axios-master
Advanced tools
+8
-16
@@ -118,7 +118,2 @@ "use strict"; | ||
| const startTime = Date.now(); | ||
| let timer = 0; | ||
| const interval = setInterval(() => { | ||
| const elapsedTime = Date.now() - startTime; | ||
| timer = parseFloat((elapsedTime / 1000).toFixed(5)); | ||
| }, 1); | ||
| const log = (level, message, data) => { | ||
@@ -136,5 +131,5 @@ if (masterConfig.logger) { | ||
| const response = yield (0, axios_1.default)(config); | ||
| clearInterval(interval); | ||
| const elapsedTime = parseFloat(((Date.now() - startTime) / 1000).toFixed(5)); | ||
| console.log("\x1b[32m", ": resolve"); | ||
| console.log("\x1b[33m", `${masterConfig.name || config.url} => ${timer} s :`); | ||
| console.log("\x1b[33m", `${masterConfig.name || config.url} => ${elapsedTime} s :`); | ||
| if (masterConfig.log) { | ||
@@ -147,3 +142,3 @@ console.log(response); | ||
| catch (error) { | ||
| clearInterval(interval); | ||
| const elapsedTime = parseFloat(((Date.now() - startTime) / 1000).toFixed(5)); | ||
| if (masterConfig.log) { | ||
@@ -153,3 +148,3 @@ console.log(error); | ||
| console.log("\x1b[35m", ": reject"); | ||
| console.log("\x1b[33m", `${masterConfig.name || config.url} => ${timer} s :`); | ||
| console.log("\x1b[33m", `${masterConfig.name || config.url} => ${elapsedTime} s :`); | ||
| if (error instanceof axios_1.AxiosError && error.response) { | ||
@@ -165,3 +160,3 @@ console.log(error.response.data); | ||
| log("INFO", `API -> ${masterConfig.name || config.url}`, { | ||
| time: timer, | ||
| time: parseFloat(((Date.now() - startTime) / 1000).toFixed(5)), | ||
| request: default_config, | ||
@@ -183,3 +178,3 @@ response: response.data, | ||
| log("INFO", `API -> ${masterConfig.name || config.url}`, { | ||
| time: timer, | ||
| time: parseFloat(((Date.now() - startTime) / 1000).toFixed(5)), | ||
| request: default_config, | ||
@@ -192,3 +187,3 @@ response: retryResponse.data, | ||
| log("WARN", `Retry API -> ${masterConfig.name || config.url} failed`, { | ||
| time: timer, | ||
| time: parseFloat(((Date.now() - startTime) / 1000).toFixed(5)), | ||
| request: default_config, | ||
@@ -202,3 +197,3 @@ response: retryError, | ||
| log("WARN", `API -> ${masterConfig.name || config.url} failed`, { | ||
| time: timer, | ||
| time: parseFloat(((Date.now() - startTime) / 1000).toFixed(5)), | ||
| request: default_config, | ||
@@ -210,7 +205,4 @@ response: error, | ||
| } | ||
| finally { | ||
| clearInterval(interval); | ||
| } | ||
| }); | ||
| exports.axiosMasterMain = axiosMasterMain; | ||
| exports.default = exports.axiosMaster; |
+1
-1
| { | ||
| "name": "axios-master", | ||
| "version": "1.1.5", | ||
| "version": "1.1.6", | ||
| "description": "axios response time status log", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
11425
0.75%226
-3.42%