Skip to content

Commit 657faa5

Browse files
committed
feat: add /health endpoint and exclude it from request logging
1 parent abbd70b commit 657faa5

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/app.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,27 @@ app.use(cors({
2424
credentials: true
2525
}));
2626
app.use(express.json());
27-
app.use(morgan('dev'));
27+
28+
app.use(morgan('dev', {
29+
skip: (req) => req.url === '/health'
30+
})
31+
);
2832

2933
app.get('/', (_req, res) => {
3034
res.status(200).json({
3135
message: "Backend is online"
3236
})
3337
});
3438

39+
app.get('/health', (_req, res) => {
40+
res.status(200).json({
41+
status: "ok",
42+
service: "hms-backend",
43+
uptime: process.uptime(),
44+
timestamp: new Date().toISOString()
45+
});
46+
});
47+
3548
app.use('/api/auth', authRoutes);
3649
app.use('/api/signup', signupRoutes);
3750
app.use('/api/admin', adminRoutes);

0 commit comments

Comments
 (0)