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
separation-of-concernsprovidersmappingarchitecture
Keep response mapping out of generic data-fetching layers
Don't bury domain-specific shaping or interface mapping inside a generic provider/fetch layer; put it in a dedicated mapper or the upstream service so providers stay reusable.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | class ArticleProvider { |
| 2 | async get() { |
| 3 | const raw = await api.fetch(); |
| 4 | return raw.map(r => ({ title: r.headline, url: r.link })); // mapping leaked into provider |
| 5 | } |
| 6 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | class ArticleProvider { |
| 2 | async get() { return api.fetch(); } |
| 3 | } |
| 4 | // mapping lives in a dedicated mapper / the upstream service |
| 5 | const article = articleMapper.toArticle(raw); |
Explanation (EN)
Objašnjenje (HR)