Skip to content

Commit 9c79124

Browse files
committed
fix: update tencnet-component-toolkit for api mark
1 parent 1fcfddd commit 9c79124

File tree

7 files changed

+159
-14
lines changed

7 files changed

+159
-14
lines changed

README.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Tencent Koa Serverless Component
44

5-
[简体中文](./README.md) | English
5+
[简体中文](https://github.com/serverless-components/tencent-koa/tree/master/README.md) | English
66

77
## Introduction
88

@@ -32,7 +32,7 @@ $ touch sls.js
3232
$ touch serverless.yml
3333
```
3434

35-
Add the access keys of a [Tencent CAM Role](https://bash.cloud.tencent.com/cam/capi) with `AdministratorAccess` in the `.env` file, using this format:
35+
Add the access keys of a [Tencent CAM Role](https://console.cloud.tencent.com/cam/capi) with `AdministratorAccess` in the `.env` file, using this format:
3636

3737
```
3838
# .env
@@ -95,7 +95,7 @@ inputs:
9595
environment: release
9696
```
9797
98-
- [Click here to view the configuration document](/docs/configure.md)
98+
- [Click here to view the configuration document](https://github.com/serverless-components/tencent-koa/tree/master/docs/configure.md)
9999
100100
### 4. Deploy
101101

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# 腾讯云 Koa 组件
44

5-
简体中文 | [English](./README.en.md)
5+
简体中文 | [English](https://github.com/serverless-components/tencent-koa/tree/master/README.en.md)
66

77
## 简介
88

@@ -91,7 +91,7 @@ inputs:
9191
environment: release
9292
```
9393
94-
- [点击此处查看配置文档](/docs/configure.md)
94+
- [点击此处查看配置文档](https://github.com/serverless-components/tencent-koa/tree/master/docs/configure.md)
9595
9696
### 4. 部署
9797
@@ -127,7 +127,7 @@ $ touch .env # 腾讯云的配置信息
127127

128128
如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)
129129

130-
如果已有腾讯云账号,可以在[API 密钥管理](https://bash.cloud.tencent.com/cam/capi)中获取 `SecretId``SecretKey`.
130+
如果已有腾讯云账号,可以在[API 密钥管理](https://console.cloud.tencent.com/cam/capi)中获取 `SecretId``SecretKey`.
131131

132132
```
133133
# .env

example/README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
[![Serverless Koa Tencent Cloud](https://img.serverlesscloud.cn/20191226/1577361724216-koajs_width.png)](http://serverless.com)
2+
3+
# 腾讯云 Koa 组件
4+
5+
简体中文 | [English](https://github.com/serverless-components/tencent-koa/tree/master/README.en.md)
6+
7+
## 简介
8+
9+
使用腾讯云 Koa 组件,可快速的在腾讯云创建,配置和管理一个 [Koa 框架](https://koajs.com/) 服务。
10+
11+
## 目录
12+
13+
1. [安装](#1-安装)
14+
2. [创建](#2-创建)
15+
3. [配置](#3-配置)
16+
4. [部署](#4-部署)
17+
5. [移除](#5-移除)
18+
19+
### 1. 安装
20+
21+
通过 npm 安装 serverless
22+
23+
```bash
24+
$ npm install -g serverless
25+
```
26+
27+
### 2. 创建
28+
29+
本地创建 `serverless.yml` 文件:
30+
31+
```bash
32+
$ touch serverless.yml
33+
```
34+
35+
初始化一个新的 npm 包,并安装 koa:
36+
37+
```bash
38+
# 创建后持续回车
39+
$ npm init
40+
41+
# 安装 koa
42+
$ npm i --save koa
43+
```
44+
45+
创建一个 `sls.js`文件,并在其中创建您的 koa App:
46+
47+
```bash
48+
$ touch sls.js
49+
```
50+
51+
```js
52+
const koa = require('koa')
53+
const app = new koa()
54+
55+
app.use(async (ctx, next) => {
56+
if (ctx.path !== '/') return next()
57+
ctx.body = 'Hello from Koa'
58+
})
59+
60+
// set binary types
61+
// app.binaryTypes = [*/*];
62+
63+
// don't forget to export!
64+
module.exports = app
65+
```
66+
67+
### 3. 配置
68+
69+
在 serverless.yml 中进行如下配置
70+
71+
```yml
72+
# serverless.yml
73+
74+
org: orgDemo # (optional) serverless dashboard org. default is the first org you created during signup.
75+
app: appDemo # (optional) serverless dashboard app. default is the same as the name property.
76+
stage: dev # (optional) serverless dashboard stage. default is dev.
77+
component: koa # (required) name of the component. In that case, it's koa.
78+
name: koaDemo # (required) name of your koa component instance.
79+
80+
inputs:
81+
src:
82+
src: ./ # (optional) path to the source folder. default is a hello world app.
83+
exclude:
84+
- .env
85+
region: ap-guangzhou
86+
runtime: Nodejs10.15
87+
apigatewayConf:
88+
protocols:
89+
- http
90+
- https
91+
environment: release
92+
```
93+
94+
- [点击此处查看配置文档](https://github.com/serverless-components/tencent-koa/tree/master/docs/configure.md)
95+
96+
### 4. 部署
97+
98+
如您的账号未[登陆](https://cloud.tencent.com/login)或[注册](https://cloud.tencent.com/register)腾讯云,您可以直接通过`微信`扫描命令行中的二维码进行授权登陆和注册。
99+
100+
通过`sls`命令进行部署,并可以添加`--debug`参数查看部署过程中的信息
101+
102+
> 注:`sls`命令是`serverless`命令的缩写
103+
104+
```
105+
$ sls deploy
106+
```
107+
108+
部署完毕后,可以在浏览器中访问部署成功地 url。
109+
110+
### 5. 移除
111+
112+
通过以下命令移除部署的 Koa 服务。
113+
114+
```
115+
$ sls remove
116+
```
117+
118+
### 账号配置(可选)
119+
120+
当前默认支持 CLI 扫描二维码登录,如您希望配置持久的环境变量/秘钥信息,也可以本地创建 `.env` 文件
121+
122+
```bash
123+
$ touch .env # 腾讯云的配置信息
124+
```
125+
126+
`.env` 文件中配置腾讯云的 SecretId 和 SecretKey 信息并保存
127+
128+
如果没有腾讯云账号,可以在此[注册新账号](https://cloud.tencent.com/register)
129+
130+
如果已有腾讯云账号,可以在[API 密钥管理](https://bash.cloud.tencent.com/cam/capi)中获取 `SecretId``SecretKey`.
131+
132+
```
133+
# .env
134+
TENCENT_SECRET_ID=123
135+
TENCENT_SECRET_KEY=123
136+
```
137+
138+
### 还支持哪些组件?
139+
140+
可以在 [Serverless Components](https://github.com/serverless/components) repo 中查询更多组件的信息。
141+
142+
## License
143+
144+
MIT License
145+
146+
Copyright (c) 2020 Tencent Cloud, Inc.

example/serverless.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
org: orgDemo # (optional) serverless dashboard org. default is the first org you created during signup.
2-
app: appDemo # (optional) serverless dashboard app. default is the same as the name property.
3-
stage: dev # (optional) serverless dashboard stage. default is dev.
4-
component: koa # (required) name of the component. In that case, it's koa.
5-
name: koaDemo # (required) name of your koa component instance.
1+
org: orgDemo
2+
app: appDemo
3+
stage: dev
4+
component: koa
5+
name: koaDemo
66

77
inputs:
88
src:

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "@serverless/koa",
3-
"version": "0.0.9",
43
"main": "src/serverless.js",
54
"publishConfig": {
65
"access": "public"

serverless.component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: koa
2-
version: 0.0.10
2+
version: 0.0.11
33
author: Tencent Cloud, Inc.
44
org: Tencent Cloud, Inc.
55
description: Deploy a serverless Koa.js application onto 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.15.7",
4+
"tencent-component-toolkit": "^1.16.2",
55
"type": "^2.0.0"
66
}
77
}

0 commit comments

Comments
 (0)