qoq-ratelimit
v0.0.3
Published
Rate limiter middleware for qoq based on [koa-ratelimit](https://github.com/koajs/ratelimit).
Downloads
12
Readme
qoq-ratelimit
Rate limiter middleware for qoq based on koa-ratelimit.
Installation
yarn add qoq-ratelimit
Usage
With a memory driver
import { WebSlotManager, createConfig } from 'qoq';
import { RateLimit, RateLimitOptions } from 'qoq-ratelimit';
const options = createConfig<RateLimitOptions>({
driver: 'memory',
});
export const webSlots = WebSlotManager.use(new RateLimit(options));
With a redis driver
import { WebSlotManager, createConfig } from 'qoq';
import { RateLimit, RateLimitOptions } from 'qoq-ratelimit';
import Redis from 'ioredis';
const options = createConfig<RateLimitOptions>({
driver: 'redis',
db: new Redis(),
});
export const webSlots = WebSlotManager.use(new RateLimit(options));
Options
@see koa-ratelimit