Skip to content

Commit

Permalink
Merge pull request #318 from wafflestudio/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
davin111 authored Aug 3, 2023
2 parents 42731c0 + e80fdfe commit 6d3c2f6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/api/routes/RootRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@ import ExpressPromiseRouter from 'express-promise-router';
import MonitorRouter = require('./MonitorRouter');
import StaticPageRouter = require('./StaticPageRouter');
import ApiRouter = require('./ApiRouter');
import mongoose = require('mongoose');

let router = ExpressPromiseRouter();

router.get('/health-check', (req, res) => res.sendStatus(200));
router.get('/health-check', (req, res) => {
if (mongoose.connection.readyState !== 1) {
res.status(500).json({ message: 'MongoDB connection failed' });
return;
}

mongoose.connection.db.admin().ping((err, result) => {
if (err) {
res.status(500).json({ message: 'MongoDB connection failed' });
return;
}
res.status(200).json({ message: 'ok' });
});
});

router.use('/monitor', MonitorRouter);

router.use(function(req, res) {
Expand Down

0 comments on commit 6d3c2f6

Please sign in to comment.