diff --git a/types/express-rate-limit/express-rate-limit-tests.ts b/types/express-rate-limit/express-rate-limit-tests.ts index 4b94ef6b05..064289423e 100644 --- a/types/express-rate-limit/express-rate-limit-tests.ts +++ b/types/express-rate-limit/express-rate-limit-tests.ts @@ -7,6 +7,7 @@ const apiLimiter = new RateLimit({ skipFailedRequests: false, skipSuccessfulRequests: true, }); +apiLimiter.resetKey('testKey'); const apiLimiterWithMaxFn = new RateLimit({ windowMs: 15 * 60 * 1000, diff --git a/types/express-rate-limit/index.d.ts b/types/express-rate-limit/index.d.ts index 9d3459e21b..740ebbeaa4 100644 --- a/types/express-rate-limit/index.d.ts +++ b/types/express-rate-limit/index.d.ts @@ -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; diff --git a/types/express-rate-limit/v2/express-rate-limit-tests.ts b/types/express-rate-limit/v2/express-rate-limit-tests.ts index aa5c51a016..2314c25cfb 100644 --- a/types/express-rate-limit/v2/express-rate-limit-tests.ts +++ b/types/express-rate-limit/v2/express-rate-limit-tests.ts @@ -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 diff --git a/types/express-rate-limit/v2/index.d.ts b/types/express-rate-limit/v2/index.d.ts index b3f074f28d..9918efe3b0 100644 --- a/types/express-rate-limit/v2/index.d.ts +++ b/types/express-rate-limit/v2/index.d.ts @@ -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;