https://github.com/ashetm/npm-express-routes-group
https://github.com/ashetm/npm-express-routes-group
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/ashetm/npm-express-routes-group
- Owner: AsheTM
- Created: 2019-11-29T11:30:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T15:19:49.000Z (over 3 years ago)
- Last Synced: 2024-04-27T02:27:29.526Z (about 2 years ago)
- Language: JavaScript
- Size: 564 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Express routes group
Simple way to group your routes in Express + chaining it.
If you want to prefix all routes with a certain URL you can use the group method as following:
```js
var app = require('express');
require('express-routes-group');
app
.group("/api/v1", (router) => {
router.get("/path1", controller1); // /api/v1/login
})
.group("/api/v2", (router) => {
router.get("/path2", controller2); // /api/v2/path2
});
```
In case you don't want to add a prefix but still need to group certain routes you can leave the first parameter
and go straight for the function:
```js
var app = require('express');
require('express-routes-group');
app
.group((router) => {
router.use(middleware1);
})
.group((router) => {
router.use(middleware2);
});
```
* Inspired from `express-group-routes`