@be-link/ecommerce-promotion-service-node-sdk 0.0.36 → 0.1.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.
- package/modules/BaseService.d.ts +7 -2
- package/modules/BaseService.js +14 -3
- package/package.json +2 -4
- package/utils/http.js +1 -1
package/modules/BaseService.d.ts
CHANGED
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
* 所有服务类都应该继承此类
|
|
4
4
|
*/
|
|
5
5
|
export default abstract class BaseService {
|
|
6
|
+
private isPublicEnv;
|
|
6
7
|
/** URL一级路径 */
|
|
7
8
|
protected abstract prefixUrl: string;
|
|
8
9
|
/** 子网域名 */
|
|
9
|
-
protected readonly natDevHost = "
|
|
10
|
-
protected readonly natProdHost = "";
|
|
10
|
+
protected readonly natDevHost = "http://promotion:8090/promotion";
|
|
11
|
+
protected readonly natProdHost = "http://promotion:8090/promotion";
|
|
12
|
+
/** 公网域名 */
|
|
13
|
+
protected readonly publicDevHost = "https://ecommerce-dev.wejourney.top/promotion";
|
|
14
|
+
protected readonly publicProdHost = "";
|
|
15
|
+
constructor();
|
|
11
16
|
/** 获取API URL */
|
|
12
17
|
protected getApiUrl(func: Function): string;
|
|
13
18
|
}
|
package/modules/BaseService.js
CHANGED
|
@@ -12,12 +12,23 @@ const string_1 = require("../utils/string");
|
|
|
12
12
|
class BaseService {
|
|
13
13
|
constructor() {
|
|
14
14
|
/** 子网域名 */
|
|
15
|
-
this.natDevHost = '
|
|
16
|
-
this.natProdHost = '';
|
|
15
|
+
this.natDevHost = 'http://promotion:8090/promotion';
|
|
16
|
+
this.natProdHost = 'http://promotion:8090/promotion';
|
|
17
|
+
/** 公网域名 */
|
|
18
|
+
this.publicDevHost = 'https://ecommerce-dev.wejourney.top/promotion';
|
|
19
|
+
this.publicProdHost = '';
|
|
20
|
+
/** 如果是云函数环境, 默认走公网访问 */
|
|
21
|
+
this.isPublicEnv = (process.env.CONTAINER_ENV || 'SCF') === 'SCF';
|
|
17
22
|
}
|
|
18
23
|
/** 获取API URL */
|
|
19
24
|
getApiUrl(func) {
|
|
20
|
-
const host =
|
|
25
|
+
const host = this.isPublicEnv
|
|
26
|
+
? env_1.default.isProduction()
|
|
27
|
+
? this.publicProdHost
|
|
28
|
+
: this.publicDevHost
|
|
29
|
+
: env_1.default.isProduction()
|
|
30
|
+
? this.natProdHost
|
|
31
|
+
: this.natDevHost;
|
|
21
32
|
return `${host}${this.prefixUrl}/${(0, string_1.camelToKebabCase)(func.name)}`;
|
|
22
33
|
}
|
|
23
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@be-link/ecommerce-promotion-service-node-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "EcommercePromotionService Node.js SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
"@fastify/request-context": "6.2.1",
|
|
14
14
|
"axios": "1.13.2",
|
|
15
15
|
"axios-retry": "4.0.0",
|
|
16
|
-
"uuid": "9.0.1"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
16
|
+
"uuid": "9.0.1",
|
|
19
17
|
"tsoa": "^6.6.0"
|
|
20
18
|
},
|
|
21
19
|
"scripts": {
|
package/utils/http.js
CHANGED
|
@@ -80,7 +80,7 @@ async function callApi(url, request) {
|
|
|
80
80
|
console.error(`ecommerce-promotion-service 异常: ${axiosError.message},requestId: ${requestId}`);
|
|
81
81
|
console.info('响应信息', data.message);
|
|
82
82
|
console.error('异常堆栈', JSON.stringify(error.stack));
|
|
83
|
-
throw
|
|
83
|
+
throw error;
|
|
84
84
|
}
|
|
85
85
|
// 调用dns模块解析url
|
|
86
86
|
const dns = await Promise.resolve().then(() => __importStar(require('dns')));
|