Comments (3)
This is not a bug. By default rateLimit context will be applied globally and disregarding any hierarchy, use scoping
option to make plugin affect per routes.
from elysia-rate-limit.
This is not a bug. By default rateLimit context will be applied globally and disregarding any hierarchy, use
scoping
option to make plugin affect per routes.
scope has nothing to do with it. You need to add url.pathname to the key in the generator
Maybe it's better to make it by default, so you don't have to specify it every time.
Otherwise now, if you exhaust the limit on one router you will be blocked everywhere!
That's how it should be.
generator: (req) => {
const path = new URL(req.url).pathname
const ip = req.headers.get('x-real-ip')
const res = ip !== null ? ip : 'anonymous'
return res + path
},
You were clearly in a hurry to close the issue.
from elysia-rate-limit.
scoping is meant to separate rate limit per instances to grouping by each categories, by design rate limit should be counted globally this is also a default behavior for fastify, and express as well. If you want per api route you should create your own generator
that's what it's designed for. this project should not cover every tiny cases otherwise it will be extremely bloated
and do not make an accusation like that to anyone EVER
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
- duration overwritten HOT 7
- 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.