feat(rate-limit): enforce rate limit configuration in production environment

This commit is contained in:
Yusuf İpek
2026-04-10 21:13:43 +03:00
parent d07b40a937
commit c92181b90f
+7
View File
@@ -26,6 +26,13 @@ function isRateLimitDisabled(): boolean {
return rawValue !== undefined && TRUTHY_ENV_VALUES.has(rawValue); return rawValue !== undefined && TRUTHY_ENV_VALUES.has(rawValue);
} }
if (process.env.NODE_ENV === 'production' && isRateLimitDisabled()) {
throw new Error(
'DISABLE_RATE_LIMIT must not be set in production. ' +
'Remove or unset the environment variable before deploying.'
);
}
// Industry-standard rate limit defaults per action // Industry-standard rate limit defaults per action
export const RATE_LIMIT_CONFIGS: Record<string, RateLimitConfig> = { export const RATE_LIMIT_CONFIGS: Record<string, RateLimitConfig> = {
// Auth — strict to prevent brute force / credential stuffing // Auth — strict to prevent brute force / credential stuffing