async-ratelimiter
Version:
Rate limit made simple, easy, async.
35 lines (28 loc) • 637 B
TypeScript
declare module 'async-ratelimiter' {
import { Redis } from 'ioredis'
namespace RateLimiter {
interface ConstructorOptions {
db: Redis
max?: number
duration?: number
namespace?: string
id?: string
}
interface GetOptions {
id?: string
max?: number
duration?: number
peek?: boolean
}
interface Status {
total: number
remaining: number
reset: number
}
}
class RateLimiter {
constructor(options: RateLimiter.ConstructorOptions)
get(options?: RateLimiter.GetOptions): Promise<RateLimiter.Status>
}
export = RateLimiter
}