Skip to content

[backend] Add Rate Limiting with @nestjs/throttler #6

Description

@josueazc

DESCRIPTION

The NestJS API has no rate limiting. Any actor can send unlimited requests to any endpoint, enabling abuse, DoS, and brute-force attacks against POST /auth/login. This task adds ThrottlerModule with sensible global and per-route defaults.

GOAL

API endpoints are protected by rate limiting. Abusive callers receive 429 Too Many Requests with a Retry-After header once they exceed the configured threshold.

REQUIREMENTS

  • Install @nestjs/throttler in apps/api
  • Configure ThrottlerModule globally in AppModule: default 100 req / 60 s per IP
  • Stricter limits on sensitive endpoints: POST /auth/login (10 req/min), POST /bonds (20 req/min)
  • Return standard 429 with a Retry-After header
  • Add THROTTLE_TTL and THROTTLE_LIMIT to .env.example for configurability

ACCEPTANCE CRITERIA

  • Sending 101 requests in 60s to a default endpoint returns 429 on the 101st
  • POST /auth/login is blocked after 10 requests in 60s
  • 429 response includes Retry-After header
  • THROTTLE_* vars documented in .env.example
  • Work follows Velar monorepo structure
  • No legitimate request flow is broken
  • Can be reviewed by the team

NOTES

Relevant files: apps/api/src/app.module.ts, apps/api/src/auth/auth.controller.ts, apps/api/src/bonds/bonds.controller.ts, apps/api/.env.example. Good first task — no blockchain knowledge required. Reference: https://docs.nestjs.com/security/rate-limiting


Difficulty: Beginner
Priority: Medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions