Comments (7)
No that's not the behavior of rate limit at all. Rate limiting should be counted by time window, what you're asking right now is to give user a time out after certain request which is no longer a rate limiting anymore.
Thinking this scenario, with rate limit of 10 request with duration of 100 seconds
- (0 sec) Make 2 requests
- (400 sec) Make 7 request
- (800 sec) Make 1 request
- (801 sec) Make 1 request, get rate limited and waiting for 100 seconds
- (901 sec) Make 1 request
This is 900 seconds time window, not 100 seconds
from elysia-rate-limit.
Apparently, duration should be passed to the increment function
elysia-rate-limit/src/services/plugin.ts
Line 45 in 098e4c7
from elysia-rate-limit.
Great, thank you.
from elysia-rate-limit.
@rayriffy , I think that Ratelimit-Reset should start counting after the requests run out.
Right now it triggers after the first request, which doesn't seem logical.
What do you think about this?
rateLimit({
max: 10,
duration: 100 * 1000
})
Ratelimit-Limit:
10
Ratelimit-Remaining:
7
Ratelimit-Reset:
75
from elysia-rate-limit.
No that's not the behavior of rate limit at all. Rate limiting should be counted by time window, what you're asking right now is to give user a time out after certain request which is no longer a rate limiting anymore.
Thinking this scenario, with rate limit of 10 request with duration of 100 seconds
- (0 sec) Make 2 requests
- (400 sec) Make 7 request
- (800 sec) Make 1 request
- (801 sec) Make 1 request, get rate limited and waiting for 100 seconds
- (901 sec) Make 1 request
This is 900 seconds time window, not 100 seconds
Thanks for the explanation, indeed, I hadn't thought of that)
In order not to create a new issue, let me ask here.
I see that the ...rest
is passed to the generator.
elysia-rate-limit/src/services/plugin.ts
Line 41 in fb23a8d
Earlier you added derived support to the generator and showed an example using elysia-ip.
I would like to be able to access
cookie
, path
etc from Elysia in the generator. Is there any way we can throw these into the generator?from elysia-rate-limit.
cookies are just http header, you can intercept and parse them via request
from elysia-rate-limit.
cookies are just http header, you can intercept and parse them via
request
.
Yes, I just didn't want to write my own parser function) Ok
from elysia-rate-limit.
Related Issues (16)
- Support for Elysia 0.8 HOT 1
- Unable to determine client IP HOT 2
- Use LRU cache for default context HOT 5
- how use `skip`? HOT 1
- Default generator is unable to determine client IP address HOT 1
- Response is never given to the user HOT 3
- Unable to determine client IP address HOT 8
- Rate limit for individual endpoint HOT 18
- [BUG] On limit exceeded, response is not given HOT 10
- Elysia is not initialized yet. Please call .listen() first. HOT 4
- Throw the bearer utility into the generator HOT 6
- rateLimit for each path has a common counter HOT 3
- Duplicate run when use multiple time HOT 2
- Ability to hide Ratelimit-* headers HOT 1
- Custom cache context HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elysia-rate-limit.