/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/serverless-nestjs-for-tencent@1.1.4/serverless.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const path=require("path"),{Component:Component,utils:utils}=require("@serverless/core"),random=require("ext/string/random"),ensureString=require("type/string/ensure"),ensureIterable=require("type/iterable/ensure"),ensurePlainObject=require("type/plain-object/ensure"),resolveCachedHandlerPath=require("./lib/resolve-cached-handler-path");class TencentExpress extends Component{getDefaultProtocol(e){return e.map((e=>e.toLowerCase())).includes("https")?"https":"http"}async default(e={}){e.name=ensureString(e.functionName,{isOptional:!0})||this.state.functionName||`ExpressComponent_${random({length:6})}`,e.codeUri=ensureString(e.codeUri,{isOptional:!0})||process.cwd(),e.region=ensureString(e.region,{default:"ap-guangzhou"}),e.namespace=ensureString(e.namespace,{default:"default"}),e.include=ensureIterable(e.include,{default:[],ensureItem:ensureString}),e.exclude=ensureIterable(e.exclude,{default:[],ensureItem:ensureString}),e.apigatewayConf=ensurePlainObject(e.apigatewayConf,{default:{}});const n=path.resolve(e.codeUri+"/dist","index.js");if(!await utils.fileExists(n))throw new Error(`index.js not found in ${e.codeUri}/dist`);const t=await resolveCachedHandlerPath(e);e.include.push(t),e.exclude.push(".git/**",".gitignore",".serverless",".DS_Store"),e.handler=`${path.basename(t,".js")}.handler`,e.runtime="Nodejs8.9";const a=await this.load("@serverless/tencent-scf");e.functionConf&&(e.timeout=e.functionConf.timeout?e.functionConf.timeout:3,e.memorySize=e.functionConf.memorySize?e.functionConf.memorySize:128,e.functionConf.environment&&(e.environment=e.functionConf.environment),e.functionConf.vpcConfig&&(e.vpcConfig=e.functionConf.vpcConfig)),e.fromClientRemark=e.fromClientRemark||"tencent-express";const o=await a(e),i={region:e.region,functionName:e.name};if(!e.apigatewayConf.isDisabled){const n=await this.load("@serverless/tencent-apigateway"),t={serviceName:e.serviceName,description:"Serverless Framework tencent-express Component",serviceId:e.serviceId,region:e.region,protocols:e.apigatewayConf&&e.apigatewayConf.protocols?e.apigatewayConf.protocols:["http"],environment:e.apigatewayConf&&e.apigatewayConf.environment?e.apigatewayConf.environment:"release",endpoints:[{path:"/",method:"ANY",function:{isIntegratedResponse:!0,functionName:o.Name,functionNamespace:e.namespace}}],customDomain:e.apigatewayConf.customDomain};e.apigatewayConf&&e.apigatewayConf.usagePlan&&(t.endpoints[0].usagePlan=e.apigatewayConf.usagePlan),e.apigatewayConf&&e.apigatewayConf.auth&&(t.endpoints[0].auth=e.apigatewayConf.auth),t.fromClientRemark=e.fromClientRemark||"tencent-express";const a=await n(t);i.apiGatewayServiceId=a.serviceId,i.url=`${this.getDefaultProtocol(a.protocols)}://${a.subDomain}/${a.environment}/`,a.customDomains&&(i.customDomains=a.customDomains)}return i}async remove(e={}){const n={fromClientRemark:e.fromClientRemark||"tencent-express"},t=await this.load("@serverless/tencent-scf"),a=await this.load("@serverless/tencent-apigateway");return await t.remove(n),await a.remove(n),{}}}module.exports=TencentExpress;
//# sourceMappingURL=/sm/c1df16d5a75af3ac1c0b4c0bf985d07eef7c1a3f0aece9ecbecd5eab7aeb86cd.map