express-rate-limit middleware.
Login Rate Limiter
Protects the authentication endpoint from brute force attacks. Endpoint:POST /api/auth/login
Configuration
Time window in milliseconds for rate limiting.Value:
15 * 60 * 1000 (15 minutes)Maximum number of requests allowed per IP within the time window.Value:
5 requestsError message returned when rate limit is exceeded.Value:
{ error: 'Muitas tentativas de login. Tente novamente em 15 minutos.' }Behavior
- Users can attempt login 5 times within a 15-minute window
- After exceeding the limit, requests are blocked for the remainder of the window
- Each IP address is tracked independently
- Standard rate limit headers are included in responses
Contact Form Rate Limiter
Prevents spam and abuse of the contact form endpoint. Endpoint:POST /api/contact
Configuration
Time window in milliseconds for rate limiting.Value:
60 * 60 * 1000 (1 hour)Maximum number of requests allowed per IP within the time window.Value:
5 requestsError message returned when rate limit is exceeded.Value:
{ error: 'Muitas mensagens enviadas. Tente novamente mais tarde.' }Behavior
- Users can submit 5 contact forms within a 1-hour window
- After exceeding the limit, requests are blocked for the remainder of the window
- Each IP address is tracked independently
- Standard rate limit headers are included in responses
Rate Limit Headers
Both rate limiters include standard headers in API responses:RateLimit-Limit- Maximum requests allowed in the windowRateLimit-Remaining- Number of requests remainingRateLimit-Reset- Time when the rate limit window resets (Unix timestamp)
Example Response Headers
Implementation Details
Rate limiting is implemented inbackend/src/server.js:
backend/src/server.js:27-41 for the complete implementation.
