forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ratelimiter.d.ts
61 lines (47 loc) · 1.08 KB
/
ratelimiter.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Type definitions for ratelimiter 2.1.1
// Project: https://github.com/tj/node-ratelimiter
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../redis/redis.d.ts" />
declare module "ratelimiter" {
import { RedisClient } from 'redis';
interface LimiterOption {
/**
* The identifier to limit against (typically a user id)
*/
id: string;
/**
* Redis connection instance
*/
db: RedisClient;
/**
* Max requests within duration
*/
max?: number;
/**
* Duration of limit in milliseconds
*/
duration?: number;
}
interface LimiterInfo {
/**
* max value
*/
total: number;
/**
* Number of calls left in current duration without decreasing current get
*/
remaining: number;
/**
* Time in milliseconds until the end of current duration
*/
reset: number;
}
class Limiter {
constructor(opts: LimiterOption);
inspect(): string;
get(fn: (err: any, info: LimiterInfo) => void): void;
}
namespace Limiter {}
export = Limiter;
}