youmeb-routes

A simple routing module for express.js.

youmeb-routes

A simple routing module for express.js.

youmeb-routes-example-app

git clone git://github.com/YouMeb/youmeb-routes-example-app
cd youmeb-routes-example-app
npm install
node app.js
module.exports = function () {
  
  this.$({
    name: 'controllerName',   // default: [filename]
    path: '/example'          // default: ''
  });

  this.index = {
    name: '',                               // default: 'index'
    path: '/',                              // default: '/'
    middlewares: ['middlewareName'],        // default: []
    handler: function (req, res, next) {
      //...
    }
  };

};
Routes.create(app)  // or (new Routes(app))
  .source(path.join(__dirname, 'controllers-folder-1'))
  .source(path.join(__dirname, 'controllers-folder-2'))
  .generate(function (err) {
    if (err) {
      return console.error(err);
    }
    // create server
  });
req.$routes.generateUrl('routeName', {
  param1: '...',
  param2: '...'
});
path('routeName', {})
routes.defineMiddleware('middlewareName', function () {});

(The MIT License)

Copyright (c) 2013 YouMeb and contributors.