express-inject-middleware
Inject stack of middlewares into given routes or middlewares.
With this middleware, it can easily define express routes as a group that use one set of middlewares.
Installation
npm install express-inject-middleware --save
Example Usage
Basic example
;; const app = ; const authMiddleware = { // some auth logic...}; const fooMiddleware = { // some foo logic} const barMiddleware = { // some bar logic} app;
Will become...
app;app;
Working with express.Router
;; const app = ;const router = express; const authMiddleware = { // some auth logic...}; const fooMiddleware = { // some foo logic} app;
Will become...
router;
Combine app and router
;; const app = ;const router1 = express;const router2 = express; const authMiddleware = { // some auth logic...}; router1;router2; app; // Both of the "/api/foo" and "/api/bar" will use the authMiddleware.
License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO.