UNPKG

@canmertinyo/rate-limiter-redis

Version:

A simple rate-limiting middleware for Express.js with support for in-memory, Redis, and MongoDB storage

13 lines (12 loc) 616 B
import { RateLimiter, RateLimitRecord } from "@canmertinyo/rate-limiter-core"; import { RedisOptions } from "ioredis"; export declare class RedisStorage implements RateLimiter { private readonly options; private redis; constructor(options: RedisOptions); initialize(): Promise<RateLimiter>; getRateLimitRecord(key: string): Promise<RateLimitRecord | undefined>; createRateLimitRecord(record: RateLimitRecord): Promise<RateLimitRecord>; updateRateLimitRecord(key: string, timestamp: number, count: number): Promise<RateLimitRecord>; increment(key: string): Promise<RateLimitRecord>; }