Skip to content

qoq-ts/qoq-ratelimit

Repository files navigation

qoq-ratelimit

Rate limiter middleware for qoq based on koa-ratelimit.

License npm

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

Releases

No releases published

Packages

No packages published