@be-link/ecommerce-promotion-service-node-sdk 0.1.10 → 0.1.12
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/modules/BaseService.d.ts +2 -2
- package/modules/BaseService.js +2 -2
- package/package.json +3 -2
- package/utils/http.js +8 -6
package/modules/BaseService.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export default abstract class BaseService {
|
|
|
7
7
|
/** URL一级路径 */
|
|
8
8
|
protected abstract prefixUrl: string;
|
|
9
9
|
/** 子网域名 */
|
|
10
|
-
protected readonly natDevHost = "http://
|
|
11
|
-
protected readonly natProdHost = "http://
|
|
10
|
+
protected readonly natDevHost = "http://192.168.3.168:8090/promotion";
|
|
11
|
+
protected readonly natProdHost = "http://192.168.74.224:8090/promotion";
|
|
12
12
|
/** 公网域名 */
|
|
13
13
|
protected readonly publicDevHost = "https://ecommerce-dev.wejourney.top/promotion";
|
|
14
14
|
protected readonly publicProdHost = "";
|
package/modules/BaseService.js
CHANGED
|
@@ -12,8 +12,8 @@ const string_1 = require("../utils/string");
|
|
|
12
12
|
class BaseService {
|
|
13
13
|
constructor() {
|
|
14
14
|
/** 子网域名 */
|
|
15
|
-
this.natDevHost = 'http://
|
|
16
|
-
this.natProdHost = 'http://
|
|
15
|
+
this.natDevHost = 'http://192.168.3.168:8090/promotion';
|
|
16
|
+
this.natProdHost = 'http://192.168.74.224:8090/promotion';
|
|
17
17
|
/** 公网域名 */
|
|
18
18
|
this.publicDevHost = 'https://ecommerce-dev.wejourney.top/promotion';
|
|
19
19
|
this.publicProdHost = '';
|
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.12",
|
|
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,
|
|
@@ -68,6 +69,7 @@ async function callApi(url, request) {
|
|
|
68
69
|
'x-belink-userid': beLinkUserId,
|
|
69
70
|
'x-belink-pandora-roleid': pandoraRoleId,
|
|
70
71
|
},
|
|
72
|
+
timeout: 3000,
|
|
71
73
|
});
|
|
72
74
|
const responseData = response.data;
|
|
73
75
|
return responseData.data;
|
|
@@ -79,7 +81,7 @@ async function callApi(url, request) {
|
|
|
79
81
|
const data = response.data;
|
|
80
82
|
console.error(`ecommerce-promotion-service 异常: ${axiosError.message},requestId: ${requestId}`);
|
|
81
83
|
console.info('响应信息', data.message);
|
|
82
|
-
console.error('异常堆栈',
|
|
84
|
+
console.error('异常堆栈', (0, safe_stable_stringify_1.default)(error.stack));
|
|
83
85
|
throw error;
|
|
84
86
|
}
|
|
85
87
|
// 调用dns模块解析url
|
|
@@ -90,16 +92,16 @@ async function callApi(url, request) {
|
|
|
90
92
|
console.error(err.message);
|
|
91
93
|
reject(err);
|
|
92
94
|
}
|
|
93
|
-
console.info(`lookup: ${
|
|
95
|
+
console.info(`lookup: ${(0, safe_stable_stringify_1.default)(lookupRes)}`);
|
|
94
96
|
resolve(address);
|
|
95
97
|
});
|
|
96
98
|
});
|
|
97
99
|
try {
|
|
98
100
|
const address = await dnsPromise;
|
|
99
|
-
console.info(`address: ${
|
|
101
|
+
console.info(`address: ${(0, safe_stable_stringify_1.default)(address)}`);
|
|
100
102
|
}
|
|
101
103
|
catch (error) {
|
|
102
|
-
console.info(`error: ${
|
|
104
|
+
console.info(`error: ${(0, safe_stable_stringify_1.default)(error)}`);
|
|
103
105
|
}
|
|
104
106
|
console.error(`ecommerce-promotion-service 未知异常: ${axiosError.message}`, error.stack);
|
|
105
107
|
throw error;
|