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 ruleP2stack specificStack: TypeScript / Express
organizationapireadability
Group related routes into their own router instead of cluttering a shared one
When two or more similar endpoints accumulate in a catch-all router, move them into a dedicated sub-router to keep the routing table readable.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | commonRouter.get('/webcasts', webcastsRoute); |
| 2 | commonRouter.get('/webcasts/:instrumentId', webcastsByInsrefRoute); |
| 3 | // mixed into the big common router |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const webcastsRouter = Router(); |
| 2 | webcastsRouter.get('/', webcastsRoute); |
| 3 | webcastsRouter.get('/:instrumentId', webcastsByInsrefRoute); |
| 4 | commonRouter.use('/webcasts', webcastsRouter); |
Explanation (EN)
Objašnjenje (HR)