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 ruleP2universalStack: node
httpconstantsreadabilityapi
Use shared HTTP status constants instead of magic numbers
Reference a shared status constant (e.g. HTTP_STATUS.UNAUTHORIZED) rather than hard-coding numeric status codes in handlers.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | if (!blaize_session) { |
| 2 | return res.status(401).json({ message: 'Unauthorized: Missing session.' }); |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (!blaize_session) { |
| 2 | return res.status(HTTP_STATUS.UNAUTHORIZED).json({ message: 'Unauthorized: Missing session.' }); |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)