Skip to content

JJJ4n/hapi-router

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hapi-router Build Status Code Climate Test Coverage npm version

Opinionated route loader for hapi.

Setup

$ npm install hapi-router
server.register({
  plugin: 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');
    }
  }
]

About

auto route loading for hapi

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%