hapi-route-auto-reg
v1.0.4
Published
Automatic registration for hapi routes
Downloads
8
Readme
Automatically scans the directory and registers the routes it finds within
installation:
npm install hapi-route-auto-reg
usage:
var hapi = require("hapi");
var server = Hapi.createServer('127.0.0.1', 3000, {});
server.pack.register([
{
plugin: require("hapi-route-auto-reg"),
options: {
directory: './path/to/routes'
}
}], function(err){
if(err) {
throw err;
}
server.start(function(){
server.log('server started...');
});
});
Scans the given directory for .js files which export a method .routes(plugin)
and invokes them.
The routes files should look like this:
module.exports.routes = function(plugin){
plugin.route([
{
method: 'GET',
path: '/my/test/route',
config: {
handler: function(request, reply) {
...
}
}
}
]);
}