-
Notifications
You must be signed in to change notification settings - Fork 0
Enhancers: HttpStatusEnhancer
File: http-status.enhancer.ts
The HttpStatusEnhancer class is designed to augment error objects with HTTP-specific metadata. This can be valuable for debugging, monitoring, and auditing HTTP-related issues within applications.
| Property | Description |
|---|---|
httpStatusCode |
HTTP Status Code, default is -1. |
url |
URL where the error occurred, default is an empty string. |
httpMethod |
HTTP Method used (GET, POST, etc.), default is an empty string. |
requestHeaders |
HTTP request headers, default is an empty object. |
responseHeaders |
HTTP response headers, default is an empty object. |
queryParams |
Query parameters in the URL, default is an empty object. |
requestBody |
Body of the HTTP request, default is null. |
responseBody |
Body of the HTTP response, default is null. |
clientIp |
Client's IP address, default is an empty string. |
latency |
Latency in milliseconds, default is -1. |
Sets the HTTP status code and validates it against known status codes.
Usage Example:
const httpStatus = new HttpStatusEnhancer();
httpStatus.setHttpStatusCode(200);Sets the URL where the error occurred and validates its format.
Usage Example:
httpStatus.setUrl("https://example.com");Sets the HTTP method used in the request and validates it against known methods.
Usage Example:
httpStatus.setHttpMethod("GET");Sets the request headers.
Usage Example:
httpStatus.setRequestHeaders({ "Content-Type": "application/json" });Sets the response headers.
Usage Example:
httpStatus.setResponseHeaders({ "Content-Type": "application/json" });Sets the query parameters.
Usage Example:
httpStatus.setQueryParams({ "page": 1, "limit": 10 });Sets the body of the HTTP request.
Usage Example:
httpStatus.setRequestBody({ "key": "value" });Sets the body of the HTTP response.
Usage Example:
httpStatus.setResponseBody({ "key": "value" });Sets the client's IP address.
Usage Example:
httpStatus.setClientIp("192.168.0.1");Sets the latency of the request in milliseconds.
Usage Example:
httpStatus.setLatency(120);error-enhanced Wiki
Version: 1.2.1 - © 2023
🔗 MIT License | 📦 GitHub Repository | 🐞 Report Issues | ✉️ Contact