all files / lib/routers/ mountHealth.js

100% Statements 20/20
75% Branches 3/4
100% Functions 2/2
100% Lines 17/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                                16×    
'use strict';
 
Object.defineProperty(exports, "__esModule", {
        value: true
});
exports.default = mountHealth;
 
var _express = require('express');
 
var _express2 = _interopRequireDefault(_express);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
//endregion
 
const context = {
        router: _express2.default.Router(),
        logger: null
}; //region 1. Platform Libraries
 
 
context.router.get('/', (req, res) => {
        const log = (lvl, msg) => context.logger.log(lvl, msg, { tags: 'GET /health' });
        res.type('text/plain');
        res.status(200).send(new Buffer('HEALTHY'));
        log('debug', '200 OK');
});
 
//noinspection JSUnusedGlobalSymbols
/**
 * Mount router for /health
 * @param {object}         options          Options
 * @param {object}         options.app      Express App
 * @param {winston.Logger} options.logger   Logger
 */
function mountHealth(options) {
        context.logger = options.logger;
        const log = (lvl, msg) => context.logger.log(lvl, msg, { tags: 'mountHealth' });
        log('debug', 'Mounting router for /health....');
        options.app.use('/health', context.router);
        log('info', 'Router for /recorders Mounted');
}
//# sourceMappingURL=mountHealth.js.map