koa-better-ratelimit
koa-better-ratelimit copied to clipboard
support id option
I want to be able to set up my own custom id functions, like in koa-ratelimit:
id: function (context) {
return context.ip;
}
In particular, I am trying to limit the rate of my entire application, not just per-user, so my custom id function might look like:
id: function () { return -1; }
Yea, i see that when PR appears in koa-ratelimit and i'm thinking of it.
It would be great if you can PR also with tests.
Its not so easy because of using ipchecker
's checks here
Hm.. okey, I'll look what can I create, as soon as possible. PRs welcome.
@jedahan why you want to use koa-better-body
?
I'm confused what does koa-better-body
has to do with my request. Unfortunately I don't have the time to submit a pull request, though I would like to. This is a request from a friend of mine, just trying to help him out :)
Right.
I'm confused what does koa-better-body has to do with my request
It's simple, just limiting the requests per ip. And if he dont need to define custom error msgs, blacklisting ips, dont need db saving and etc, he should use some other simpler middleware
Im thinking of to decouple it to separate modules at some point or concept for adding middleware to this middleware - i think it would be good. At this point we have tj's node-ratelimiter, but i believe it can be simpler.
Ahh yes. That makes sense. Any middleware that can take a function, and yield a 429 ratelimit would do. Much simpler. Thanks for being patient explaining this to me.
No worries. Try middlewares such as koa-ratelimit
and koa-limit
@jedahan I'll do this tonight and will release v3.0.0, because significant refactoring of the codebase and following ferver
version scheme.
I'll start in clear v3 branch, stay tuned. Thank you guys!
@tunnckoCore Do you have an ETA on when you plan on making v3 live? I need this feature as my server is sitting behind a load balancer and the IP address I need to rate limit is stored in X-Forwarded-For header.
Do you have an ETA on when you plan on making v3 live
maximum the end of the week.
you may want to review https://github.com/tunnckoCore/koa-ip-filter
+1. Would love to see this feature.
@bishtawi @popc0rn sorry guys but I have a bad cold. Try koa-ip-filter
. :)
Finally, v3 will come maximum at the end of the week. After I finish https://github.com/tunnckoCore/koa-better-body/pull/34.