Skip to content

Commit ec3ffc7

Browse files
committed
fix: support all parameters for apigw
1 parent 80e2890 commit ec3ffc7

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/serverless.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class ServerlessComponent extends Component {
152152
environment: apigwOutput.environment,
153153
url: `${getDefaultProtocol(inputs.protocols)}://${apigwOutput.subDomain}/${
154154
apigwOutput.environment
155-
}/`
155+
}${apigwInputs.endpoints[0].path}`
156156
}
157157

158158
if (apigwOutput.customDomains) {

src/utils.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ const uploadCodeToCos = async (instance, appId, credentials, inputs, region) =>
170170

171171
const prepareInputs = async (instance, credentials, inputs = {}) => {
172172
// 对function inputs进行标准化
173-
const tempFunctionConf = inputs.functionConf ? inputs.functionConf : {}
173+
const tempFunctionConf = inputs.functionConf
174+
? inputs.functionConf
175+
: inputs.functionConfig
176+
? inputs.functionConfig
177+
: {}
174178
const fromClientRemark = `tencent-${CONFIGS.compName}`
175179
const regionList = inputs.region
176180
? typeof inputs.region == 'string'
@@ -253,22 +257,30 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
253257
}
254258

255259
// 对apigw inputs进行标准化
256-
const tempApigwConf = inputs.apigatewayConf ? inputs.apigatewayConf : {}
260+
const tempApigwConf = inputs.apigatewayConf
261+
? inputs.apigatewayConf
262+
: inputs.apigwConfig
263+
? inputs.apigwConfig
264+
: {}
257265
const apigatewayConf = Object.assign(tempApigwConf, {
258-
serviceId: inputs.serviceId,
266+
serviceId: inputs.serviceId || tempApigwConf.serviceId,
259267
region: regionList,
260268
isDisabled: tempApigwConf.isDisabled === true,
261269
fromClientRemark: fromClientRemark,
262-
serviceName: inputs.serviceName || getDefaultServiceName(instance),
263-
description: getDefaultServiceDescription(instance),
270+
serviceName: inputs.serviceName || tempApigwConf.serviceName || getDefaultServiceName(instance),
271+
serviceDesc: tempApigwConf.serviceDesc || getDefaultServiceDescription(instance),
264272
protocols: tempApigwConf.protocols || ['http'],
265273
environment: tempApigwConf.environment ? tempApigwConf.environment : 'release',
266-
endpoints: [
274+
customDomains: tempApigwConf.customDomains || []
275+
})
276+
if (!apigatewayConf.endpoints) {
277+
apigatewayConf.endpoints = [
267278
{
268-
path: '/',
279+
path: tempApigwConf.path || '/',
269280
enableCORS: tempApigwConf.enableCORS,
270281
serviceTimeout: tempApigwConf.serviceTimeout,
271282
method: 'ANY',
283+
apiName: tempApigwConf.apiName || 'index',
272284
function: {
273285
isIntegratedResponse: true,
274286
functionName: functionConf.name,
@@ -277,9 +289,8 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
277289
(tempApigwConf.function && tempApigwConf.function.functionQualifier) || '$LATEST'
278290
}
279291
}
280-
],
281-
customDomains: tempApigwConf.customDomains || []
282-
})
292+
]
293+
}
283294
if (tempApigwConf.usagePlan) {
284295
apigatewayConf.endpoints[0].usagePlan = {
285296
usagePlanId: tempApigwConf.usagePlan.usagePlanId,

0 commit comments

Comments
 (0)