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
dryapirouting
Consolidate API routes that do essentially the same work
When two endpoints differ only in where a parameter comes from or a minor branch, merge them into one route that handles the variation instead of maintaining duplicates.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | // /api/remove-instrument reads insref from req.body |
| 2 | // /api/delete-instruments reads insref from req.query (otherwise identical) |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // single route accepting insref from body or query |
| 2 | const insref = req.body.insref ?? req.query.insref; |
Explanation (EN)
Objašnjenje (HR)