@cloudbase/manager-node 4.1.2 → 4.2.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/lib/constant.js +3 -3
- package/lib/env/index.js +4 -2
- package/lib/storage/index.js +12 -2
- package/lib/utils/runenv.js +8 -0
- package/package.json +1 -1
- package/types/constant.d.ts +2 -1
- package/types/utils/runenv.d.ts +1 -0
- package/.vscode/settings.json +0 -3
package/lib/constant.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// static credentail = 'credential'
|
|
5
5
|
// }
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.COS_SDK_PROTOCOL = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
|
|
7
|
+
exports.COS_SDK_KEEPALIVE = exports.COS_SDK_PROTOCOL = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
|
|
8
8
|
exports.ENV_NAME = {
|
|
9
9
|
ENV_SECRETID: 'TENCENTCLOUD_SECRETID',
|
|
10
10
|
ENV_SECRETKEY: 'TENCENTCLOUD_SECRETKEY',
|
|
@@ -51,5 +51,5 @@ exports.SCF_STATUS = {
|
|
|
51
51
|
};
|
|
52
52
|
// 是否使用内网域名
|
|
53
53
|
exports.USE_INTERNAL_ENDPOINT = "USE_INTERNAL_ENDPOINT" in process.env;
|
|
54
|
-
|
|
55
|
-
exports.
|
|
54
|
+
exports.COS_SDK_PROTOCOL = process.env.COS_SDK_PROTOCOL;
|
|
55
|
+
exports.COS_SDK_KEEPALIVE = process.env.COS_SDK_KEEPALIVE;
|
package/lib/env/index.js
CHANGED
|
@@ -261,8 +261,10 @@ class EnvService {
|
|
|
261
261
|
SecurityToken: token,
|
|
262
262
|
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* PUBLIC */
|
|
263
263
|
};
|
|
264
|
-
if (constant_1.COS_SDK_PROTOCOL
|
|
265
|
-
cosConfig.Protocol =
|
|
264
|
+
if (constant_1.COS_SDK_PROTOCOL) {
|
|
265
|
+
cosConfig.Protocol = constant_1.COS_SDK_PROTOCOL.endsWith(':')
|
|
266
|
+
? constant_1.COS_SDK_PROTOCOL.toLowerCase()
|
|
267
|
+
: constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':';
|
|
266
268
|
}
|
|
267
269
|
return new cos_nodejs_sdk_v5_1.default(cosConfig);
|
|
268
270
|
}
|
package/lib/storage/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const cos_nodejs_sdk_v5_1 = __importDefault(require("cos-nodejs-sdk-v5"));
|
|
|
20
20
|
const utils_1 = require("../utils");
|
|
21
21
|
const error_1 = require("../error");
|
|
22
22
|
const parallel_1 = require("../utils/parallel");
|
|
23
|
+
const runenv_1 = require("../utils/runenv");
|
|
23
24
|
const constant_1 = require("../constant");
|
|
24
25
|
const BIG_FILE_SIZE = 5242880; // 5MB 1024*1024*5
|
|
25
26
|
class StorageService {
|
|
@@ -848,8 +849,17 @@ class StorageService {
|
|
|
848
849
|
SecurityToken: token,
|
|
849
850
|
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* PUBLIC */
|
|
850
851
|
};
|
|
851
|
-
if (constant_1.COS_SDK_PROTOCOL
|
|
852
|
-
cosConfig.Protocol =
|
|
852
|
+
if (constant_1.COS_SDK_PROTOCOL) {
|
|
853
|
+
cosConfig.Protocol = constant_1.COS_SDK_PROTOCOL.endsWith(':')
|
|
854
|
+
? constant_1.COS_SDK_PROTOCOL.toLowerCase()
|
|
855
|
+
: constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':';
|
|
856
|
+
}
|
|
857
|
+
// COSSDK 默认开启 KeepAlive,这里提供关闭的方式
|
|
858
|
+
if (constant_1.COS_SDK_KEEPALIVE) {
|
|
859
|
+
cosConfig.KeepAlive = { true: true, false: false }[constant_1.COS_SDK_KEEPALIVE];
|
|
860
|
+
}
|
|
861
|
+
else if (runenv_1.checkIsInScf()) {
|
|
862
|
+
cosConfig.KeepAlive = false;
|
|
853
863
|
}
|
|
854
864
|
return new cos_nodejs_sdk_v5_1.default(cosConfig);
|
|
855
865
|
}
|
package/package.json
CHANGED
package/types/constant.d.ts
CHANGED
|
@@ -40,4 +40,5 @@ export declare const enum COS_ENDPOINT {
|
|
|
40
40
|
INTERNAL = "{Bucket}.cos-internal.{Region}.tencentcos.cn",
|
|
41
41
|
PUBLIC = "{Bucket}.cos.{Region}.tencentcos.cn"
|
|
42
42
|
}
|
|
43
|
-
export declare const COS_SDK_PROTOCOL
|
|
43
|
+
export declare const COS_SDK_PROTOCOL: string;
|
|
44
|
+
export declare const COS_SDK_KEEPALIVE: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function checkIsInScf(): boolean;
|
package/.vscode/settings.json
DELETED