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

support id option #6

Open
jedahan opened this issue Dec 15, 2014 · 15 comments
Open

support id option #6

jedahan opened this issue Dec 15, 2014 · 15 comments
Milestone

Comments

@jedahan
Copy link

jedahan commented Dec 15, 2014

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; }
@tunnckoCore
Copy link
Owner

Yea, i see that when PR appears in koa-ratelimit and i'm thinking of it.

@tunnckoCore
Copy link
Owner

It would be great if you can PR also with tests.

@tunnckoCore
Copy link
Owner

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.

@tunnckoCore
Copy link
Owner

@jedahan why you want to use koa-better-body?

@jedahan
Copy link
Author

jedahan commented Dec 17, 2014

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 :)

@tunnckoCore
Copy link
Owner

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

@tunnckoCore
Copy link
Owner

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.

@jedahan
Copy link
Author

jedahan commented Dec 18, 2014

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.

@tunnckoCore
Copy link
Owner

No worries. Try middlewares such as koa-ratelimit and koa-limit

@tunnckoCore
Copy link
Owner

@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!

@bishtawi
Copy link

bishtawi commented Jun 3, 2015

@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.

@tunnckoCore
Copy link
Owner

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

@apisurfer
Copy link

+1. Would love to see this feature.

@tunnckoCore
Copy link
Owner

@bishtawi @Popc0rn sorry guys but I have a bad cold. Try koa-ip-filter. :)

@tunnckoCore
Copy link
Owner

Finally, v3 will come maximum at the end of the week. After I finish helapkg/hela#34.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants