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 ruleP0universalStack: node
api-designcontrol-flowcorrectness
Return after sending an API response to stop further execution
Always return when writing a response in a route handler so code below doesn't keep running.
PR: hegnar-forum-web · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | if (bad) res.status(400).json({ message }); |
| 2 | // execution continues, may double-send |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | if (bad) return res.status(400).json({ message }); |
Explanation (EN)
Objašnjenje (HR)