express-use-shortcut
DEPRECATED: use express-shortcut instead.
Helper function that avoids calling app.use
multiple times for middlewares. You can pass as many middlewares you need passing Express instance only once.
Installation
npm install express-use-shortcut --save
The problem
The following code is very common in Express applications. It registers many middlewares:
const express = app = cookieParser = session = passport = ; app;app;app;app;
It's not too hard to figure out that we are calling app.use
too many times.
express-use-shortcut usage
Let's see the previous example with express-use-shortcut
:
const express = app = cookieParser = session = passport = use = ; app;
If a path is necessary, you can pass the path and the middleware within an array:
app;