feat(rate-limits): make rate limits configurable via environment variables#892
feat(rate-limits): make rate limits configurable via environment variables#892waleedlatif1 merged 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Greptile Summary
This PR refactors the rate limiting system to use configurable environment variables instead of hardcoded values. The change affects the core rate limiting infrastructure by:
-
Environment Configuration: Adds 10 new environment variables in
env.tsfor rate limiting configuration, including window duration (RATE_LIMIT_WINDOW_MS), manual execution bypass limit (MANUAL_EXECUTION_LIMIT), and tier-specific limits for sync/async API executions across free, pro, team, and enterprise subscription plans. -
Service Layer Updates: Modifies the
RateLimiterservice to consume these environment variables through thetypes.tsmodule, replacing hardcoded values like60000(1 minute window) and999999(manual execution limit) with configurable constants. -
Test Alignment: Updates the test suite to use the new
MANUAL_EXECUTION_LIMITconstant instead of hardcoded expectations, ensuring tests validate actual runtime behavior. -
Deployment Configuration: Updates the Helm chart's
values.yamlto include the new environment variables with sensible defaults that maintain existing behavior.
This change integrates well with the existing environment management system that uses @t3-oss/env-nextjs and Zod validation. The rate limiting system follows a tiered subscription model where higher-paying customers get increased API execution limits, with separate controls for synchronous and asynchronous operations. The implementation maintains backward compatibility through default values while enabling operational flexibility for different deployment environments.
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it maintains existing behavior through sensible defaults
- Score reflects well-structured changes that follow established patterns and maintain backward compatibility
- No files require special attention as all changes are straightforward configuration updates
5 files reviewed, no comments
…ables (#892) * feat(rate-limits): make rate limits configurable via environment variables * add defaults for CI
…ables (simstudioai#892) * feat(rate-limits): make rate limits configurable via environment variables * add defaults for CI
Summary
Make rate limits configurable via environment variables, default values are what we had before as magic number so no need to set them anywhere
Type of Change
Testing
N/A
Checklist