ti2 1.0.58 → 1.0.59
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.
package/index.js
CHANGED
|
@@ -15,10 +15,6 @@ const EventEmitter = require('eventemitter2');
|
|
|
15
15
|
const axios = require('axios');
|
|
16
16
|
const curlirize = require('axios-curlirize');
|
|
17
17
|
|
|
18
|
-
if (process.env.debug) {
|
|
19
|
-
curlirize(axios);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
const cacheSettings = {
|
|
23
19
|
'*': [
|
|
24
20
|
'getAffiliateAgents',
|
|
@@ -237,6 +233,9 @@ module.exports = async ({
|
|
|
237
233
|
}
|
|
238
234
|
return response;
|
|
239
235
|
});
|
|
236
|
+
if (process.env.debug) {
|
|
237
|
+
curlirize(axiosPlugin);
|
|
238
|
+
}
|
|
240
239
|
req.axios = async (...args) => axiosPlugin(...args).catch(err => {
|
|
241
240
|
const errMsg = (() => {
|
|
242
241
|
const defaultErr = R.omit(['config'], err.toJSON()); // default error
|
|
@@ -248,7 +247,7 @@ module.exports = async ({
|
|
|
248
247
|
}
|
|
249
248
|
return defaultErr;
|
|
250
249
|
})();
|
|
251
|
-
if (
|
|
250
|
+
if (process.env.debug) console.error(`error in ${pluginName}`, args[0], errMsg);
|
|
252
251
|
if (ti2Events.events) {
|
|
253
252
|
ti2Events.events.emit(`${pluginName}.axios.error`, {
|
|
254
253
|
request: args[0],
|
|
@@ -310,7 +309,7 @@ module.exports = async ({
|
|
|
310
309
|
return next(err);
|
|
311
310
|
}
|
|
312
311
|
if (process.env.CONSOLE_ERRORS || process.env.JEST_WORKER_ID) {
|
|
313
|
-
console.error(R.path(['response', 'data'], err)
|
|
312
|
+
console.error(R.path(['response', 'data'], err));
|
|
314
313
|
}
|
|
315
314
|
return res.status((() => {
|
|
316
315
|
if (!isNumber(err.status)) return 500;
|