Skip to content

FAC-85 feat: API rate limiting#189

Merged
y4nder merged 2 commits intodevelopfrom
feat/fac-85-api-rate-limiting
Mar 28, 2026
Merged

FAC-85 feat: API rate limiting#189
y4nder merged 2 commits intodevelopfrom
feat/fac-85-api-rate-limiting

Conversation

@y4nder
Copy link
Copy Markdown
Member

@y4nder y4nder commented Mar 28, 2026

Summary

  • Implement @nestjs/throttler v6 with Redis-backed storage (@nest-lab/throttler-storage-redis) for per-IP request rate limiting
  • Global default of 60 req/60s, stricter limits on auth login (5/60s), auth refresh (10/60s), and Moodle login (5/60s)
  • Custom ThrottlerGuard subclass with fail-open resilience — allows requests through with a warning log if Redis is unavailable
  • Health endpoint exempt from throttling via @SkipThrottle()
  • Env-configurable global defaults (THROTTLE_TTL_SECONDS, THROTTLE_LIMIT) with Zod validation (integer, min 1)

Closes #88

Test plan

  • 4 unit tests for CustomThrottlerGuard (extends base, 429 passthrough, fail-open on Redis error, fail-open on non-Error throws)
  • 3 e2e tests (global limit exceeded returns 429, per-route stricter limit, health endpoint exempt)
  • All 561 existing unit tests pass — zero regressions
  • Lint clean
  • Manual verification: npm run start:dev + docker compose up, rapid-fire curl requests, verify 429 responses and Retry-After header
  • Manual verification: stop Redis container, verify API continues serving requests (fail-open)

Implement @nestjs/throttler with Redis-backed storage for request
rate limiting. Global default of 60 req/60s per IP with stricter
limits on auth login (5/60s), auth refresh (10/60s), and Moodle
login (5/60s). Health endpoint exempt. Custom guard fails open on
Redis unavailability with warning log.
@y4nder y4nder linked an issue Mar 28, 2026 that may be closed by this pull request
10 tasks
@y4nder y4nder self-assigned this Mar 28, 2026
@y4nder y4nder merged commit 1d7a5a7 into develop Mar 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FAC-85 feat: API rate limiting

1 participant