5.0.3 • Published 5 years ago

hapi-routes v5.0.3

Weekly downloads
1,042
License
MIT
Repository
github
Last release
5 years ago

Hapi Routes Build Status

hapi plugin for registering routes

What

Hapi Routes allows you to put all your routing logic in different files in a specified folder. This allows you to have a clear overview of your routes.

How

server.js

const server = new Hapi.server();

await server.register({
  plugin: require('hapi-routes'),
  options: {
    dir: `${__dirname}/test/routes/*`,
  },
});

options take the following arguments:

{
  dir: String,  // (Required): Relative path where to search for route files.
                               Requires a globable path: 'routes/*', 'routes/**/*.js', etc
  test: RegExp, // (Optional): Regular expression for matching files, defaults to /\.(js)$/
}

In the example the routes are located in test/routes relative to the server.js module.

Hapi Routes requires that your route files have a routes method exported:

test/routes/example.js

const routes = [{
  method: 'GET',
  path: '/',
  handler: (request, reply) => reply('Hello world'),
}];

exports.routes = server => server.route(routes);
5.0.3

5 years ago

5.0.2

6 years ago

5.0.0

7 years ago

4.0.0

8 years ago

3.0.0

8 years ago

2.2.3

9 years ago

2.2.2

9 years ago

2.2.1

9 years ago

2.2.0

9 years ago

2.1.2

9 years ago

2.1.1

10 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.1

10 years ago