Skip to content

Commit 59217c2

Browse files
test
1 parent f523ce8 commit 59217c2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

backend/server.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ app.delete('/api/users/:id', async (req, res) => {
4242
});
4343

4444
// ✅ Add this test route for CI/CD health check
45-
app.get('/api/test', (req, res) => {
46-
res.status(200).json({ message: 'Backend is up!' });
45+
app.get('/api/test', async (req, res) => {
46+
const dbStatus = mongoose.connection.readyState;
47+
48+
if (dbStatus === 1) {
49+
res.status(200).json({ message: '✅ Backend and DB are up!' });
50+
} else {
51+
res.status(500).json({ message: '❌ Backend OK but DB not connected' });
52+
}
4753
});
4854

4955
app.listen(process.env.PORT || 5000, () => {

0 commit comments

Comments
 (0)