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
apihttpresponse-shaperest
Do not duplicate the HTTP status in the JSON response body
Set the status code on the response itself; don't also include a status field in the body since the client can read it from the response.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | return res.status(400).json({ message: 'Invalid request body', status: 400 }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | return res.status(400).json({ message: 'Invalid request body' }); |
| 2 | // client reads the code from response.status |
Explanation (EN)
Objašnjenje (HR)