Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2stack specificStack: node
expressroutingdead-coderedundancy
Skip routes that only return the same fallback the default handler already provides
Do not register explicit routes whose only job is to return the same 404/fallback that a catch-all handler already produces.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codejavascript
| 1 | // A dedicated handler that just 404s |
| 2 | app.get('/legacy-section/*', (req, res) => res.status(404).send()); |
| 3 | // ...later, the framework's own fallback also 404s |
| 4 | app.use(notFoundHandler); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | // Let the existing catch-all fallback handle unknown paths |
| 2 | app.use(notFoundHandler); // already returns 404 for /legacy-section/* |
Explanation (EN)
Objašnjenje (HR)