koajs / ratelimit

Rate limiter middleware
MIT License
485 stars 57 forks source link

feat: add whitelist and blacklist opts #44

Closed tuananh closed 5 years ago

tuananh commented 5 years ago

add whitelistand blacklist option.

Fixes: #1 and #2

app = new Koa();

app.use(ratelimit({
    db,
    whitelist: (ctx) => ctx.request.header.foo === 'whitelistme',
    max: 1
}));

or

app.use(ratelimit({
    db,
    blacklist: (ctx) => ctx.request.header.foo === 'blacklisted',
    max: 1
}));
tuananh commented 5 years ago

@dead-horse @coderhaoxin can you take a look at this?

haoxins commented 5 years ago

will review this at this weekend :).

haoxins commented 5 years ago

4.2.0