Skip to content

Conversation

@mubbi
Copy link
Owner

@mubbi mubbi commented Jul 23, 2025

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 variable DEFAULT_API_RATE_LIMIT with 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 the DEFAULT_API_RATE_LIMIT environment variable.

Service Provider Updates:

  • app/Providers/AppServiceProvider.php:
    • Imported necessary classes (Limit, Request, RateLimiter).
    • Configured rate limiting in the boot method, 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 the ThrottleRequests middleware with the alias throttle.
  • routes/api_v1.php: Applied the throttle:api middleware to the API v1 routes to enforce the rate-limiting rules.

added laravel default rate limiter on all apis
@mubbi mubbi requested a review from Copilot July 23, 2025 11:02
@mubbi mubbi self-assigned this Jul 23, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements API rate limiting functionality across the application to control access to API endpoints. The implementation provides configurable rate limits with environment-specific behavior, including disabled rate limiting during testing.

  • Added rate limiting configuration with environment variable support
  • Integrated ThrottleRequests middleware with API route groups
  • Configured rate limiter to use user ID or IP address for limit tracking

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.env.docker.example Added DEFAULT_API_RATE_LIMIT environment variable with default value of 60
config/rate-limiting.php Created configuration file for API rate limiting settings
bootstrap/app.php Registered ThrottleRequests middleware with 'throttle' alias
routes/api_v1.php Applied throttle:api middleware to v1 API route group
app/Providers/AppServiceProvider.php Configured RateLimiter with per-minute limits and testing environment handling

@mubbi mubbi merged commit bb9226c into develop Jul 23, 2025
4 checks passed
@mubbi mubbi deleted the feature/rate-limit-apis branch July 23, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants