trafico v1.0.8
🚥 Awesome -zero dependency- router for Express.
Tráfico will map routes to controllers and enable them in your Express application, so you don't have to do it manually and for each one. This provides an easier abstraction and enables a drop-in-and-use route/controller setup.
Basic use
const express = require('express');
const Trafico = require('trafico');
const app = express();
const trafico = new Trafico({
  express,
  routes: `/path/to/routes`,
  controllers: `/path/to/controllers`
});
app.use(trafico.route());
app.listen(port, () => {
  console.log(`Up on port: ${port}`);
});Routes
In your routes folder (/path/to/routes) create the routes you need to be mapped to your application. For example:
| path/to/routes
  | home.js
  | user.jsThe home.js route would look similar to this (define your routes as you normally would in your Express application):
module.exports = (router, controller) => {
  router.get('/', controller.index);
  router.get('/date', controller.date);
  return router;
};Controllers
Tráfico will load all routes from the routes path you specify and try to look for the controllers to match them. Create your controllers in the controllers folder (/path/to/controllers). Controllers must be named like their corresponding routes.
| path/to/controllers
  | home.js
  | user.jsThe home.js controller would expose the methods mapped in the route:
module.exports = {
  index: (req, res) => {
    res.send({ hello: 'world' });
  },
  
  date: (req, res) => {
    res.send({ date: +new Date() });
  }
};Working examples
Have a look at the /test folder. ExpressBoilerplate also uses Tráfico.
Contribute
fork https://github.com/aichholzer/trafico