Skip to content

Commit 78ca266

Browse files
committed
feat: support apigw base64 encode
1 parent aedd8b7 commit 78ca266

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

docs/configure.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ inputs:
6161
- https
6262
environment: test
6363
serviceTimeout: 15
64+
isBase64Encoded: false
6465
usagePlan: # 用户使用计划
6566
usagePlanId: 1111
6667
usagePlanName: slscmp
@@ -151,16 +152,17 @@ inputs:
151152

152153
### API 网关配置
153154

154-
| 参数名称 | 是否必选 | 类型 | 默认值 | 描述 |
155-
| -------------- | :------: | :------- | :--------- | :--------------------------------------------------------------------------------- |
156-
| protocols | 否 | String[] | `['http']` | 前端请求的类型,如 http,https,http 与 https |
157-
| environment | 否 | String | `release` | 发布环境. 目前支持三种发布环境: test(测试), prepub(预发布) 与 release(发布). |
158-
| usagePlan | 否 | | | 使用计划配置, 参考 [使用计划](#使用计划) |
159-
| auth | 否 | | | API 密钥配置, 参考 [API 密钥](#API-密钥配置) |
160-
| customDomain | 否 | Object[] | | 自定义 API 域名配置, 参考 [自定义域名](#自定义域名) |
161-
| enableCORS | 否 | Boolean | `false` | 开启跨域。默认值为否。 |
162-
| serviceTimeout | 否 | Number | `15` | Api 超时时间,单位: 秒 |
163-
| isDisabled | 否 | Boolean | `false` | 关闭自动创建 API 网关功能。默认值为否,即默认自动创建 API 网关。 |
155+
| 参数名称 | 是否必选 | 类型 | 默认值 | 描述 |
156+
| --------------- | :------: | :------- | :--------- | :--------------------------------------------------------------------------------- |
157+
| protocols | 否 | String[] | `['http']` | 前端请求的类型,如 http,https,http 与 https |
158+
| environment | 否 | String | `release` | 发布环境. 目前支持三种发布环境: test(测试), prepub(预发布) 与 release(发布). |
159+
| usagePlan | 否 | | | 使用计划配置, 参考 [使用计划](#使用计划) |
160+
| auth | 否 | | | API 密钥配置, 参考 [API 密钥](#API-密钥配置) |
161+
| customDomain | 否 | Object[] | | 自定义 API 域名配置, 参考 [自定义域名](#自定义域名) |
162+
| enableCORS | 否 | Boolean | `false` | 开启跨域。默认值为否。 |
163+
| serviceTimeout | 否 | Number | `15` | Api 超时时间,单位: 秒 |
164+
| isDisabled | 否 | Boolean | `false` | 关闭自动创建 API 网关功能。默认值为否,即默认自动创建 API 网关。 |
165+
| isBase64Encoded | 否 | Boolean | `false` | 是否开启 Base64 编码,如果需要文件上传,请配置为 `true` |
164166

165167
##### 使用计划
166168

docs/output.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
>
55
> 例如,如果该组件名称是 `test_name`, ·且只部署于一个地域,则可以通过 `${output:${stage}:${app}:test_name.apigw.url}` 在别的组件中获取该组件的 API 网关的 `url`
66
7-
| 名称 | 类型 | 描述 |
8-
| :---------- | :-------------: | :----------------------------------------------------- | ---------------- |
9-
| templateUrl | string | 未提供代码时的模板代码 url |
10-
| region | string | 地域信息(只有一个地域时才提供) |
11-
| scf | [`FunctionOutput | Record<string,FunctionOutput>`](#云函数输出-`FunctionOutput`) | 云函数输出信息 |
12-
| apigw | [`ApigwOutput | Record<string:ApigwOutput>`](#API-网关输出-`ApigwOutput`) | API 网关输出信息 |
7+
| 名称 | 类型 | 描述 |
8+
| :---------- | :------------------------------------------------------------------------------: | :------------------------------- |
9+
| templateUrl | string | 未提供代码时的模板代码 url |
10+
| region | string | 地域信息(只有一个地域时才提供) |
11+
| scf | [`FunctionOutput | Record<string,FunctionOutput>`](#云函数输出-`FunctionOutput`) | 云函数输出信息 |
12+
| apigw | [`ApigwOutput | Record<string:ApigwOutput>`](#API-网关输出-`ApigwOutput`) | API 网关输出信息 |
1313

1414
## 云函数输出 `FunctionOutput`
1515

@@ -25,25 +25,23 @@
2525
## API 网关输出 `ApigwOutput`
2626

2727
| 名称 | 类型 | 描述 |
28-
| :------------ | :------------------------------------------------------------------: | :------------------------- | ------- | -------- |
28+
| :------------ | :------------------------------------------------------------------: | :------------------------- |
2929
| serviceId | string | API 网关 ID |
3030
| subDomain | string | API 网关子域名 |
31-
| enviroment | `"release" | "prepub" | "test"` | API 网关 |
31+
| enviroment | `"release" | "prepub" | "test"` | API 网关 |
3232
| url | string | API 网关对外的完整 URL |
3333
| traffic | number (0~1) | 将多少流量导向该云函数 |
3434
| customDomains | [CustomDomain[]](#API-网关自定义域名输出-`ApigwOutput.CustomDomain`) | API 网关自定义域名输出列表 |
3535

3636
## API 网关自定义域名输出 `ApigwOutput.CustomDomain`
3737

3838
| 名称 | 类型 | 描述 |
39-
| :--------------- | :----------------------------------------------------------------: | :------------------------- | ---------- |
39+
| :--------------- | :----------------------------------------------------------------: | :------------------------- |
4040
| domain | string | 自定义域名 |
4141
| certificateId | string | 域名证书 ID |
4242
| isDefaultMapping | boolean | 该自定义域名是否为默认域名 |
4343
| pathMappingSet | [PathMapping[]](#-API-网关域名映射规则-`CustomDomain.PathMapping`) | 该域名的路径映射规则列表 |
44-
| protocols | `"http" | "https"` | 启用的协议 |
45-
46-
44+
| protocols | `"http" | "https"` | 启用的协议 |
4745

4846
## API 网关域名映射规则 `CustomDomain.PathMapping`
4947

serverless.component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: express
2-
version: 0.2.3
2+
version: 0.3.0
33
author: Tencent Cloud, Inc.
44
org: Tencent Cloud, Inc.
55
description: Deploy a serverless Express.js application on Tencent SCF and API Gateway.

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dependencies": {
33
"download": "^8.0.0",
4-
"tencent-component-toolkit": "^1.20.6",
4+
"tencent-component-toolkit": "^1.20.10",
55
"type": "^2.0.0"
66
}
77
}

src/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ const prepareInputs = async (instance, credentials, inputs = {}) => {
281281
serviceTimeout: tempApigwConf.serviceTimeout,
282282
method: 'ANY',
283283
apiName: tempApigwConf.apiName || 'index',
284+
isBase64Encoded: tempApigwConf.isBase64Encoded,
285+
isBase64Trigger: tempApigwConf.isBase64Trigger,
286+
base64EncodedTriggerRules: tempApigwConf.base64EncodedTriggerRules,
284287
function: {
285288
isIntegratedResponse: true,
286289
functionName: functionConf.name,

0 commit comments

Comments
 (0)