formacao
This commit is contained in:
+31
-1
@@ -159,6 +159,26 @@ declare const validations: {
|
||||
windowMs(windowMs: number): void;
|
||||
};
|
||||
export type Validations = typeof validations;
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -265,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.
|
||||
*
|
||||
@@ -477,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
|
||||
|
||||
Reference in New Issue
Block a user