Judicial Backend uses express-rate-limit to cap the number of requests a single IP address can make within a rolling time window. Two distinct limiters are defined — a stricter one for authentication routes where brute-force attacks are most dangerous, and a general one for all other API routes. Both limiters are configured entirely through environment variables so thresholds can be adjusted per environment without code changes.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/BladimirGS/judicial-backend/llms.txt
Use this file to discover all available pages before exploring further.
Limiter Definitions
Both limiters are created insrc/core/middlewares/rate-limit.middleware.ts and share the same windowMs value while differing in their max ceiling:
apiLimiter
Applied to all protected resource routes. Allows up to 100 requests per 15-minute window per IP by default. Suitable for normal browsing, search queries, and report generation.
authLimiter
Applied exclusively to authentication routes. Allows up to 20 requests per 15-minute window per IP by default. The lower threshold limits the blast radius of credential stuffing or brute-force login attempts.
Both limiters set standardHeaders: true (the RateLimit-* headers defined by the IETF draft standard) and legacyHeaders: false (suppresses the older X-RateLimit-* headers).
Route Registration
Limiters are attached per route group insrc/routes/index.ts. They are inserted as middleware before the route handler and, where applicable, before the protect authentication check:
429 without consuming authentication infrastructure.
Response When Limit Is Exceeded
When a client exceeds the configured threshold,express-rate-limit short-circuits the request and responds with HTTP 429 Too Many Requests:
| Header | Description |
|---|---|
RateLimit-Limit | The maximum number of requests allowed per window. |
RateLimit-Remaining | Requests remaining in the current window. |
RateLimit-Reset | Timestamp (seconds) when the window resets. |
Configuration via Environment Variables
All thresholds are read from environment variables at startup. Set them in your.env file:
The duration of the rolling rate-limit window in milliseconds. The default
900000 equals 15 minutes. Both apiLimiter and authLimiter use this same value.Maximum number of requests allowed within one window for API routes (
/apelaciones, /busquedas, /estadisticas). Requests beyond this threshold receive 429.Maximum number of requests allowed within one window for authentication routes (
/auth). This value should be kept low enough to deter brute-force attacks while still permitting normal login workflows.Changing Limits Per Environment
A common pattern is to use a higher limit in development to avoid interrupting local testing, and tighten it in production:minutes is computed from RATE_LIMIT_WINDOW_MS at startup, the user-facing error message automatically reflects the correct window duration without any additional code changes.