express-routes-group

1.0.4 • Public • Published

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:

var app = require('express');
require('express-group-routes');
 
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:

var app = require('express');
require('express-group-routes');
 
app
  .group((router) => {
      router.use(middleware1);
  })
  .group((router) => {
      router.use(middleware2);
  });
  • Inspired from express-group-routes

Readme

Keywords

none

Package Sidebar

Install

npm i express-routes-group

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

1.85 kB

Total Files

3

Last publish

Collaborators

  • ashetm