Skip to content

Commit

Permalink
feat(runtime): support multi-level uri of cloud function (#1203)
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow authored May 31, 2023
1 parent 2fed138 commit df478bf
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 31 deletions.
23 changes: 0 additions & 23 deletions runtimes/nodejs/env.sh

This file was deleted.

18 changes: 17 additions & 1 deletion runtimes/nodejs/src/handler/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,20 @@ router.get('/_/healthz', (_req, res) => res.status(200).send('ok'))
* Invoke cloud function through HTTP request.
* @method *
*/
router.all('/:name', uploader.any(), handleInvokeFunction)
// router.all('/:name', uploader.any(), handleInvokeFunction)
router.all('*', uploader.any(), (req, res) => {
let func_name = req.path

// remove the leading slash
if (func_name.startsWith('/')) {
func_name = func_name.slice(1)
}

// check length
if (func_name.length > 256) {
return res.status(500).send('function name is too long')
}

req.params['name'] = func_name
handleInvokeFunction(req, res)
})
2 changes: 2 additions & 0 deletions runtimes/python/TBD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

> TBD
1 change: 1 addition & 0 deletions server/src/account/account.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class AccountController {
async findOne(@Req() req: IRequest) {
const user = req.user
const data = await this.accountService.findOne(user._id)
data.balance = Math.floor(data.balance)
return ResponseUtil.ok(data)
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/function/dto/create-function.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CreateFunctionDto {
description: 'Function name is unique in the application',
})
@IsNotEmpty()
@Matches(/^[a-zA-Z0-9_.-]{1,128}$/)
@Matches(/^[a-zA-Z0-9_.-\/]{1,256}$/)
name: string

@ApiPropertyOptional()
Expand Down
4 changes: 2 additions & 2 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"SystemDependence": "内置依赖",
"Value": "",
"isSupport": "是否支持",
"FunctionNameRule": "函数名须由字母、数字、点(.)和划线(-_)组成,匹配正则:/^[a-zA-Z0-9_.-]{1,128}$/",
"FunctionNameRule": "函数名须由字母、数字、点(.)和划线(-_)组成,匹配正则:/^[a-zA-Z0-9_.-\/]{1,256}$/",
"EmptyDebugTip": "暂无运行结果",
"EmptyFunctionTip": "您还没有创建函数",
"UploadButton": "上传",
Expand Down Expand Up @@ -439,4 +439,4 @@
"CostTime": "扣费时间",
"Duration": "计费周期",
"TotalAmount": "总费用"
}
}
4 changes: 2 additions & 2 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"SystemDependence": "内置依赖",
"Value": "",
"isSupport": "是否支持",
"FunctionNameRule": "函数名须由字母、数字、点(.)和划线(-_)组成,匹配正则:/^[a-zA-Z0-9_.-]{1,128}$/",
"FunctionNameRule": "函数名须由字母、数字、点(.)和划线(-_)组成,匹配正则:/^[a-zA-Z0-9_.-\/]{1,256}$/",
"EmptyDebugTip": "暂无运行结果",
"EmptyFunctionTip": "您还没有创建函数",
"UploadButton": "上传",
Expand Down Expand Up @@ -440,4 +440,4 @@
"Duration": "计费周期",
"State": "状态",
"TotalAmount": "总费用"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const PromptModal = (props: {
<Input
{...register("name", {
pattern: {
value: /^[a-zA-Z0-9_.-]{1,128}$/,
value: /^[a-zA-Z0-9_.-\/]{1,256}$/,
message: t("FunctionPanel.FunctionNameRule"),
},
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const CreateModal = (props: {
<Input
{...register("name", {
pattern: {
value: /^[a-zA-Z0-9_.-]{1,128}$/,
value: /^[a-zA-Z0-9_.-\/]{1,256}$/,
message: t("FunctionPanel.FunctionNameRule"),
},
})}
Expand Down

0 comments on commit df478bf

Please sign in to comment.