Skip to content

Commit c3efa96

Browse files
committed
fix: support all parameters for apigw
1 parent 38a93c4 commit c3efa96

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Diff for: serverless.component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: koa
2-
version: 0.2.0
2+
version: dev
33
author: 'Tencent Cloud, Inc.'
44
org: 'Tencent Cloud, Inc.'
55
description: Deploy a serverless Koa.js application onto Tencent SCF and API Gateway.

Diff for: src/serverless.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class ServerlessComponent extends Component {
140140
environment: apigwOutput.environment,
141141
url: `${getDefaultProtocol(inputs.protocols)}://${apigwOutput.subDomain}/${
142142
apigwOutput.environment
143-
}/`
143+
}${apigwInputs.endpoints[0].path}`
144144
}
145145

146146
if (apigwOutput.customDomains) {

Diff for: src/utils.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,18 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
263263
? inputs.apigwConfig
264264
: {}
265265
const apigatewayConf = Object.assign(tempApigwConf, {
266-
serviceId: inputs.serviceId,
266+
serviceId: inputs.serviceId || tempApigwConf.serviceId,
267267
region: regionList,
268268
isDisabled: tempApigwConf.isDisabled === true,
269269
fromClientRemark: fromClientRemark,
270-
serviceName: inputs.serviceName || getDefaultServiceName(instance),
271-
description: tempApigwConf.description || getDefaultServiceDescription(instance),
270+
serviceName: inputs.serviceName || tempApigwConf.serviceName || getDefaultServiceName(instance),
271+
serviceDesc: tempApigwConf.serviceDesc || getDefaultServiceDescription(instance),
272272
protocols: tempApigwConf.protocols || ['http'],
273273
environment: tempApigwConf.environment ? tempApigwConf.environment : 'release',
274-
endpoints: [
274+
customDomains: tempApigwConf.customDomains || []
275+
})
276+
if (!apigatewayConf.endpoints) {
277+
apigatewayConf.endpoints = [
275278
{
276279
path: tempApigwConf.path || '/',
277280
enableCORS: tempApigwConf.enableCORS,
@@ -286,9 +289,8 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
286289
(tempApigwConf.function && tempApigwConf.function.functionQualifier) || '$LATEST'
287290
}
288291
}
289-
],
290-
customDomains: tempApigwConf.customDomains || []
291-
})
292+
]
293+
}
292294
if (tempApigwConf.usagePlan) {
293295
apigatewayConf.endpoints[0].usagePlan = {
294296
usagePlanId: tempApigwConf.usagePlan.usagePlanId,

0 commit comments

Comments
 (0)