avancement planning
This commit is contained in:
+614
-421
File diff suppressed because it is too large
Load Diff
+105
-21
@@ -1,7 +1,28 @@
|
||||
// Generated by dts-bundle-generator v8.0.1
|
||||
// Generated by dts-bundle-generator v8.1.2
|
||||
|
||||
import { NextFunction, Request, RequestHandler, Response } from 'express';
|
||||
|
||||
/**
|
||||
* Returns the IP address itself for IPv4, or a CIDR-notation subnet for IPv6.
|
||||
*
|
||||
* If you write a custom keyGenerator that allows a fallback to IP address for
|
||||
* unauthenticated users, return ipKeyGenerator(req.ip) rather than just req.ip.
|
||||
*
|
||||
* For more information, {@see Options.ipv6Subnet}.
|
||||
*
|
||||
* @param ip {string} - The IP address to process, usually request.ip.
|
||||
* @param ipv6Subnet {number | false} - The subnet mask for IPv6 addresses.
|
||||
*
|
||||
* @returns {string} - The key generated from the IP address
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare function ipKeyGenerator(ip: string, ipv6Subnet?: number | false): string;
|
||||
declare const SUPPORTED_DRAFT_VERSIONS: readonly [
|
||||
"draft-6",
|
||||
"draft-7",
|
||||
"draft-8"
|
||||
];
|
||||
declare const validations: {
|
||||
enabled: {
|
||||
[key: string]: boolean;
|
||||
@@ -39,6 +60,14 @@ declare const validations: {
|
||||
* @returns {void}
|
||||
*/
|
||||
xForwardedForHeader(request: Request): void;
|
||||
/**
|
||||
* Alert the user if the Forwarded header is set (standardized version of X-Forwarded-For - not supported by express as of version 5.1.0)
|
||||
*
|
||||
* @param request {Request} - The Express request object.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
forwardedHeader(request: Request): void;
|
||||
/**
|
||||
* Ensures totalHits value from store is a positive integer.
|
||||
*
|
||||
@@ -103,12 +132,13 @@ declare const validations: {
|
||||
* @returns {void}
|
||||
*/
|
||||
headersResetTime(resetTime?: Date): void;
|
||||
knownOptions(passedOptions?: Partial<Options>): void;
|
||||
/**
|
||||
* Checks the options.validate setting to ensure that only recognized
|
||||
* validations are enabled or disabled.
|
||||
*
|
||||
* If any unrecognized values are found, an error is logged that
|
||||
* includes the list of supported vaidations.
|
||||
* includes the list of supported validations.
|
||||
*/
|
||||
validationsConfig(): void;
|
||||
/**
|
||||
@@ -117,13 +147,38 @@ declare const validations: {
|
||||
* store (or any other store with localKeys.)
|
||||
*/
|
||||
creationStack(store: Store): void;
|
||||
ipv6Subnet(ipv6Subnet?: any): void;
|
||||
ipv6SubnetOrKeyGenerator(options: Partial<Options>): void;
|
||||
keyGeneratorIpFallback(keyGenerator?: ValueDeterminingMiddleware<string>): void;
|
||||
/**
|
||||
* Checks to see if the window duration is greater than 2^32 - 1. This is only
|
||||
* called by the default MemoryStore, since it uses Node's setInterval method.
|
||||
*
|
||||
* See https://nodejs.org/api/timers.html#setintervalcallback-delay-args.
|
||||
*/
|
||||
windowMs(windowMs: number): void;
|
||||
};
|
||||
export type Validations = typeof validations;
|
||||
declare const SUPPORTED_DRAFT_VERSIONS: readonly [
|
||||
"draft-6",
|
||||
"draft-7",
|
||||
"draft-8"
|
||||
];
|
||||
/**
|
||||
* Basic logging function
|
||||
*
|
||||
* @param error {unknown} - The error to log
|
||||
* @param message {string | undefined} - Additional details about the error
|
||||
*/
|
||||
export type LoggerFn = (error: unknown, message?: string) => void;
|
||||
/**
|
||||
* Minimal interface for logging warnings and errors
|
||||
*/
|
||||
export type Logger = {
|
||||
/**
|
||||
* Function to log an error
|
||||
*/
|
||||
error: LoggerFn;
|
||||
/**
|
||||
* Function to log a warning
|
||||
*/
|
||||
warn: LoggerFn;
|
||||
};
|
||||
/**
|
||||
* Callback that fires when a client's hit counter is incremented.
|
||||
*
|
||||
@@ -230,9 +285,15 @@ export type Store = {
|
||||
* Method that initializes the store, and has access to the options passed to
|
||||
* the middleware too.
|
||||
*
|
||||
* Called once during initialization.
|
||||
*
|
||||
* Errors / promise rejections will be caught and logged.
|
||||
*
|
||||
* Note that the result is not awaited - other store methods (such as increment) may be called before init returns and/or after it throws/rejects.
|
||||
*
|
||||
* @param options {Options} - The options used to setup the middleware.
|
||||
*/
|
||||
init?: (options: Options) => void;
|
||||
init?: (options: Options) => void | Promise<void>;
|
||||
/**
|
||||
* Method to fetch a client's hit count and reset time.
|
||||
*
|
||||
@@ -280,7 +341,8 @@ export type Store = {
|
||||
/**
|
||||
* Optional value that the store prepends to keys
|
||||
*
|
||||
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
||||
* Used by the double-count check to avoid false-positives when a key is counted
|
||||
* twice, but with different prefixes.
|
||||
*/
|
||||
prefix?: string;
|
||||
};
|
||||
@@ -372,6 +434,21 @@ export type Options = {
|
||||
* By default, the client's IP address is used.
|
||||
*/
|
||||
keyGenerator: ValueDeterminingMiddleware<string>;
|
||||
/**
|
||||
* IPv6 subnet mask applied to IPv6 addresses in the default keyGenerator.
|
||||
*
|
||||
* Default is 56. The valid range is technically 1-128 but the value should
|
||||
* generally be in the 32-64 range.
|
||||
*
|
||||
* Smaller numbers are more aggressive, larger numbers are more lenient. Try
|
||||
* bumping to 60 or 64 if you see evidence of users being blocked incorrectly.
|
||||
*
|
||||
* May also be set to a function that returns a number based on the request.
|
||||
*
|
||||
* See the documentation for more info:
|
||||
* https://express-rate-limit.mintlify.app/reference/configuration#ipv6subnet.
|
||||
*/
|
||||
ipv6Subnet: 64 | 60 | 56 | 52 | 50 | 48 | 32 | number | ValueDeterminingMiddleware<number> | false;
|
||||
/**
|
||||
* Express request handler that sends back a response when a client is
|
||||
* rate-limited.
|
||||
@@ -387,7 +464,7 @@ export type Options = {
|
||||
*/
|
||||
skip: ValueDeterminingMiddleware<boolean>;
|
||||
/**
|
||||
* Method to determine whether or not the request counts as 'succesful'. Used
|
||||
* Method to determine whether or not the request counts as 'successful'. Used
|
||||
* when either `skipSuccessfulRequests` or `skipFailedRequests` is set to true.
|
||||
*
|
||||
* By default, requests with a response status code less than 400 are considered
|
||||
@@ -426,6 +503,10 @@ export type Options = {
|
||||
* If the Store generates an error, allow the request to pass.
|
||||
*/
|
||||
passOnStoreError: boolean;
|
||||
/**
|
||||
* The logger to use to log errors. If absent, logs to the console.
|
||||
*/
|
||||
logger: Logger;
|
||||
};
|
||||
/**
|
||||
* The extended request object that includes information about the client's
|
||||
@@ -443,18 +524,8 @@ export type RateLimitInfo = {
|
||||
used: number;
|
||||
remaining: number;
|
||||
resetTime: Date | undefined;
|
||||
key: string;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Create an instance of IP rate-limiting middleware for Express.
|
||||
*
|
||||
* @param passedOptions {Options} - Options to configure the rate limiter.
|
||||
*
|
||||
* @returns {RateLimitRequestHandler} - The middleware that rate-limits clients based on your configuration.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const rateLimit: (passedOptions?: Partial<Options>) => RateLimitRequestHandler;
|
||||
/**
|
||||
* The record that stores information about a client - namely, how many times
|
||||
* they have hit the endpoint, and when their hit count resets.
|
||||
@@ -471,6 +542,7 @@ export type Client = {
|
||||
* @public
|
||||
*/
|
||||
export declare class MemoryStore implements Store {
|
||||
private validations?;
|
||||
/**
|
||||
* The duration of time before which all hit counts are reset (in milliseconds).
|
||||
*/
|
||||
@@ -496,6 +568,7 @@ export declare class MemoryStore implements Store {
|
||||
* cannot affect other instances.
|
||||
*/
|
||||
localKeys: boolean;
|
||||
constructor(validations?: Validations | undefined);
|
||||
/**
|
||||
* Method that initializes the store.
|
||||
*
|
||||
@@ -580,6 +653,17 @@ export declare class MemoryStore implements Store {
|
||||
*/
|
||||
private clearExpired;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Create an instance of IP rate-limiting middleware for Express.
|
||||
*
|
||||
* @param passedOptions {Options} - Options to configure the rate limiter.
|
||||
*
|
||||
* @returns {RateLimitRequestHandler} - The middleware that rate-limits clients based on your configuration.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const rateLimit: (passedOptions?: Partial<Options>) => RateLimitRequestHandler;
|
||||
|
||||
export {
|
||||
rateLimit as default,
|
||||
|
||||
+105
-21
@@ -1,7 +1,28 @@
|
||||
// Generated by dts-bundle-generator v8.0.1
|
||||
// Generated by dts-bundle-generator v8.1.2
|
||||
|
||||
import { NextFunction, Request, RequestHandler, Response } from 'express';
|
||||
|
||||
/**
|
||||
* Returns the IP address itself for IPv4, or a CIDR-notation subnet for IPv6.
|
||||
*
|
||||
* If you write a custom keyGenerator that allows a fallback to IP address for
|
||||
* unauthenticated users, return ipKeyGenerator(req.ip) rather than just req.ip.
|
||||
*
|
||||
* For more information, {@see Options.ipv6Subnet}.
|
||||
*
|
||||
* @param ip {string} - The IP address to process, usually request.ip.
|
||||
* @param ipv6Subnet {number | false} - The subnet mask for IPv6 addresses.
|
||||
*
|
||||
* @returns {string} - The key generated from the IP address
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare function ipKeyGenerator(ip: string, ipv6Subnet?: number | false): string;
|
||||
declare const SUPPORTED_DRAFT_VERSIONS: readonly [
|
||||
"draft-6",
|
||||
"draft-7",
|
||||
"draft-8"
|
||||
];
|
||||
declare const validations: {
|
||||
enabled: {
|
||||
[key: string]: boolean;
|
||||
@@ -39,6 +60,14 @@ declare const validations: {
|
||||
* @returns {void}
|
||||
*/
|
||||
xForwardedForHeader(request: Request): void;
|
||||
/**
|
||||
* Alert the user if the Forwarded header is set (standardized version of X-Forwarded-For - not supported by express as of version 5.1.0)
|
||||
*
|
||||
* @param request {Request} - The Express request object.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
forwardedHeader(request: Request): void;
|
||||
/**
|
||||
* Ensures totalHits value from store is a positive integer.
|
||||
*
|
||||
@@ -103,12 +132,13 @@ declare const validations: {
|
||||
* @returns {void}
|
||||
*/
|
||||
headersResetTime(resetTime?: Date): void;
|
||||
knownOptions(passedOptions?: Partial<Options>): void;
|
||||
/**
|
||||
* Checks the options.validate setting to ensure that only recognized
|
||||
* validations are enabled or disabled.
|
||||
*
|
||||
* If any unrecognized values are found, an error is logged that
|
||||
* includes the list of supported vaidations.
|
||||
* includes the list of supported validations.
|
||||
*/
|
||||
validationsConfig(): void;
|
||||
/**
|
||||
@@ -117,13 +147,38 @@ declare const validations: {
|
||||
* store (or any other store with localKeys.)
|
||||
*/
|
||||
creationStack(store: Store): void;
|
||||
ipv6Subnet(ipv6Subnet?: any): void;
|
||||
ipv6SubnetOrKeyGenerator(options: Partial<Options>): void;
|
||||
keyGeneratorIpFallback(keyGenerator?: ValueDeterminingMiddleware<string>): void;
|
||||
/**
|
||||
* Checks to see if the window duration is greater than 2^32 - 1. This is only
|
||||
* called by the default MemoryStore, since it uses Node's setInterval method.
|
||||
*
|
||||
* See https://nodejs.org/api/timers.html#setintervalcallback-delay-args.
|
||||
*/
|
||||
windowMs(windowMs: number): void;
|
||||
};
|
||||
export type Validations = typeof validations;
|
||||
declare const SUPPORTED_DRAFT_VERSIONS: readonly [
|
||||
"draft-6",
|
||||
"draft-7",
|
||||
"draft-8"
|
||||
];
|
||||
/**
|
||||
* Basic logging function
|
||||
*
|
||||
* @param error {unknown} - The error to log
|
||||
* @param message {string | undefined} - Additional details about the error
|
||||
*/
|
||||
export type LoggerFn = (error: unknown, message?: string) => void;
|
||||
/**
|
||||
* Minimal interface for logging warnings and errors
|
||||
*/
|
||||
export type Logger = {
|
||||
/**
|
||||
* Function to log an error
|
||||
*/
|
||||
error: LoggerFn;
|
||||
/**
|
||||
* Function to log a warning
|
||||
*/
|
||||
warn: LoggerFn;
|
||||
};
|
||||
/**
|
||||
* Callback that fires when a client's hit counter is incremented.
|
||||
*
|
||||
@@ -230,9 +285,15 @@ export type Store = {
|
||||
* Method that initializes the store, and has access to the options passed to
|
||||
* the middleware too.
|
||||
*
|
||||
* Called once during initialization.
|
||||
*
|
||||
* Errors / promise rejections will be caught and logged.
|
||||
*
|
||||
* Note that the result is not awaited - other store methods (such as increment) may be called before init returns and/or after it throws/rejects.
|
||||
*
|
||||
* @param options {Options} - The options used to setup the middleware.
|
||||
*/
|
||||
init?: (options: Options) => void;
|
||||
init?: (options: Options) => void | Promise<void>;
|
||||
/**
|
||||
* Method to fetch a client's hit count and reset time.
|
||||
*
|
||||
@@ -280,7 +341,8 @@ export type Store = {
|
||||
/**
|
||||
* Optional value that the store prepends to keys
|
||||
*
|
||||
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
||||
* Used by the double-count check to avoid false-positives when a key is counted
|
||||
* twice, but with different prefixes.
|
||||
*/
|
||||
prefix?: string;
|
||||
};
|
||||
@@ -372,6 +434,21 @@ export type Options = {
|
||||
* By default, the client's IP address is used.
|
||||
*/
|
||||
keyGenerator: ValueDeterminingMiddleware<string>;
|
||||
/**
|
||||
* IPv6 subnet mask applied to IPv6 addresses in the default keyGenerator.
|
||||
*
|
||||
* Default is 56. The valid range is technically 1-128 but the value should
|
||||
* generally be in the 32-64 range.
|
||||
*
|
||||
* Smaller numbers are more aggressive, larger numbers are more lenient. Try
|
||||
* bumping to 60 or 64 if you see evidence of users being blocked incorrectly.
|
||||
*
|
||||
* May also be set to a function that returns a number based on the request.
|
||||
*
|
||||
* See the documentation for more info:
|
||||
* https://express-rate-limit.mintlify.app/reference/configuration#ipv6subnet.
|
||||
*/
|
||||
ipv6Subnet: 64 | 60 | 56 | 52 | 50 | 48 | 32 | number | ValueDeterminingMiddleware<number> | false;
|
||||
/**
|
||||
* Express request handler that sends back a response when a client is
|
||||
* rate-limited.
|
||||
@@ -387,7 +464,7 @@ export type Options = {
|
||||
*/
|
||||
skip: ValueDeterminingMiddleware<boolean>;
|
||||
/**
|
||||
* Method to determine whether or not the request counts as 'succesful'. Used
|
||||
* Method to determine whether or not the request counts as 'successful'. Used
|
||||
* when either `skipSuccessfulRequests` or `skipFailedRequests` is set to true.
|
||||
*
|
||||
* By default, requests with a response status code less than 400 are considered
|
||||
@@ -426,6 +503,10 @@ export type Options = {
|
||||
* If the Store generates an error, allow the request to pass.
|
||||
*/
|
||||
passOnStoreError: boolean;
|
||||
/**
|
||||
* The logger to use to log errors. If absent, logs to the console.
|
||||
*/
|
||||
logger: Logger;
|
||||
};
|
||||
/**
|
||||
* The extended request object that includes information about the client's
|
||||
@@ -443,18 +524,8 @@ export type RateLimitInfo = {
|
||||
used: number;
|
||||
remaining: number;
|
||||
resetTime: Date | undefined;
|
||||
key: string;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Create an instance of IP rate-limiting middleware for Express.
|
||||
*
|
||||
* @param passedOptions {Options} - Options to configure the rate limiter.
|
||||
*
|
||||
* @returns {RateLimitRequestHandler} - The middleware that rate-limits clients based on your configuration.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const rateLimit: (passedOptions?: Partial<Options>) => RateLimitRequestHandler;
|
||||
/**
|
||||
* The record that stores information about a client - namely, how many times
|
||||
* they have hit the endpoint, and when their hit count resets.
|
||||
@@ -471,6 +542,7 @@ export type Client = {
|
||||
* @public
|
||||
*/
|
||||
export declare class MemoryStore implements Store {
|
||||
private validations?;
|
||||
/**
|
||||
* The duration of time before which all hit counts are reset (in milliseconds).
|
||||
*/
|
||||
@@ -496,6 +568,7 @@ export declare class MemoryStore implements Store {
|
||||
* cannot affect other instances.
|
||||
*/
|
||||
localKeys: boolean;
|
||||
constructor(validations?: Validations | undefined);
|
||||
/**
|
||||
* Method that initializes the store.
|
||||
*
|
||||
@@ -580,6 +653,17 @@ export declare class MemoryStore implements Store {
|
||||
*/
|
||||
private clearExpired;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Create an instance of IP rate-limiting middleware for Express.
|
||||
*
|
||||
* @param passedOptions {Options} - Options to configure the rate limiter.
|
||||
*
|
||||
* @returns {RateLimitRequestHandler} - The middleware that rate-limits clients based on your configuration.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const rateLimit: (passedOptions?: Partial<Options>) => RateLimitRequestHandler;
|
||||
|
||||
export {
|
||||
rateLimit as default,
|
||||
|
||||
+105
-21
@@ -1,7 +1,28 @@
|
||||
// Generated by dts-bundle-generator v8.0.1
|
||||
// Generated by dts-bundle-generator v8.1.2
|
||||
|
||||
import { NextFunction, Request, RequestHandler, Response } from 'express';
|
||||
|
||||
/**
|
||||
* Returns the IP address itself for IPv4, or a CIDR-notation subnet for IPv6.
|
||||
*
|
||||
* If you write a custom keyGenerator that allows a fallback to IP address for
|
||||
* unauthenticated users, return ipKeyGenerator(req.ip) rather than just req.ip.
|
||||
*
|
||||
* For more information, {@see Options.ipv6Subnet}.
|
||||
*
|
||||
* @param ip {string} - The IP address to process, usually request.ip.
|
||||
* @param ipv6Subnet {number | false} - The subnet mask for IPv6 addresses.
|
||||
*
|
||||
* @returns {string} - The key generated from the IP address
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare function ipKeyGenerator(ip: string, ipv6Subnet?: number | false): string;
|
||||
declare const SUPPORTED_DRAFT_VERSIONS: readonly [
|
||||
"draft-6",
|
||||
"draft-7",
|
||||
"draft-8"
|
||||
];
|
||||
declare const validations: {
|
||||
enabled: {
|
||||
[key: string]: boolean;
|
||||
@@ -39,6 +60,14 @@ declare const validations: {
|
||||
* @returns {void}
|
||||
*/
|
||||
xForwardedForHeader(request: Request): void;
|
||||
/**
|
||||
* Alert the user if the Forwarded header is set (standardized version of X-Forwarded-For - not supported by express as of version 5.1.0)
|
||||
*
|
||||
* @param request {Request} - The Express request object.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
forwardedHeader(request: Request): void;
|
||||
/**
|
||||
* Ensures totalHits value from store is a positive integer.
|
||||
*
|
||||
@@ -103,12 +132,13 @@ declare const validations: {
|
||||
* @returns {void}
|
||||
*/
|
||||
headersResetTime(resetTime?: Date): void;
|
||||
knownOptions(passedOptions?: Partial<Options>): void;
|
||||
/**
|
||||
* Checks the options.validate setting to ensure that only recognized
|
||||
* validations are enabled or disabled.
|
||||
*
|
||||
* If any unrecognized values are found, an error is logged that
|
||||
* includes the list of supported vaidations.
|
||||
* includes the list of supported validations.
|
||||
*/
|
||||
validationsConfig(): void;
|
||||
/**
|
||||
@@ -117,13 +147,38 @@ declare const validations: {
|
||||
* store (or any other store with localKeys.)
|
||||
*/
|
||||
creationStack(store: Store): void;
|
||||
ipv6Subnet(ipv6Subnet?: any): void;
|
||||
ipv6SubnetOrKeyGenerator(options: Partial<Options>): void;
|
||||
keyGeneratorIpFallback(keyGenerator?: ValueDeterminingMiddleware<string>): void;
|
||||
/**
|
||||
* Checks to see if the window duration is greater than 2^32 - 1. This is only
|
||||
* called by the default MemoryStore, since it uses Node's setInterval method.
|
||||
*
|
||||
* See https://nodejs.org/api/timers.html#setintervalcallback-delay-args.
|
||||
*/
|
||||
windowMs(windowMs: number): void;
|
||||
};
|
||||
export type Validations = typeof validations;
|
||||
declare const SUPPORTED_DRAFT_VERSIONS: readonly [
|
||||
"draft-6",
|
||||
"draft-7",
|
||||
"draft-8"
|
||||
];
|
||||
/**
|
||||
* Basic logging function
|
||||
*
|
||||
* @param error {unknown} - The error to log
|
||||
* @param message {string | undefined} - Additional details about the error
|
||||
*/
|
||||
export type LoggerFn = (error: unknown, message?: string) => void;
|
||||
/**
|
||||
* Minimal interface for logging warnings and errors
|
||||
*/
|
||||
export type Logger = {
|
||||
/**
|
||||
* Function to log an error
|
||||
*/
|
||||
error: LoggerFn;
|
||||
/**
|
||||
* Function to log a warning
|
||||
*/
|
||||
warn: LoggerFn;
|
||||
};
|
||||
/**
|
||||
* Callback that fires when a client's hit counter is incremented.
|
||||
*
|
||||
@@ -230,9 +285,15 @@ export type Store = {
|
||||
* Method that initializes the store, and has access to the options passed to
|
||||
* the middleware too.
|
||||
*
|
||||
* Called once during initialization.
|
||||
*
|
||||
* Errors / promise rejections will be caught and logged.
|
||||
*
|
||||
* Note that the result is not awaited - other store methods (such as increment) may be called before init returns and/or after it throws/rejects.
|
||||
*
|
||||
* @param options {Options} - The options used to setup the middleware.
|
||||
*/
|
||||
init?: (options: Options) => void;
|
||||
init?: (options: Options) => void | Promise<void>;
|
||||
/**
|
||||
* Method to fetch a client's hit count and reset time.
|
||||
*
|
||||
@@ -280,7 +341,8 @@ export type Store = {
|
||||
/**
|
||||
* Optional value that the store prepends to keys
|
||||
*
|
||||
* Used by the double-count check to avoid false-positives when a key is counted twice, but with different prefixes
|
||||
* Used by the double-count check to avoid false-positives when a key is counted
|
||||
* twice, but with different prefixes.
|
||||
*/
|
||||
prefix?: string;
|
||||
};
|
||||
@@ -372,6 +434,21 @@ export type Options = {
|
||||
* By default, the client's IP address is used.
|
||||
*/
|
||||
keyGenerator: ValueDeterminingMiddleware<string>;
|
||||
/**
|
||||
* IPv6 subnet mask applied to IPv6 addresses in the default keyGenerator.
|
||||
*
|
||||
* Default is 56. The valid range is technically 1-128 but the value should
|
||||
* generally be in the 32-64 range.
|
||||
*
|
||||
* Smaller numbers are more aggressive, larger numbers are more lenient. Try
|
||||
* bumping to 60 or 64 if you see evidence of users being blocked incorrectly.
|
||||
*
|
||||
* May also be set to a function that returns a number based on the request.
|
||||
*
|
||||
* See the documentation for more info:
|
||||
* https://express-rate-limit.mintlify.app/reference/configuration#ipv6subnet.
|
||||
*/
|
||||
ipv6Subnet: 64 | 60 | 56 | 52 | 50 | 48 | 32 | number | ValueDeterminingMiddleware<number> | false;
|
||||
/**
|
||||
* Express request handler that sends back a response when a client is
|
||||
* rate-limited.
|
||||
@@ -387,7 +464,7 @@ export type Options = {
|
||||
*/
|
||||
skip: ValueDeterminingMiddleware<boolean>;
|
||||
/**
|
||||
* Method to determine whether or not the request counts as 'succesful'. Used
|
||||
* Method to determine whether or not the request counts as 'successful'. Used
|
||||
* when either `skipSuccessfulRequests` or `skipFailedRequests` is set to true.
|
||||
*
|
||||
* By default, requests with a response status code less than 400 are considered
|
||||
@@ -426,6 +503,10 @@ export type Options = {
|
||||
* If the Store generates an error, allow the request to pass.
|
||||
*/
|
||||
passOnStoreError: boolean;
|
||||
/**
|
||||
* The logger to use to log errors. If absent, logs to the console.
|
||||
*/
|
||||
logger: Logger;
|
||||
};
|
||||
/**
|
||||
* The extended request object that includes information about the client's
|
||||
@@ -443,18 +524,8 @@ export type RateLimitInfo = {
|
||||
used: number;
|
||||
remaining: number;
|
||||
resetTime: Date | undefined;
|
||||
key: string;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* Create an instance of IP rate-limiting middleware for Express.
|
||||
*
|
||||
* @param passedOptions {Options} - Options to configure the rate limiter.
|
||||
*
|
||||
* @returns {RateLimitRequestHandler} - The middleware that rate-limits clients based on your configuration.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const rateLimit: (passedOptions?: Partial<Options>) => RateLimitRequestHandler;
|
||||
/**
|
||||
* The record that stores information about a client - namely, how many times
|
||||
* they have hit the endpoint, and when their hit count resets.
|
||||
@@ -471,6 +542,7 @@ export type Client = {
|
||||
* @public
|
||||
*/
|
||||
export declare class MemoryStore implements Store {
|
||||
private validations?;
|
||||
/**
|
||||
* The duration of time before which all hit counts are reset (in milliseconds).
|
||||
*/
|
||||
@@ -496,6 +568,7 @@ export declare class MemoryStore implements Store {
|
||||
* cannot affect other instances.
|
||||
*/
|
||||
localKeys: boolean;
|
||||
constructor(validations?: Validations | undefined);
|
||||
/**
|
||||
* Method that initializes the store.
|
||||
*
|
||||
@@ -580,6 +653,17 @@ export declare class MemoryStore implements Store {
|
||||
*/
|
||||
private clearExpired;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Create an instance of IP rate-limiting middleware for Express.
|
||||
*
|
||||
* @param passedOptions {Options} - Options to configure the rate limiter.
|
||||
*
|
||||
* @returns {RateLimitRequestHandler} - The middleware that rate-limits clients based on your configuration.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const rateLimit: (passedOptions?: Partial<Options>) => RateLimitRequestHandler;
|
||||
|
||||
export {
|
||||
rateLimit as default,
|
||||
|
||||
+613
-421
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user