Skip to content

[All Services] Add Rate Limiting Middleware #26

Description

@ScriptedBro

Migrated from DelegoLabs/Delego#443.
This issue belongs to the backend repository after the monorepo split.


Type
Task

Area
Backend / All Services

Complexity
Moderate

Problem
No service has rate limiting. Wallet, payments, orchestrator, and notification routes are all vulnerable to abuse and DDoS.

Implementation Scope

  • apps/backend/gateway/middleware/rateLimiter.ts (new)
  • Apply to all service routes

Functions to Implement

  1. Create a sliding-window rate limiter using Redis.
  2. Default: 100 requests per minute per IP.
  3. Return 429 Too Many Requests with Retry-After header when exceeded.
  4. Make limits configurable via env vars.

Tests

  • Unit test: requests under limit pass through.
  • Unit test: requests over limit return 429.
  • Unit test: retry-after header is present.

Acceptance Criteria

  • All service routes have rate limiting.
  • Limits are configurable per service.
  • 429 response includes retry-after.

Verification

  • pnpm test passes.
  • pnpm build completes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions