hapi-plug-routes
v1.0.2
Published
npm module to allow registering routes from a specific folder
Downloads
10
Readme
hapi-plug-routes
What is hapi-plug-routes?
A simple npm module to register routes contained in separated files from a specific folder. Sub-folders will work as well.
By registering this plugin you will be able to specify a folder that contains .js files with hapi.js routes which will then automatically become available to the server.
Usage
$ npm i hapi-plug-routes --save
/src/routes/helloWorld.js
module.exports = {
method: 'GET',
path: '/',
handler: function (request, reply) {
reply('Hello, World!');
}
};
/app.js
server.register([
{
register: require('hapi-plug-routes'),
options: {
directory: '/src/routes/'
}
}
], function(err) {
if (err) {
console.error('Failed to load plugin:', err);
}
server.start();
});
Configuration
- directory (default: '/src/routes') - path to directory containing routes
Release History
- v1.0.0 (2015-05-24)
- initial release
- v1.0.1 (2015-05-26)
- added default for the 'directory' option
- v1.0.2 (2015-09-13)
- updated dependencies