Skip to content

Commit

Permalink
Code cleanup, removed harcoded values and commneted code from health API
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek Y committed Oct 10, 2024
1 parent f0c9aed commit d122d90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
6 changes: 2 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 3 additions & 15 deletions src/routes/requests.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,10 @@ if (
requestsRouter.get("/health", async (req: Request, res: Response) => {
try {
const health = {
status: "UP",
status: "up",
components: {
db: {
status: "UP",
details: {
database: "MongoDB",
}
},
diskSpace: {
status: "UP",
status: "up",
details: getDiskSpaceDetails()
}
}
Expand All @@ -210,19 +204,13 @@ requestsRouter.get("/health", async (req: Request, res: Response) => {
res.json(health);
} catch (error: any) {
logger.error(`Health check failed: ${error.message}`);
res.status(500).json({ status: "DOWN", error: error.message });
res.status(500).json({ status: "down", error: error.message });
}
});

function getDiskSpaceDetails() {
const path = __dirname;
const stats = fs.statSync(path);
// const total = stats.blocks * stats.bsize;
// const free = stats.bfree * stats.bsize;
return {
// total: total,
// free: free,
threshold: 10485760, // 10 MB threshold (example value)
path: path,
exists: true
};
Expand Down

0 comments on commit d122d90

Please sign in to comment.