-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
35 lines (29 loc) · 1.09 KB
/
index.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
declare module "@outofsync/express-rate-limiter";
import ObjectKeyCache from '@outofsync/object-key-cache';
import MemoryCache from '@outofsync/memory-cache';
import Redis from 'redis';
import {
ClientRequest,
ServerResponse,
} from 'http';
type ClosureFn = (...params: any) => void;
type RateLimiterLookupFn = (req: ClientRequest) => string[];
type RateLimiterWhiteListFn = (req: ClientRequest) => string[] | boolean;
type RateLimiterOnRateLimitedtFn = (req: ClientRequest, res: ServerResponse, next: ClosureFn) => any;
type Cache = typeof ObjectKeyCache | typeof MemoryCache | typeof Redis;
interface RateLimiterOptions {
lookup: RateLimiterLookupFn | string[];
count: number;
expire: number;
whitelist: RateLimiterWhiteListFn;
onRateLimited: RateLimiterOnRateLimitedtFn | null;
skipHeaders: boolean
noip: boolean;
}
declare class RateLimiter {
constructor(namespace: string, config?: RateLimiterOptions, cache?: Cache, log?: any);
checkWhitelist(req: ClientRequest);
limit(req: ClientRequest, res: ServerResponse, next: ClosureFn);
}
declare const obj: RateLimiter;
export default obj;