@be-link/ecommerce-client-backend-service-node-sdk 0.0.19 → 0.1.0
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 -5
- package/modules/data/types.d.ts +2 -2
- 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://client-backend:8090";
|
|
11
|
+
protected readonly natProdHost = "http://client-backend:8090";
|
|
12
|
+
/** 公网域名 */
|
|
13
|
+
protected readonly publicDevHost = "https://ecommerce-dev.wejourney.top";
|
|
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,14 +12,23 @@ const string_1 = require("../utils/string");
|
|
|
12
12
|
class BaseService {
|
|
13
13
|
constructor() {
|
|
14
14
|
/** 子网域名 */
|
|
15
|
-
this.natDevHost = '
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.
|
|
15
|
+
this.natDevHost = 'http://client-backend:8090';
|
|
16
|
+
this.natProdHost = 'http://client-backend:8090';
|
|
17
|
+
/** 公网域名 */
|
|
18
|
+
this.publicDevHost = 'https://ecommerce-dev.wejourney.top';
|
|
19
|
+
this.publicProdHost = '';
|
|
20
|
+
/** 如果是云函数环境, 默认走公网访问 */
|
|
21
|
+
this.isPublicEnv = (process.env.CONTAINER_ENV || 'SCF') === 'SCF';
|
|
19
22
|
}
|
|
20
23
|
/** 获取API URL */
|
|
21
24
|
getApiUrl(func) {
|
|
22
|
-
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;
|
|
23
32
|
return `${host}${this.prefixUrl}/${(0, string_1.camelToKebabCase)(func.name)}`;
|
|
24
33
|
}
|
|
25
34
|
}
|
package/modules/data/types.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare namespace DataService {
|
|
|
32
32
|
liveStreamRoomId: string;
|
|
33
33
|
/** 用户id */
|
|
34
34
|
userId: string;
|
|
35
|
+
/** 任务id */
|
|
36
|
+
taskId: string;
|
|
35
37
|
/** 查询观看类型 */
|
|
36
38
|
viewType: ENUM.LIVE_STREAM_AUDIENCE.VIEW_TYPE;
|
|
37
39
|
/** 用户行为 */
|
|
@@ -62,8 +64,6 @@ export declare namespace DataService {
|
|
|
62
64
|
viewType: ENUM.LIVE_STREAM_AUDIENCE.VIEW_TYPE;
|
|
63
65
|
/** 观看时长,单位秒 */
|
|
64
66
|
duration: number;
|
|
65
|
-
/** 观看总时长,单位秒 */
|
|
66
|
-
totalDuration?: number;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* 根据用户id查询所在直播间信息响应
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@be-link/ecommerce-client-backend-service-node-sdk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "EcommerceClientBackendService Node.js SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
"axios": "1.13.2",
|
|
16
16
|
"axios-retry": "4.0.0",
|
|
17
17
|
"fastify": "5.6.2",
|
|
18
|
-
"uuid": "9.0.1"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {
|
|
18
|
+
"uuid": "9.0.1",
|
|
21
19
|
"tsoa": "^6.6.0"
|
|
22
20
|
},
|
|
23
21
|
"scripts": {
|
package/utils/http.js
CHANGED
|
@@ -72,7 +72,7 @@ async function callApi(url, request) {
|
|
|
72
72
|
console.error(`ecommerce-client-backend-service 异常: ${axiosError.message},requestId: ${requestId}`);
|
|
73
73
|
console.info('响应信息', data.message);
|
|
74
74
|
console.error('异常堆栈', JSON.stringify(error.stack));
|
|
75
|
-
throw
|
|
75
|
+
throw error;
|
|
76
76
|
}
|
|
77
77
|
// 调用dns模块解析url
|
|
78
78
|
const dns = await Promise.resolve().then(() => __importStar(require('dns')));
|