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 ruleP1universalStack: node
httpapicorrectnessstatus-code
Check the HTTP status the upstream API actually returns on success
Validate responses against the status code the upstream service truly returns (for example 201 on create), not an assumed one, to avoid false negatives.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codejavascript
| 1 | const response = await UserApi.save(req.body); |
| 2 | if (response.status !== 200) { |
| 3 | return res.status(500).send({ error: 'save failed' }); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | // Upstream returns 201 on a successful create |
| 2 | const response = await UserApi.save(req.body); |
| 3 | if (response.status !== 201) { |
| 4 | return res.status(500).send({ error: 'save failed' }); |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)