Performance: Router-level middleware
MEDIUM IMPACT
This affects server response time and throughput by controlling how requests are processed and routed.
router.use('/specific-path', (req, res, next) => { /* logic */ next(); });
app.use((req, res, next) => { /* heavy logic */ next(); });| Pattern | CPU Usage | Blocking | Request Latency | Verdict |
|---|---|---|---|---|
| Global middleware on all routes | High | No | Increased | [X] Bad |
| Middleware scoped to specific routes | Low | No | Reduced | [OK] Good |
| Synchronous blocking middleware | High | Yes | Severely Increased | [X] Bad |
| Asynchronous non-blocking middleware | Moderate | No | Optimized | [OK] Good |