hapi-droutes

0.0.5 • Public • Published

Another hapi router

0.0.3

Dynamic/pattern whay loading routes in hapi.

Setup

$ npm install hapi-droutes

Example module registration

server.register({
    register: require('hapi-droutes'),
    options: {
        'root':'routes/please/search_in/here',
        'match':'resource/*/route.*.js',
        'dependencies':['hello','hapi']
    }
}, function (err) {
    if (err) throw err;
});

the example will match all files in resource/any dir/route.any file.js

Options /node-Glob/

  • root: where root and cwd /for package Glob/ will be set
  • match: what to match

Example router

module.exports = function(greet, name) {
    return {
        method: 'GET',
        Path: '/',
        handler: function(request, reply) {
 
            return reply(greet + ' ' + name);
        }
    };
};
 

TODO

  • proper log to hapi log
  • dependency injection
  • check for few properties in required route, eg, should have at least method and Path

Readme

Keywords

Package Sidebar

Install

npm i hapi-droutes

Weekly Downloads

1

Version

0.0.5

License

MIT

Last publish

Collaborators

  • zetxx