Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Avoid colliding base paths across controllers; prefix distinct resources
Two controllers sharing the same base path make routing depend on registration order and subpath overlap; give each resource its own prefix to keep routes unambiguous.
Bad example
| 1 | @Controller('api/resource') // controller A |
| 2 | @Controller('api/resource') // controller B — :id vs /sub ordering becomes fragile |
Explanation (EN)
Overlapping parameter and literal paths can dispatch to the wrong controller depending on registration order.
Objašnjenje (HR)
Good example
| 1 | @Controller('api/resource') // resource root |
| 2 | @Controller('api/resource/items') // distinct sub-resource prefix |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Compare full HTTP method/path registrations, parameter matchers and registration order when related controllers share a prefix; separate ambiguous routes or constrain them explicitly.
Exceptions / Tradeoffs (EN)
Sharing a base prefix is valid when the complete route patterns are disjoint and the framework resolves them predictably. A prefix change is an API contract change.