@riocrypto/common-server 1.0.2016 → 1.0.2018

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,11 +35,15 @@ function maskHeaders(headers) {
35
35
  // Request Interceptor
36
36
  axiosWithLogging.interceptors.request.use((config) => {
37
37
  var _a;
38
- // Mask sensitive headers in the configuration
39
- const maskedHeaders = maskHeaders(config.headers);
40
- // Combine and log the full request configuration with masked headers
41
- const logMessage = `Request: method=${config.method}, url=${config.url}, headers=${JSON.stringify(maskedHeaders)}, data=${JSON.stringify(config.data)}`;
42
- ((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
38
+ const customConfig = config;
39
+ // Check if logging is disabled for this request
40
+ if (!customConfig.skipLogging) {
41
+ // Mask sensitive headers in the configuration
42
+ const maskedHeaders = maskHeaders(customConfig.headers);
43
+ // Combine and log the full request configuration with masked headers
44
+ const logMessage = `Request: method=${customConfig.method}, url=${customConfig.url}, headers=${JSON.stringify(maskedHeaders)}, data=${JSON.stringify(customConfig.data)}`;
45
+ ((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
46
+ }
43
47
  return config;
44
48
  }, (error) => {
45
49
  var _a;
@@ -51,13 +55,17 @@ axiosWithLogging.interceptors.request.use((config) => {
51
55
  // Response Interceptor
52
56
  axiosWithLogging.interceptors.response.use((response) => {
53
57
  var _a;
54
- // Combine and log the full response details
55
- const logMessage = `Response: url=${response.config.url}, status=${response.status}, data=${JSON.stringify(response.data)}`;
56
- ((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
58
+ const customConfig = response.config;
59
+ // Check if logging is disabled for this request
60
+ if (!customConfig.skipLogging) {
61
+ // Combine and log the full response details
62
+ const logMessage = `Response: url=${customConfig.url}, status=${response.status}, data=${JSON.stringify(response.data)}`;
63
+ ((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
64
+ }
57
65
  return response;
58
66
  }, (error) => {
59
67
  var _a;
60
- // Combine and log the response error details
68
+ // Combine and log the response error details without headers
61
69
  let logMessage = `Response Error: url=${error.config ? error.config.url : "unknown"}, message=${error.message}`;
62
70
  if (error.response) {
63
71
  logMessage += `, status=${error.response.status}, data=${JSON.stringify(error.response.data)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2016",
3
+ "version": "1.0.2018",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",