You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement API rate limiting using NestJS's ThrottlerModule to restrict the number of requests a client can make within a given time frame. This will improve security and overall stability of the API by preventing abuse and reducing the risk of DoS attacks.
Acceptance Criteria
The project is configured to use the NestJS ThrottlerModule.
Global or endpoint-level rate limits are enforced (e.g., 100 requests per minute per client).
Appropriate error responses (e.g., HTTP 429 Too Many Requests) are returned when limits are exceeded.
Unit and integration tests are added to verify the rate limiting behavior.
Documentation is updated to explain the rate limiting policy and configuration.
Purpose
Adding rate limiting will help protect the API from malicious or excessive use, ensuring fair usage for all clients and improving the overall reliability and scalability of the application.
Requirements
Install the NestJS Throttler package:
- npm install @nestjs/throttler
Configure the ThrottlerModule in the root module (e.g., in app.module.ts) with sensible defaults (e.g., 100 requests per minute).
Optionally, allow for custom limits on specific controllers or routes via decorators.
Update tests to simulate request bursts and verify that excess requests receive a 429 response.
Update API documentation to include rate limiting details.
Expected Outcome
Clients making excessive requests will receive an HTTP 429 status code with an appropriate message. For normal usage, the API will continue to operate without noticeable delay. Overall, this feature will contribute to improved API resilience and user fairness.
Additional Context
Rate limiting is a widely recognized best practice for APIs in production environments. Implementing this feature will help the HNG Boilerplate project scale more safely and securely, while also providing a better baseline for developers contributing to the project.
The text was updated successfully, but these errors were encountered:
NnatuanyaFrankOguguo
changed the title
[FEAT] Enforce Global API Rate Limiting for Enhanced Security and Performance
[FEAT] [in progress] Enforce Global API Rate Limiting for Enhanced Security and Performance
Feb 28, 2025
NnatuanyaFrankOguguo
changed the title
[FEAT] [in progress] Enforce Global API Rate Limiting for Enhanced Security and Performance
[FEAT] Enforce Global API Rate Limiting for Enhanced Security and Performance
Feb 28, 2025
Description
Implement API rate limiting using NestJS's ThrottlerModule to restrict the number of requests a client can make within a given time frame. This will improve security and overall stability of the API by preventing abuse and reducing the risk of DoS attacks.
Acceptance Criteria
Purpose
Adding rate limiting will help protect the API from malicious or excessive use, ensuring fair usage for all clients and improving the overall reliability and scalability of the application.
Requirements
- npm install @nestjs/throttler
Expected Outcome
Clients making excessive requests will receive an HTTP 429 status code with an appropriate message. For normal usage, the API will continue to operate without noticeable delay. Overall, this feature will contribute to improved API resilience and user fairness.
Additional Context
Rate limiting is a widely recognized best practice for APIs in production environments. Implementing this feature will help the HNG Boilerplate project scale more safely and securely, while also providing a better baseline for developers contributing to the project.
The text was updated successfully, but these errors were encountered: