Skip to content

Commit

Permalink
fix(other): added /healthcheck endpoint. Fixes MEMB-562
Browse files Browse the repository at this point in the history
  • Loading branch information
serge1peshcoff committed Aug 11, 2019
1 parent cae6140 commit b39b20a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const logger = require('./logger');
const { Event, Application } = require('../models');
const helpers = require('./helpers');
const config = require('../config');
const packageInfo = require('../package');

exports.authenticateUser = async (req, res, next) => {
const token = req.header('x-auth-token');
Expand Down Expand Up @@ -122,6 +123,18 @@ exports.fetchSingleApplication = async (req, res, next) => {
return next();
};

/* istanbul ignore next */
exports.healthcheck = (req, res) => {
return res.json({
success: true,
data: {
name: packageInfo.name,
description: packageInfo.description,
version: packageInfo.version
}
});
};

/* eslint-disable no-unused-vars */
exports.notFound = (req, res, next) => errors.makeNotFoundError(res, 'No such API endpoint: ' + req.method + ' ' + req.originalUrl);

Expand Down
1 change: 1 addition & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ process.on('unhandledRejection', (err) => {

ImagesRouter.use(express.static(config.media_dir)); // Serving images.

GeneralRouter.get('/healthcheck', middlewares.healthcheck);
GeneralRouter.use(middlewares.authenticateUser);

GeneralRouter.get('/', events.listEvents);
Expand Down

0 comments on commit b39b20a

Please sign in to comment.