@be-link/ecommerce-promotion-service-node-sdk 0.1.10 → 0.1.11
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/package.json +3 -2
- package/utils/http.js +7 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@be-link/ecommerce-promotion-service-node-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "EcommercePromotionService Node.js SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"axios": "1.13.2",
|
|
15
15
|
"axios-retry": "4.0.0",
|
|
16
16
|
"uuid": "9.0.1",
|
|
17
|
-
"tsoa": "^6.6.0"
|
|
17
|
+
"tsoa": "^6.6.0",
|
|
18
|
+
"safe-stable-stringify": "2.5.0"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build": "rm -rf ./dist && tsc && cp package.json README.md ./dist/ 2>/dev/null || true",
|
package/utils/http.js
CHANGED
|
@@ -41,6 +41,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
41
41
|
const uuid_1 = require("uuid");
|
|
42
42
|
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
43
43
|
const request_context_1 = require("@fastify/request-context");
|
|
44
|
+
const safe_stable_stringify_1 = __importDefault(require("safe-stable-stringify"));
|
|
44
45
|
(0, axios_retry_1.default)(axios_1.default, {
|
|
45
46
|
retries: 1,
|
|
46
47
|
retryCondition(error) {
|
|
@@ -51,7 +52,7 @@ const request_context_1 = require("@fastify/request-context");
|
|
|
51
52
|
return retryCount * 500;
|
|
52
53
|
},
|
|
53
54
|
onRetry(retryCount, error, requestConfig) {
|
|
54
|
-
console.info(`retryCount: ${retryCount}, onRetry: ${error.message}, requestHeader: ${
|
|
55
|
+
console.info(`retryCount: ${retryCount}, onRetry: ${error.message}, requestHeader: ${(0, safe_stable_stringify_1.default)(requestConfig.headers)}`);
|
|
55
56
|
},
|
|
56
57
|
});
|
|
57
58
|
async function callApi(url, request) {
|
|
@@ -60,7 +61,7 @@ async function callApi(url, request) {
|
|
|
60
61
|
const beLinkUserId = request_context_1.requestContext.get('beLinkUserId') || '';
|
|
61
62
|
const pandoraRoleId = request_context_1.requestContext.get('pandoraRoleId') || '';
|
|
62
63
|
try {
|
|
63
|
-
console.info(`准备发起ecommerce-promotion-service请求[${requestId}]: ${url}, 参数: ${
|
|
64
|
+
console.info(`准备发起ecommerce-promotion-service请求[${requestId}]: ${url}, 参数: ${(0, safe_stable_stringify_1.default)(request)}`);
|
|
64
65
|
const response = await axios_1.default.post(url, request || {}, {
|
|
65
66
|
headers: {
|
|
66
67
|
'x-request-id': requestId,
|
|
@@ -79,7 +80,7 @@ async function callApi(url, request) {
|
|
|
79
80
|
const data = response.data;
|
|
80
81
|
console.error(`ecommerce-promotion-service 异常: ${axiosError.message},requestId: ${requestId}`);
|
|
81
82
|
console.info('响应信息', data.message);
|
|
82
|
-
console.error('异常堆栈',
|
|
83
|
+
console.error('异常堆栈', (0, safe_stable_stringify_1.default)(error.stack));
|
|
83
84
|
throw error;
|
|
84
85
|
}
|
|
85
86
|
// 调用dns模块解析url
|
|
@@ -90,16 +91,16 @@ async function callApi(url, request) {
|
|
|
90
91
|
console.error(err.message);
|
|
91
92
|
reject(err);
|
|
92
93
|
}
|
|
93
|
-
console.info(`lookup: ${
|
|
94
|
+
console.info(`lookup: ${(0, safe_stable_stringify_1.default)(lookupRes)}`);
|
|
94
95
|
resolve(address);
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
try {
|
|
98
99
|
const address = await dnsPromise;
|
|
99
|
-
console.info(`address: ${
|
|
100
|
+
console.info(`address: ${(0, safe_stable_stringify_1.default)(address)}`);
|
|
100
101
|
}
|
|
101
102
|
catch (error) {
|
|
102
|
-
console.info(`error: ${
|
|
103
|
+
console.info(`error: ${(0, safe_stable_stringify_1.default)(error)}`);
|
|
103
104
|
}
|
|
104
105
|
console.error(`ecommerce-promotion-service 未知异常: ${axiosError.message}`, error.stack);
|
|
105
106
|
throw error;
|