express-http-client
Version:
middleware style interceptor; fetch based 0 dependancy imperative light weight http handler.
54 lines • 2.45 kB
TypeScript
/**
* Executes a chain of request interceptors sequentially
*
* @async
* @param {Object} data - The data object containing the request and a store
* @param {Request} data.request - The Request object to be processed
* @param {Map} data.store - A Map object for storing data between interceptors
* @param {Function[]} interceptors - Array of request interceptor functions
* @returns {Promise<Request|Error>} The processed request or an Error if interceptor chain fails
*
* @description
* Each interceptor in the chain receives:
* - data: The data object containing the request
* - next: Function to proceed to the next interceptor
* - end: Function to end the interceptor chain early
*
* Interceptors can modify the request, pass control to the next interceptor,
* end the chain early, or reject with an error.
*/
export function executeRequestInterceptors(data: {
request: Request;
store: Map<any, any>;
}, interceptors: Function[]): Promise<Request | Error>;
/**
* Executes a chain of response interceptors sequentially
*
* @async
* @param {Object} data - The data object containing the response
* @param {Request} data.request - The Request object used in the original request if not modified by other response interceptors
* @param {Response} data.response - The Response object to be processed
* @param {number} data.requestTime - The timestamp of the original request
* @param {number} data.responseTime - The timestamp of the processed response
* @param {Map} data.store - A Map object for storing data between interceptors in one request chain execution
* @param {Function[]} interceptors - Array of response interceptor functions
* @returns {Promise<Response>} The processed response
*
* @description
* Each interceptor in the chain receives:
* - data: The data object containing the response
* - next: Function to proceed to the next interceptor
* - end: Function to end the interceptor chain early
*
* Interceptors can modify the response, pass control to the next interceptor,
* end the chain early, or handle errors. Errors in response interceptors
* result in a 424 Failed Dependency response rather than rejecting the promise.
*/
export function executeResponseInterceptors(data: {
request: Request;
response: Response;
requestTime: number;
responseTime: number;
store: Map<any, any>;
}, interceptors: Function[]): Promise<Response>;
//# sourceMappingURL=Core.d.ts.map