@6thbridge/utils 1.0.14 → 1.0.15-1

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.
@@ -1,27 +1,4 @@
1
1
  'use strict';
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -33,47 +10,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
33
10
  };
34
11
  Object.defineProperty(exports, "__esModule", { value: true });
35
12
  exports.getRollbarInstance = exports.rollbar = exports.Monitoring = exports.reportAxiosError = exports.getMonitoredAxios = void 0;
36
- const apitoolkit_express_1 = __importStar(require("apitoolkit-express"));
37
- const logger_1 = require("../logger/logger");
38
13
  const utils_1 = require("../utils");
39
14
  const rollbar_1 = require("./rollbar");
40
- let apitoolkit;
41
15
  function getMonitoredAxios(options) {
42
16
  return Monitoring.getMonitoredAxios(options);
43
17
  }
44
18
  exports.getMonitoredAxios = getMonitoredAxios;
45
19
  function reportAxiosError(error) {
46
20
  return __awaiter(this, void 0, void 0, function* () {
47
- try {
48
- (0, apitoolkit_express_1.ReportError)(error);
49
- }
50
- catch (e) {
51
- logger_1.logger.exception(e);
52
- }
53
21
  });
54
22
  }
55
23
  exports.reportAxiosError = reportAxiosError;
56
24
  class Monitoring {
57
25
  static getMonitoredAxios(options) {
58
- var _a, _b;
59
- const axiosInstance = options.axiosInstance || utils_1.HttpUtil.getAxiosInstance();
60
- if (!options.apitoolkitApiKey)
61
- return axiosInstance;
62
- if (!apitoolkit)
63
- apitoolkit = apitoolkit_express_1.default.NewClient({ apiKey: options.apitoolkitApiKey });
64
- options.redactRequestBody = options.redactRequestBody || [];
65
- options.redactResponseBody = options.redactResponseBody || [];
66
- if ((_a = options === null || options === void 0 ? void 0 : options.redactResponseBody) === null || _a === void 0 ? void 0 : _a.length) {
67
- options.redactResponseBody = options.redactResponseBody.map((field) => `$.${field}`);
68
- // console.log("redactResponseBody", options.redactResponseBody);
69
- }
70
- if ((_b = options === null || options === void 0 ? void 0 : options.redactRequestBody) === null || _b === void 0 ? void 0 : _b.length) {
71
- // console.log("redactRequestBody", options?.redactRequestBody);
72
- options.redactRequestBody = options.redactRequestBody.map((field) => `$.${field}`);
73
- // console.log("after redactRequestBody", options.redactRequestBody);
74
- }
75
- //@ts-ignore
76
- return apitoolkit.observeAxios(axiosInstance, options.urlWildcard, options.redactHeaders, options.redactRequestBody, options.redactResponseBody);
26
+ const axiosInstance = ((options === null || options === void 0 ? void 0 : options.axiosInstance) || utils_1.HttpUtil.getAxiosInstance());
27
+ // Interceptors are now attached centrally inside HttpUtil.getAxiosInstance()
28
+ return axiosInstance;
77
29
  }
78
30
  }
79
31
  exports.Monitoring = Monitoring;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/monitoring/index.ts"],"names":[],"mappings":"AAA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