1.0.4 • Published 9 years ago

hapi-route-auto-reg v1.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

#Hapi route auto-registration Build Status NPM version Dependencies

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) {
                    ...
                }
            }
        }
    ]);
}
1.0.4

9 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.1.1

10 years ago

0.1.0

10 years ago