Skip to content

Instantly share code, notes, and snippets.

@aalimovs
Created June 22, 2017 17:30
Show Gist options
  • Save aalimovs/ddb2a51eb06b1f10c90b8f367c4d06f1 to your computer and use it in GitHub Desktop.
Save aalimovs/ddb2a51eb06b1f10c90b8f367c4d06f1 to your computer and use it in GitHub Desktop.
'use strict';
const Version = require('./../package.json').version;
const Hostname = require('os').hostname();
const internals = {
handlers: {},
};
exports.register = function (server, options, next) {
server.route([{
method: 'GET',
path: '/health',
config: internals.handlers.health,
}, {
method: 'GET',
path: '/foo',
config: internals.handlers.getFoo,
}]);
return next();
};
internals.handlers.health = {
tags: ['api'],
description: 'Health Check',
notes: 'Return 200',
plugins: {
'hapi-swagger': {
responses: {
200: { description: 'Success' },
},
},
},
auth: false,
handler: function (request, reply) {
reply(`v${Version} - ${Hostname} - healthy`);
},
};
internals.handlers.getFoo = {
tags: ['api'],
description: 'Get foo',
notes: 'Returns foo',
plugins: {
'hapi-swagger': {
responses: {
200: { description: 'Success' },
},
},
},
auth: false,
handler: function (request, reply) {
reply('foo');
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment