Commit b50590d
authored
chore(api): Retrieve DEFAULT_RATE_LIMIT_PER_MIN using zod (#5077)
<!-- Describe the problem and your solution -->
The existing usage of `DEFAULT_RATE_LIMIT_PER_MIN` env var had 2 issues
- It didn't use zod, which is the standard way of parsing and using env
vars in the codebase
- It defaulted to 3500 if it's missing, which is a lot higher than our
actual current base default.
This PR addresses both of these. The default value is set to 200, which
is our current base default, but only for type-safety reasons. We make
sure to set this value in all services and environments that would use
this variable regardless.
<!-- Issue ticket number and link (if applicable) -->
<!-- Testing instructions (skip if just adding/editing providers) -->
<!-- Summary by @propel-code-bot -->
---
**Switch rate-limit default to zod-parsed env & lower fallback value**
Replaces direct `process.env` access with typed retrieval via `envs`
object and adjusts the fallback value of `DEFAULT_RATE_LIMIT_PER_MIN`
from 3500 to 200. Keeps rate-limiter logic unchanged otherwise and
aligns with the codebase’s standard zod-based env parsing.
<details>
<summary><strong>Key Changes</strong></summary>
• Removed inline parsing of `process.env['DEFAULT_RATE_LIMIT_PER_MIN']`
in `packages/server/lib/middleware/ratelimit.middleware.ts`
• Added `envs.DEFAULT_RATE_LIMIT_PER_MIN` import and usage
• Updated zod schema in `packages/utils/lib/environment/parse.ts` to
`.default(200)` instead of leaving undefined or defaulting in code
</details>
<details>
<summary><strong>Affected Areas</strong></summary>
• `packages/server/lib/middleware/ratelimit.middleware.ts`
• `packages/utils/lib/environment/parse.ts`
</details>
---
*This summary was automatically generated by @propel-code-bot*1 parent 3193bfb commit b50590d
File tree
2 files changed
+4
-2
lines changed- packages
- server/lib/middleware
- utils/lib/environment
2 files changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | | - | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
0 commit comments