Environment and configuration values should be explicit, visible, and environment-aware. Avoid hardcoded production values, hidden configuration properties, and complex environment variable logic. Instead:
Environment and configuration values should be explicit, visible, and environment-aware. Avoid hardcoded production values, hidden configuration properties, and complex environment variable logic. Instead:
// Good export const skipAuth = process.env.SKIP_AUTH === ‘true’ || false;
2. Make configuration properties visible and customizable:
```typescript
// Bad
class Config {
@Env('DB_NAME')
database: string = 'production_db'; // Hardcoded production value
}
// Good
class Config {
@Env('DB_NAME')
database: string = 'local_db'; // Development-friendly default
@Env('API_URL')
apiUrl: string = 'http://localhost:3000'; // Visible and configurable
}
// Good const DIST_DIR = process.env.DIST_DIR || join(__dirname, ‘dist’); ```
This approach improves maintainability, prevents production issues, and makes configuration more transparent for developers and operators.
Enter the URL of a public GitHub repository