feat(rate limiter): applied rate limiter for APIs #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces API rate limiting to the application, ensuring controlled access to API endpoints while allowing flexibility for different environments. The key changes include adding a rate-limiting configuration, integrating middleware, and updating route definitions to enforce rate limits.
API Rate Limiting Implementation:
.env.docker.example: Added a new environment variableDEFAULT_API_RATE_LIMITwith a default value of 60 to configure the API rate limit.config/rate-limiting.php: Created a new configuration file to define the default API rate limit using theDEFAULT_API_RATE_LIMITenvironment variable.Service Provider Updates:
app/Providers/AppServiceProvider.php:Limit,Request,RateLimiter).bootmethod, disabling it during testing and setting a per-minute limit for production based on user ID or IP address. [1] [2]Middleware and Route Updates:
bootstrap/app.php: Registered theThrottleRequestsmiddleware with the aliasthrottle.routes/api_v1.php: Applied thethrottle:apimiddleware to the API v1 routes to enforce the rate-limiting rules.