2016-06-18 21:53:18 +02:00
|
|
|
'use strict';
|
2016-10-26 10:43:11 +02:00
|
|
|
|
2017-08-04 16:03:15 +02:00
|
|
|
const logger = require('../logger')('health-check.js');
|
2017-06-28 10:20:22 +02:00
|
|
|
const { Router } = require('express');
|
2015-10-02 13:46:03 +02:00
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
exports.router = function(config) {
|
|
|
|
const router = Router();
|
|
|
|
|
|
|
|
router.get('/', (req, res) => {
|
|
|
|
config.stores.db
|
|
|
|
.select(1)
|
2015-10-02 13:46:03 +02:00
|
|
|
.from('features')
|
2016-11-11 16:24:16 +01:00
|
|
|
.then(() => res.json({ health: 'GOOD' }))
|
2016-06-18 21:53:18 +02:00
|
|
|
.catch(err => {
|
2017-06-28 10:20:22 +02:00
|
|
|
logger.error(
|
|
|
|
'Could not select from features, error was: ',
|
|
|
|
err
|
|
|
|
);
|
2016-04-24 22:41:37 +02:00
|
|
|
res.status(500).json({ health: 'BAD' });
|
2015-10-02 13:46:03 +02:00
|
|
|
});
|
2014-10-20 13:03:43 +02:00
|
|
|
});
|
2017-06-28 10:20:22 +02:00
|
|
|
|
|
|
|
return router;
|
2015-10-02 13:46:03 +02:00
|
|
|
};
|