hapi-rate-limiter
hapi-rate-limiter copied to clipboard
Include option to whitelist API keys.
It'd be useful to have the option to whitelist certain API keys so that requests made with those keys don't get rate limited. For example, if I have some services that need to consume each other, I don't want to worry about limiting my own services.
I could pass a defaultRate function that returns an unreachable rate for requests made by my own services, but ideally I wouldn't want to go through Redis if I can identify an API key I don't want to limit.
Something like this would work I think:
options: {
whitelist: [ 'myAPIKey', 'anotherKey' ],
}
if (options.whitelist && options.whitelist.indexOf(options.requestAPIKey(request)) > -1) {
return reply.continue();
}
If this is something y'all would like to include in this plugin, I'd be happy to make a PR that adds this feature and the accompanying unit tests.