Created
June 22, 2017 17:30
-
-
Save aalimovs/ddb2a51eb06b1f10c90b8f367c4d06f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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