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 ruleP0universalStack: any
configurationfail-fastsecuritycorrectness
Fail fast when required environment variables are missing
Validate mandatory env vars at startup and throw, instead of silently defaulting to an empty/placeholder value.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | protected readonly apikey: string = process.env.DR_EDITION_APIKEY || ''; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | function requireEnv(key: string): string { |
| 2 | const value = process.env[key]; |
| 3 | if (!value) throw new Error(`Environment variable '${key}' is missing.`); |
| 4 | return value; |
| 5 | } |
| 6 | protected readonly apikey: string = requireEnv('DR_EDITION_APIKEY'); |
Explanation (EN)
Objašnjenje (HR)