Skip to content

Commit 98d96c5

Browse files
authored
Merge pull request #39 from ekanshgupta2046/added-health-endpoint
Added /health endpoint and integrate route
2 parents acb1e60 + 0d3d353 commit 98d96c5

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

server/package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import express from "express";
22
import dotenv from "dotenv";
33
import authRoutes from "./routes/authRoutes.js";
4+
import healthRoutes from "./routes/healthRoutes.js";
45
import { errorHandler } from "./middleware/errorHandler.js";
56

67
dotenv.config();
@@ -10,6 +11,7 @@ app.use(express.json());
1011

1112
// Routes
1213
app.use("/api/auth", authRoutes);
14+
app.use("/api/health", healthRoutes);
1315

1416
// Error Handler
1517
app.use(errorHandler);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Request, Response, NextFunction } from 'express';
2+
3+
export const healthCheck = async (req: Request, res: Response, next: NextFunction) => {
4+
try {
5+
return res.status(200).json({ status: 'ok' });// Responds with { status: "ok" } if server is running
6+
} catch (error) {
7+
next(error);
8+
}
9+
};

server/src/routes/healthRoutes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Router } from 'express';
2+
import { healthCheck } from '../controllers/healthController.js';
3+
4+
5+
const router = Router();
6+
router.get('/', healthCheck);
7+
8+
export default router;

0 commit comments

Comments
 (0)