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

[FEATURE] Add Rate Limiting to APIs for Database-Backed Endpoints #417

Open
rohitdasu opened this issue Aug 12, 2023 · 15 comments
Open

[FEATURE] Add Rate Limiting to APIs for Database-Backed Endpoints #417

rohitdasu opened this issue Aug 12, 2023 · 15 comments
Assignees
Labels
api api related tasks backend backend related task enhancement New feature or request feature new feature good first issue Good for newcomers

Comments

@rohitdasu
Copy link
Owner

Description

This issue aims to enhance the performance and security of our APIs by implementing rate limiting for endpoints that involve database operations. Rate limiting is crucial to prevent abuse, ensure fair usage, and protect our infrastructure from potential threats.

Let us discuss first which service is best for implementing rate limiting!

@rohitdasu rohitdasu added enhancement New feature or request good first issue Good for newcomers backend backend related task api api related tasks feature new feature labels Aug 12, 2023
@rohitdasu
Copy link
Owner Author

Upstash is one of the good option here.

https://upstash.com/blog/nextjs-ratelimiting

@manzil-infinity180
Copy link

Upstash is one of the good option here.

https://upstash.com/blog/nextjs-ratelimiting

is this issue or security feature resolve with npm package express-rate-limit???

const limiter = rateLimit({
max:100,
windowMs: 60601000,
message : 'Too many reqests from this IP,please try again in an hour'
});

@kairblarson
Copy link

@manzil-infinity180 express-rate-limit limits all traffic but it seems like the Upstash limiter only limits endpoints that interact with redis

@rohitdasu
Copy link
Owner Author

@kairblarson it make sense

@kairblarson
Copy link

Ive been looking into it more and it seems like the upstash rate limiter leverages a redis cache so its not feasable unless we add redis. I then tried to use the express-rate-limit package but I dont think it works with nextjs however I did find a more traditional work around in this article here: https://kittygiraudel.com/2022/05/16/rate-limit-nextjs-api-routes/

I tried to implement it myself but could not figure out the exact typing

@madjed-hue
Copy link

hello @kairblarson,
You can check the lru-cache package,
Here is an example:
https://nextjs-rate-limit.vercel.app/

@kairblarson
Copy link

@madjed-hue this looks promising, ill look into it thank you!

@MrBlackGhostt
Copy link
Contributor

Hi @rohitdasu if the issue is not solve i want to contribute it

@rohitdasu
Copy link
Owner Author

Hi @rohitdasu if the issue is not solve i want to contribute it

Sure

@MrBlackGhostt
Copy link
Contributor

@rohitdasu i don't see is this assign it to me

@MrBlackGhostt
Copy link
Contributor

@rohitdasu can you assign this to me so I can work

@rohitdasu
Copy link
Owner Author

Assigned you @MrBlackGhostt

@parasvekariya26
Copy link

Plz Assign issue me?

@rohitdasu
Copy link
Owner Author

Plz Assign issue me?

assigned you. let us know if you need anything :)

@rohitdasu
Copy link
Owner Author

@parasvekariya26 are you still working on this? please let us know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api api related tasks backend backend related task enhancement New feature or request feature new feature good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants