UNPKG

@cloudbase/node-sdk

Version:

tencent cloud base server sdk for node.js

24 lines (23 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildCommonOpenApiUrlWithPath = exports.buildUrl = void 0; const ZONE_CHINA = ['ap-shanghai', 'ap-guangzhou', 'ap-shenzhen-fsi', 'ap-shanghai-fsi', 'ap-nanjing', 'ap-beijing', 'ap-chengdu', 'ap-chongqing', 'ap-hongkong']; /* eslint-disable complexity */ function buildUrl(options) { const endpoint = `https://${getGatewayUrl(options)}/v1/cloudrun/${options.name}`; const path = options.path.startsWith('/') ? options.path : `/${options.path}`; return `${endpoint}${path}`; } exports.buildUrl = buildUrl; function buildCommonOpenApiUrlWithPath(options) { return `${options.protocol || 'https'}://${options.serviceUrl || getGatewayUrl(options)}${options.path}`; } exports.buildCommonOpenApiUrlWithPath = buildCommonOpenApiUrlWithPath; function getGatewayUrl(options) { const region = options.region || 'ap-shanghai'; let baseUrl = `${options.envId}.api.tcloudbasegateway.com`; if (!ZONE_CHINA.includes(region)) { baseUrl = `${options.envId}.api.intl.tcloudbasegateway.com`; } return baseUrl; }