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

How do I rate-limit some but not all endpoints? #25

Open
vgoklani opened this issue May 25, 2016 · 3 comments
Open

How do I rate-limit some but not all endpoints? #25

vgoklani opened this issue May 25, 2016 · 3 comments

Comments

@vgoklani
Copy link

vgoklani commented May 25, 2016

Hi - Thank you for taking the time to create this!

How do I protect multiple endpoints in express?

const rateLimiter = RateLimiter(app, app.locals.redisClient0);
rateLimiter({
    path: '/api/fetch',
    method: 'post',
    lookup: 'headers.x-forwarded-for',
    total: 120,
    expire: 1000 * 60 * 60
});

It seems like the path is a string, not an array. Please let me know - thanks!

@vitorcamachoo
Copy link

@eljefedelrodeodeljefe
Copy link

Is doing this in the whitelist option with the request object an alternative? Asking because I absolutely want to avoid hitting the storage backend on maintenance and high frequency routes. Those are very small in number all others endpoints are not, which makes direct middleware unfeasible.

@eljefedelrodeodeljefe
Copy link

Just check the code: it is.

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

No branches or pull requests

3 participants