Skip to content

Commit 15805a6

Browse files
committed
fix: support all parameters for apigw
1 parent aaaae9d commit 15805a6

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

serverless.component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: nuxtjs
2-
version: 0.1.4
2+
version: 0.1.5
33
author: 'Tencent Cloud, Inc.'
44
org: 'Tencent Cloud, Inc.'
55
description: Deploy a serverless Nuxt.js application onto Tencent SCF and API Gateway.

src/serverless.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ServerlessComopnent extends Component {
159159
environment: apigwOutput.environment,
160160
url: `${getDefaultProtocol(inputs.protocols)}://${apigwOutput.subDomain}/${
161161
apigwOutput.environment
162-
}/`
162+
}${apigwInputs.endpoints[0].path}`
163163
}
164164

165165
if (apigwOutput.customDomains) {

src/utils.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,11 @@ const prepareStaticCdnInputs = async (instance, inputs, origin) => {
314314
}
315315

316316
const prepareInputs = async (instance, credentials, inputs = {}) => {
317-
// 对function inputs进行标准化
318-
const tempFunctionConf = inputs.functionConf ? inputs.functionConf : {}
317+
const tempFunctionConf = inputs.functionConf
318+
? inputs.functionConf
319+
: inputs.functionConfig
320+
? inputs.functionConfig
321+
: {}
319322
const fromClientRemark = `tencent-${CONFIGS.compName}`
320323
const regionList = inputs.region
321324
? typeof inputs.region == 'string'
@@ -396,32 +399,40 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
396399
functionConf.vpcConfig = tempFunctionConf.vpcConfig
397400
}
398401

399-
// 对apigw inputs进行标准化
400-
const tempApigwConf = inputs.apigatewayConf ? inputs.apigatewayConf : {}
402+
const tempApigwConf = inputs.apigatewayConf
403+
? inputs.apigatewayConf
404+
: inputs.apigwConfig
405+
? inputs.apigwConfig
406+
: {}
401407
const apigatewayConf = Object.assign(tempApigwConf, {
402-
serviceId: inputs.serviceId,
408+
serviceId: inputs.serviceId || tempApigwConf.serviceId,
403409
region: regionList,
404410
isDisabled: tempApigwConf.isDisabled === true,
405411
fromClientRemark: fromClientRemark,
406-
serviceName: inputs.serviceName || getDefaultServiceName(instance),
407-
description: getDefaultServiceDescription(instance),
412+
serviceName: inputs.serviceName || tempApigwConf.serviceName || getDefaultServiceName(instance),
413+
serviceDesc: tempApigwConf.serviceDesc || getDefaultServiceDescription(instance),
408414
protocols: tempApigwConf.protocols || ['http'],
409415
environment: tempApigwConf.environment ? tempApigwConf.environment : 'release',
410-
endpoints: [
416+
customDomains: tempApigwConf.customDomains || []
417+
})
418+
if (!apigatewayConf.endpoints) {
419+
apigatewayConf.endpoints = [
411420
{
412-
path: '/',
421+
path: tempApigwConf.path || '/',
413422
enableCORS: tempApigwConf.enableCORS,
414423
serviceTimeout: tempApigwConf.serviceTimeout,
415424
method: 'ANY',
425+
apiName: tempApigwConf.apiName || 'index',
416426
function: {
417427
isIntegratedResponse: true,
418428
functionName: functionConf.name,
419-
functionNamespace: functionConf.namespace
429+
functionNamespace: functionConf.namespace,
430+
functionQualifier:
431+
(tempApigwConf.function && tempApigwConf.function.functionQualifier) || '$LATEST'
420432
}
421433
}
422-
],
423-
customDomains: tempApigwConf.customDomains || []
424-
})
434+
]
435+
}
425436
if (tempApigwConf.usagePlan) {
426437
apigatewayConf.endpoints[0].usagePlan = {
427438
usagePlanId: tempApigwConf.usagePlan.usagePlanId,

0 commit comments

Comments
 (0)