Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. 'use strict';
  2.  
  3. const Version = require('./../package.json').version;
  4. const Hostname = require('os').hostname();
  5.  
  6. const internals = {
  7. handlers: {},
  8. };
  9.  
  10. exports.register = function (server, options, next) {
  11. server.route([{
  12. method: 'GET',
  13. path: '/health',
  14. config: internals.handlers.health,
  15. }, {
  16. method: 'GET',
  17. path: '/foo',
  18. config: internals.handlers.getFoo,
  19. }]);
  20.  
  21. return next();
  22. };
  23.  
  24. internals.handlers.health = {
  25. tags: ['api'],
  26. description: 'Health Check',
  27. notes: 'Return 200',
  28. plugins: {
  29. 'hapi-swagger': {
  30. responses: {
  31. 200: { description: 'Success' },
  32. },
  33. },
  34. },
  35. auth: false,
  36. handler: function (request, reply) {
  37. reply(`v${Version} - ${Hostname} - healthy`);
  38. },
  39. };
  40.  
  41. internals.handlers.getFoo = {
  42. tags: ['api'],
  43. description: 'Get foo',
  44. notes: 'Returns foo',
  45. plugins: {
  46. 'hapi-swagger': {
  47. responses: {
  48. 200: { description: 'Success' },
  49. },
  50. },
  51. },
  52. auth: false,
  53. handler: function (request, reply) {
  54. reply('foo');
  55. },
  56. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement