mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
express-rate-limit: Added support for resetKey on the RateLimit object (#36951)
* express-rate-limit: Adding resetKey on Instance * express-rate-limit Fixing string quotations
This commit is contained in:
parent
81538f04eb
commit
0278c068f3
@ -7,6 +7,7 @@ const apiLimiter = new RateLimit({
|
||||
skipFailedRequests: false,
|
||||
skipSuccessfulRequests: true,
|
||||
});
|
||||
apiLimiter.resetKey('testKey');
|
||||
|
||||
const apiLimiterWithMaxFn = new RateLimit({
|
||||
windowMs: 15 * 60 * 1000,
|
||||
|
||||
5
types/express-rate-limit/index.d.ts
vendored
5
types/express-rate-limit/index.d.ts
vendored
@ -99,7 +99,10 @@ declare namespace RateLimit {
|
||||
*/
|
||||
windowMs?: number;
|
||||
}
|
||||
interface Instance extends express.RequestHandler {
|
||||
resetKey(key: string): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var RateLimit: new (options: RateLimit.Options) => express.RequestHandler;
|
||||
declare var RateLimit: new (options: RateLimit.Options) => RateLimit.Instance;
|
||||
export = RateLimit;
|
||||
|
||||
@ -5,6 +5,7 @@ const apiLimiter = new RateLimit({
|
||||
max: 100,
|
||||
delayMs: 0 // disabled
|
||||
});
|
||||
apiLimiter.resetKey('testKey');
|
||||
|
||||
const apiLimiterWithMessageObject = new RateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
|
||||
6
types/express-rate-limit/v2/index.d.ts
vendored
6
types/express-rate-limit/v2/index.d.ts
vendored
@ -36,7 +36,11 @@ declare namespace RateLimit {
|
||||
onLimitReached?(req: express.Request, res: express.Response, optionsUsed: Options): void;
|
||||
windowMs?: number;
|
||||
}
|
||||
|
||||
interface Instance extends express.RequestHandler {
|
||||
resetKey(key: string): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var RateLimit: new (options: RateLimit.Options) => express.RequestHandler;
|
||||
declare var RateLimit: new (options: RateLimit.Options) => RateLimit.Instance;
|
||||
export = RateLimit;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user