@jinoantony/express-route-group
v1.0.1
Published
A package to add route groups and group specific middlewares in express
Downloads
5
Readme
Express route group
This package enables you to create route groups and assign middlewares to those groups.
Install
npm install @jinoantony/express-route-group
Usage
const express = require('express')
require('@jinoantony/express-route-group')(express.Router)
const router = express.Router()
...
router.group({middleware: [isAuthenticated]}, function(router) {
router.get('/', UserController.get)
})
You can also add prefix for your groups.
router.group(
{
middleware: [isAuthenticated, csrf],
prefix: '/users'
},
function(router) {
router.get('/', UserController.get)
}
)
Routes defined outside the groups are not affected by the prefix
and middleware
specified in the group.