Skip to content

Commit 8109ed0

Browse files
Rong5180rongxwang
andauthored
fix: change outputs (#82)
* fix: change outputs * fix: 修改版本 Co-authored-by: rongxwang <rongxwang@tencent.com>
1 parent f8a1359 commit 8109ed0

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

serverless.component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: scf
2-
version: 0.8.6
2+
version: 0.9.0
33
author: Tencent Cloud, Inc.
44
org: Tencent Cloud, Inc.
55
description: 单函数组件,允许用户开发部署单个腾讯 SCF 函数实例。适合进行单一函数开发的场景。如:定时触发任务。

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"dependencies": {
33
"adm-zip": "^0.5.5",
44
"download": "^8.0.0",
5-
"tencent-component-toolkit": "^2.22.0",
5+
"tencent-component-toolkit": "^2.22.1",
66
"type": "^2.0.0"
77
}
88
}

src/serverless.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ class ServerlessComponent extends Component {
136136
if (getType(item.subDomain) === 'Array') {
137137
item.subDomain.forEach((domain) => {
138138
item.urls.push(
139-
`${getDefaultProtocol(item.protocols)}://${domain}/${item.environment}${
139+
`${getDefaultProtocol(item.protocols, inputs)}://${domain}/${item.environment}${
140140
apiItem.path
141141
}`
142142
)
143143
})
144144
} else {
145145
item.urls.push(
146-
`${getDefaultProtocol(item.protocols)}://${item.subDomain}/${item.environment}${
147-
apiItem.path
148-
}`
146+
`${getDefaultProtocol(item.protocols, inputs)}://${item.subDomain}/${
147+
item.environment
148+
}${apiItem.path}`
149149
)
150150
}
151151
})

src/utils.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ const validateTraffic = (num) => {
4040
return true
4141
}
4242

43-
const getDefaultProtocol = (protocols) => {
43+
const getDefaultProtocol = (protocols, inputs) => {
44+
if (inputs && inputs.protocolType === 'WS' && inputs.type === 'web') {
45+
return 'ws'
46+
}
4447
return String(protocols).includes('https') ? 'https' : 'http'
4548
}
4649

@@ -188,7 +191,7 @@ const formatInputs = async (instance, credentials, appId, inputs) => {
188191
inputs.publish = false
189192
}
190193
// 如果是ws函数,protocolType置为WEBSOCKET
191-
if (inputs.protocolType === 'WS' || inputs.type === 'web') {
194+
if (inputs.protocolType === 'WS' && inputs.type === 'web') {
192195
inputs.events &&
193196
inputs.events.forEach((v) => {
194197
v.apigw.parameters.endpoints &&
@@ -197,7 +200,7 @@ const formatInputs = async (instance, credentials, appId, inputs) => {
197200
})
198201
})
199202
}
200-
203+
201204
// 基于镜像部署
202205
let imageCode
203206
if (inputs.image) {
@@ -272,8 +275,8 @@ const formatInputs = async (instance, credentials, appId, inputs) => {
272275
getDefaultServiceName(instance)
273276

274277
let { serviceId } = currentEvent.parameters
275-
currentEvent.parameters.isInputServiceId = !!serviceId
276-
currentEvent.parameters.serviceName = serviceName
278+
// currentEvent.parameters.isInputServiceId = !!serviceId
279+
// currentEvent.parameters.serviceName = serviceName
277280
currentEvent.parameters.description =
278281
currentEvent.parameters.description || getDefaultServiceDescription(instance)
279282
currentEvent.name = currentEvent.name || getDefaultTriggerName(eventType, instance)

0 commit comments

Comments
 (0)