Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Return the proxy route's own status, not the upstream service's
A BFF/proxy route should respond with a status reflecting its own success/failure, not blindly forward the upstream's status to the client.
Bad example
| 1 | const upstream = await UpstreamService.get(); |
| 2 | res.status(upstream.status).json(upstream.data); // leaks upstream 404/500 as this route's status |
Explanation (EN)
Blind status forwarding can expose an internal dependency contract unrelated to the requested resource.
Objašnjenje (HR)
Good example
| 1 | const upstream = await UpstreamService.get(); |
| 2 | if (!upstream.ok) return res.status(502).json({ error: 'Upstream failed' }); |
| 3 | res.status(200).json(upstream.data); |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
For a BFF route, define its public status contract and map upstream failures according to whether they represent this resource or an internal dependency failure.
Exceptions / Tradeoffs (EN)
A transparent proxy may intentionally preserve upstream status. An upstream not-found or validation failure may correctly map to 404 or 4xx; do not blanket-convert every failure to 502.