JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 294
  • Score
    100M100P100Q92136F
  • License MIT

Opinionated route loader for hapi

Package Exports

  • hapi-router

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hapi-router) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#hapi-router Build Status Code Climate Test Coverage Version Downloads

Opinionated route loader for hapi.

Setup

$ npm install hapi-router
server.register({
  register: require('hapi-router')
  options: { routesDir: __dirname + '/routes/' }
}, function (err) {
  if (err) throw err;
});

Options

The following required options should be provided at registration:

  • routesDir: the path to your routes directory

Specifying Routes

Any .js files in your routes directory will be loaded - supports nested routes

Example route file:

module.exports = [
  {
    path: '/test1',
    method: 'GET',
    handler: function (request, reply) {
      reply('hello');
    }
  },
  {
    path: '/test2',
    method: 'GET',
    handler: function (request, reply) {
      reply('hello');
    }
  }
]