node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org »

express-routing-loader

express-routing-loader

Routing loader for NodeJS Express Web framework

Installation

$ npm install express-routing-loader

Example usages:

In your app.js file

Before app.set('port', process.env.PORT || 3000);

add line app.set('APP_DIR', __dirname);

After app.use(app.router);

add line require('express-routing-loader')(app);

Add routes.json file to your directory routes

Create catalogs

  • controllers
  • helpers
  • middleware

routes.json fromat:

[
  ["route", "controller#action"],
  ["route", "controller#action", "method"],
  ["route", "middlewareFile#middlewareFunc", "controller#action", "method"]
]

You may use more than one middleware, just write it in order you need to call.

You may don't specify method, default will be get

You may specify more than one method, wrote it divided by | character, "post|patch"

Todo plans:

  • add examples
  • add configure parameters to function to specify directories from which load
  • add dynamic helpers support
  • add to load express param routes