Skip to content

fork-js/group-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@forkjs/group-router

Group Router for express.js

What is @forkjs/group-router

@forkjs/group-router gives you flexibility to writer your express.js routes in group format which is easy to write and maintain. It also provides you support for group level middlewares.

See the Quick start guide for more details.

Initialize Router

var app = require("@forkjs/group-router");

To Specify the API Version, this will add prefix to the routes if specified

app.version = "v3";

To Group Routes with a prefix

app.group("/users", function(){

app.post("/create", userController.create);
app.post("/login", userController.login);
app.get("/get", userController.get);

});

To Add a middileware to a group, supprts Array of Middlewares / Signle

app.group("/users", function(){

app.post("/create", userController.create);
app.get("/get", userController.get);

}, Middlewares.Auth);

Middlewares can be added to specific routes as well

app.post("/updateTasks", taskController.update, Middlewares.Auth);

Installation

npm install @forkjs/group-router

Important

Don't forget to return app.router from your route file.

module.exports = app.router;

Contributors

  • Eshant Sahu

Sample Application

Sample Application implented with @forkjs/group-router can be found at here

About

Group Router for ForkJS and express.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published