@be-link/ecommerce-backend-bff-service-node-sdk 0.0.1 → 0.0.2
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/bff/modules/example/service.js +1 -1
- package/bff/request/client.js +4 -2
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/utils/env.js +8 -3
package/bff/request/client.js
CHANGED
|
@@ -37,9 +37,10 @@ class HttpClient {
|
|
|
37
37
|
*/
|
|
38
38
|
async request(opts) {
|
|
39
39
|
// 并发获取凭证,带错误处理
|
|
40
|
-
const [token, userId] = await Promise.all([
|
|
40
|
+
const [token, userId, ruleId] = await Promise.all([
|
|
41
41
|
Promise.resolve(this.options.getToken()).catch(() => ''),
|
|
42
42
|
Promise.resolve(this.options.getUserId()).catch(() => ''),
|
|
43
|
+
Promise.resolve(this.options.getRuleId?.() ?? '').catch(() => ''),
|
|
43
44
|
]);
|
|
44
45
|
// 生成唯一的请求 ID
|
|
45
46
|
const requestId = `b-${crypto.randomUUID()}`;
|
|
@@ -48,7 +49,8 @@ class HttpClient {
|
|
|
48
49
|
'Content-Type': 'application/json',
|
|
49
50
|
'X-Request-Id': requestId,
|
|
50
51
|
'x-belink-authorization': token,
|
|
51
|
-
'x-belink-userId': userId,
|
|
52
|
+
'x-belink-pandora-userId': userId,
|
|
53
|
+
'x-belink-pandora-ruleId': ruleId,
|
|
52
54
|
};
|
|
53
55
|
// 合并自定义请求头(自定义请求头优先)
|
|
54
56
|
const headers = {
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
package/utils/env.js
CHANGED
|
@@ -18,23 +18,28 @@ function isMiniProgram() {
|
|
|
18
18
|
*/
|
|
19
19
|
function getContainerHost(environment) {
|
|
20
20
|
// 生产环境和测试环境使用不同的主机地址
|
|
21
|
+
// TODO 生产url
|
|
21
22
|
return environment === 'production'
|
|
22
23
|
? 'http://bxbvjnca.tfs.cwl9ok0a.mk2u3r3l.com:8090' // 生产环境
|
|
23
|
-
: '
|
|
24
|
+
: 'https://backend-bff-service-196345-5-1304510571.sh.run.tcloudbase.com'; // 测试环境
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* 根据环境获取微信云环境标识符
|
|
27
28
|
* @param environment - 运行环境 ('production' 或 'test')
|
|
28
29
|
* @returns 云环境标识符
|
|
29
30
|
*/
|
|
31
|
+
// TODO 生产改
|
|
30
32
|
function getContainerEnv(environment) {
|
|
31
|
-
return environment === 'production'
|
|
33
|
+
return environment === 'production'
|
|
34
|
+
? 'ecommerce-dev-1g0iert2838e56dd'
|
|
35
|
+
: 'ecommerce-dev-1g0iert2838e56dd';
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* 根据环境获取微信云服务名称
|
|
35
39
|
* @param environment - 运行环境 ('production' 或 'test')
|
|
36
40
|
* @returns 云服务名称
|
|
37
41
|
*/
|
|
42
|
+
// TODO 生产改
|
|
38
43
|
function getContainerService(environment) {
|
|
39
|
-
return environment === 'production' ? 'bff-
|
|
44
|
+
return environment === 'production' ? 'backend-bff-service' : 'backend-bff-service';
|
|
40
45
|
}
|