Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): add rate-limiting with Upstash for dev and prod environments #141

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

pkmanas22
Copy link
Contributor

Description

Implemented rate-limiting per IP using Upstash Redis. This ensures that API endpoints are protected against excessive requests. The rate limit feature is operational in both development and production environments.

Implementation Details

  • Used @upstash/ratelimit library to implement rate-limiting
  • Excluded the following routes from rate-limiting:
    /v1/status
    /v1/health
  • All other routes are processed through the rate-limiting handler.
  • The current configuration allows 100 requests in development and 60 requests in production per minute per IP.

Testing

  • Endpoint: http://localhost:3001/v1/session
  • Steps:
    • Set the rate limit to 5 requests in development per minute for testing purposes.
    • Make more than 5 requests to the endpoint within a minute.
    • Observe the response: A 429 status code with a message You hit the rate limit

Screenshots / Demo

image

Checklist

Please confirm that you have completed the following:

  • I have tested the feature thoroughly.
  • I have provided a clear and concise description of the feature implementation.
  • I have followed the code style and formatting guidelines.
  • I have added any necessary documentation or comments.
  • I have updated any relevant tests or test cases.

Check only those which are applicable.

Documentation Updated?

  • If your feature adds a new API, then documentation related to the feature like API-Contracts, and Data-models must be updated.

Breaking Changes

  • If your feature introduces breaking changes or if something is missing, please mention the related issue tickets.

Development Tested?

  • Confirm whether the changes have been tested locally during development.

Tested in Staging?

  • Indicate whether the changes have been tested in the staging environment.

Under Feature Flag

  • Specify if the changes are currently under a feature flag.

Database Changes

  • Indicate whether the changes include modifications to the database.

Issue ID

#102

@SkidGod4444 SkidGod4444 linked an issue Dec 30, 2024 that may be closed by this pull request
@SkidGod4444 SkidGod4444 merged commit 4bc7ddb into plura-ai:main Dec 30, 2024
3 of 9 checks passed
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.

Rate-limiting the API
2 participants