Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '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');
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement