Router for Express.JS
Create your routes file in JSON and redirect each route to controllers. You can inject middlewares and errors handler. You can configure view engine rendering and give static files.
You can see Documentation
Try it with examples
-
Manage application's routes at same place
-
Add middleware with method, level and/or inheritance
-
Handle errors and Not Found page
-
Manage static routes
npm i express-imp-router --save
./index.js
const express = require('express');
const router = require('express-imp-router');
const app = express();
router(app);
router.route([
{
controllers: './controllers',
middlewares: './middlewares',
routes: {
'/': {
get: 'HomeController#home'
}
},
}
]);
app.listen(8080);
./controllers/HomeController.js
module.exports = {
home: (req, res, next) => {
const id = req.params.id;
res.send({
message: 'ok'
})
},
}
git clone https://github.com/MaximeMaillet/express-imp-router.git
cd express-imp-router
nvm install
npm install
Tests :
npm test