UNPKG

express-http-client

Version:

middleware style interceptor; fetch based 0 dependancy imperative light weight http handler.

42 lines 1.82 kB
/** * Creates a middleware that logs HTTP requests and responses with appropriate formatting * for both browser and Node.js environments * * @returns {function({ * request: Request, * response: Response, * requestTime: number, * responseTime: number, * store: Map<any, any> * }, function():void, function():void):Promise<void>} * A middleware function that logs request details with the following parameters: * - {Object} data - The request/response data object containing: * - {Request} request - The HTTP request object with method and url properties * - {Response} response - The HTTP response object with status property * - {number} requestTime - The timestamp when the request was received * - {number} responseTime - The timestamp when the response was sent * - {Map<any, any>} store - A Map object for storing data between interceptors * - {function():void} next - Function to call to proceed to the next middleware * - {function():void} end - Function to call to end the middleware chain * * @description * This middleware logs HTTP requests with the following information: * - Timestamp in ISO format * - Status code (color-coded by response type) * - HTTP method (color-coded by method type) * - Request URL * - Response time (color-coded by performance) * * Color coding: * - Status: Green for 2xx, Yellow for 3xx, Red for 4xx/5xx * - Method: Cyan for most methods, Magenta for POST, Red for DELETE * - Response time: Green for <100ms, Yellow for <1000ms, Red for ≥1000ms */ export default function Logger(): (arg0: { request: Request; response: Response; requestTime: number; responseTime: number; store: Map<any, any>; }, arg1: () => void, arg2: () => void) => Promise<void>; //# sourceMappingURL=Logger.d.ts.map