feat(rate-limit): implement three-tier rate limiting with burst limits - #162
feat(rate-limit): implement three-tier rate limiting with burst limits#162samjay8 wants to merge 7 commits into
Conversation
- Add 'webhook' tier alongside existing 'api' and 'auth' tiers
- Add per-tier burst rate limiting (per-second spike ceiling)
- Add rate limit response headers (X-RateLimit-Limit, X-RateLimit-Reset,
Retry-After) from the NestJS ThrottlerGuard
- Configure webhook tier limits via THROTTLE_WEBHOOK_LIMIT env var
- Configure burst limits via THROTTLE_API_BURST, THROTTLE_AUTH_BURST,
THROTTLE_WEBHOOK_BURST env vars
- Apply @ThrottleTierDecorator('webhook') to WebhookController
- Add unit tests for tier routing, burst limiting, and tracker scoping
|
@samjay8 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Needs changes AstroidThrottlerGuard hardcodes burst limit defaults instead of reading the injected ConfigService values.
Reviewed commit: |
There was a problem hiding this comment.
Needs changes
AstroidThrottlerGuard hardcodes burst limit defaults instead of reading the injected ConfigService values.
src/common/guards/throttler.guard.ts:138: getBurstLimit uses hardcoded defaults (api: 10, auth: 3, webhook: 5) instead of reading throttle burst configuration from the injected ConfigService.
Reviewed commit: f594be1d27cd9cc3601c34ed7e6af08117bfa392.
|
MergeKeeper review Scope: in scope for linked issue Successfully implemented three-tier rate limiting with webhook tier, burst limits, and corresponding tests. Reviewed commit: |
|
MergeKeeper merge status Status: blocked Reason: Next steps:
|
Closes #78
Summary
webhookalongside the existingapiandauthtiers, with its own configurable limit (default 30 req/min) and burst ceiling (default 5 req/sec)X-RateLimit-Limit,X-RateLimit-Reset,Retry-After) from the NestJSThrottlerGuard, so clients can see their remaining budget@ThrottleTierDecorator('webhook')toWebhookControllerto scope webhook management endpoints to the webhook tierScope
Does not touch the
SlidingWindowThrottlerGuard(Redis-backed sliding window), the sliding-window spec, or any domain modules beyond the webhook controller tier annotation.Testing
npm run typecheck(type safety)npm run lint(no new lint errors)npm test(new throttler guard spec + existing sliding-window spec)npm run build(successful build)Files changed
src/common/decorators/throttle-tier.decorator.ts— ExtendedThrottleTierunion to include'webhook'src/common/guards/throttler.guard.ts— Added burst limiting, rate-limit headers, and webhook tier supportsrc/common/guards/throttler.guard.spec.ts— New tests for tier routing, burst limits, tracker scopingsrc/config/env.validation.ts— AddedTHROTTLE_WEBHOOK_LIMIT,THROTTLE_*_BURSTenv varssrc/config/queue.config.ts— AddedwebhookLimit,apiBurst,authBurst,webhookBurstto config typesrc/app.module.ts— Registered thewebhooknamed throttlersrc/modules/webhooks/webhook.controller.ts— Applied@ThrottleTierDecorator('webhook').env.example— Documented new rate-limit env vars