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 ruleP1universalStack: node
api-designtypescontrollerscorrectness
An endpoint that returns data should not be typed as void
If a handler responds with a payload, its return type must reflect that payload; a GET that produces data should not be declared to return void.
PR: hegnar-investor-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | @Get('/top-contributor') |
| 2 | async getTopContributor(): Promise<void> { |
| 3 | return this.service.getTopContributor(); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | @Get('/top-contributor') |
| 2 | async getTopContributor(): Promise<TopContributorDto> { |
| 3 | return this.service.getTopContributor(); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)