https://github.com/maximemaillet/express-imp-router
Router for Express.JS
https://github.com/maximemaillet/express-imp-router
expressjs json middleware router
Last synced: 5 months ago
JSON representation
Router for Express.JS
- Host: GitHub
- URL: https://github.com/maximemaillet/express-imp-router
- Owner: MaximeMaillet
- License: gpl-3.0
- Created: 2017-07-18T08:07:41.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T15:15:22.000Z (over 3 years ago)
- Last Synced: 2025-10-04T19:15:19.768Z (9 months ago)
- Topics: expressjs, json, middleware, router
- Language: JavaScript
- Homepage:
- Size: 1.49 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Express IMP-Router
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](https://github.com/MaximeMaillet/express-imp-router/tree/master/docs)
Try it with [examples](https://github.com/MaximeMaillet/express-imp-router/tree/master/example)
## Features
- Manage application's routes at same place
- Add middleware with *method*, level and/or inheritance
- Handle errors and *Not Found* page
- Manage static routes
## Installation
```bash
npm i express-imp-router --save
```
## Usage
*./index.js*
```javascript
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*
```javascript
module.exports = {
home: (req, res, next) => {
const id = req.params.id;
res.send({
message: 'ok'
})
},
}
```
## Contributing
```bash
git clone https://github.com/MaximeMaillet/express-imp-router.git
cd express-imp-router
nvm install
npm install
```
Tests :
```bash
npm test
```