Skip to content

feat: add rate limiting to all API endpoints (not just payment) - #296

Merged
Nathydre merged 1 commit into
nathydre21:mainfrom
oche11207-art:fix/add-rate-limiting-all-endpoints
Jun 19, 2026
Merged

feat: add rate limiting to all API endpoints (not just payment)#296
Nathydre merged 1 commit into
nathydre21:mainfrom
oche11207-art:fix/add-rate-limiting-all-endpoints

Conversation

@oche11207-art

Copy link
Copy Markdown
Contributor

Summary

Closes #275

Changes

  • Added EndpointType enum (READ / WRITE) to shared types
  • Configured endpoint-type multipliers: READ = 3x, WRITE = 1x tier limits
  • Updated TieredRateLimiter middleware to accept endpoint type options
    • Auto-detects from HTTP method: GET/HEAD/OPTIONS → READ, everything else → WRITE
    • Added X-RateLimit-Type response header
  • Applied rate limiting globally to all /api routes in server.ts

Acceptance Criteria

  • Apply tiered rate limiting to all API endpoints
  • Configure different rate limits per endpoint type (read vs write)
  • Add rate limit headers to all responses
  • All tests pass (257/263 passing; 6 failures are pre-existing)

Test Results

  • TypeScript typecheck: ✅ passed
  • Backend tests: 257/263 passing (6 failures are pre-existing)
  • Rate limiter tests: 16/16 passing

Files Changed

  • shared/types.ts — Added EndpointType enum
  • backend/src/config/rateLimits.ts — Added endpoint type multipliers
  • backend/src/middleware/rateLimiter.ts — Updated middleware with endpoint type support
  • backend/src/types/userTier.ts — Re-exported EndpointType
  • backend/src/server.ts — Applied global rate limiting to /api routes

- Add EndpointType enum (READ / WRITE) to shared types
- Configure endpoint-type multipliers: READ = 3x, WRITE = 1x tier limit
- Update TieredRateLimiter middleware to accept endpoint type and
  auto-detect from HTTP method (GET/HEAD/OPTIONS → READ, else WRITE)
- Add X-RateLimit-Type response header for observability
- Apply rate limiting globally to all /api routes via single middleware

Closes nathydre21#275
@Nathydre
Nathydre merged commit 2a5b2c5 into nathydre21:main Jun 19, 2026
9 of 11 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.

Add Rate Limiting to All API Endpoints (Not Just Payment)

2 participants