Skip to content

Commit bc59958

Browse files
committed
docs: update readme
1 parent 699d509 commit bc59958

File tree

2 files changed

+49
-165
lines changed

2 files changed

+49
-165
lines changed

README.en.md

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

33
# Tencent Koa Serverless Component
44

5-
[![npm](https://img.shields.io/npm/v/%40serverless%2Ftencent-koa)](http://www.npmtrends.com/%40serverless%2Ftencent-koa)
6-
[![NPM downloads](http://img.shields.io/npm/dm/%40serverless%2Ftencent-koa.svg?style=flat-square)](http://www.npmtrends.com/%40serverless%2Ftencent-koa)
7-
8-
[简体中文](https://github.com/serverless-components/tencent-koa/blob/master/README.md) | English
5+
[简体中文](https://github.com/serverless-components/tencent-koa/blob/v2/README.md) | English
96

107
## Introduction
118

@@ -31,7 +28,7 @@ Just create `serverless.yml` and `.env` files
3128

3229
```console
3330
$ touch .env # your Tencent API Keys
34-
$ touch app.js
31+
$ touch sls.js
3532
$ touch serverless.yml
3633
```
3734

@@ -52,7 +49,7 @@ npm init # then keep hitting enter
5249
npm i --save koa # install koa
5350
```
5451

55-
create your koa app in `app.js`:
52+
create your koa app in `sls.js`:
5653

5754
```js
5855
const koa = require('koa')
@@ -75,95 +72,40 @@ module.exports = app
7572
```yml
7673
# serverless.yml
7774

78-
koa:
79-
component: '@serverless/tencent-koa'
80-
inputs:
81-
region: ap-guangzhou
82-
functionName: koa-function
83-
runtime: Nodejs8.9
84-
code: ./
85-
functionConf:
86-
timeout: 10
87-
memorySize: 128
88-
environment:
89-
variables:
90-
TEST: vale
91-
apigatewayConf:
92-
protocols:
93-
- https
94-
environment: release
75+
org: orgDemo # (optional) serverless dashboard org. default is the first org you created during signup.
76+
app: appDemo # (optional) serverless dashboard app. default is the same as the name property.
77+
stage: dev # (optional) serverless dashboard stage. default is dev.
78+
component: koa # (required) name of the component. In that case, it's koa.
79+
name: koaDemo # (required) name of your koa component instance.
80+
81+
inputs:
82+
src:
83+
src: ./src # (optional) path to the source folder. default is a hello world app.
84+
exclude:
85+
- .env
86+
region: ap-guangzhou
87+
runtime: Nodejs10.15
88+
apigatewayConf:
89+
protocols:
90+
- http
91+
- https
92+
environment: release
9593
```
9694
97-
- [Click here to view the configuration document](https://github.com/serverless-components/tencent-koa/blob/master/docs/configure.md)
95+
- [Click here to view the configuration document](https://github.com/serverless-components/tencent-koa/blob/v2/docs/configure.md)
9896
9997
### 4. Deploy
10098
10199
```
102-
$ sls --debug
103-
104-
DEBUG ─ Resolving the template's static variables.
105-
DEBUG ─ Collecting components from the template.
106-
DEBUG ─ Downloading any NPM components found in the template.
107-
DEBUG ─ Analyzing the template's components dependencies.
108-
DEBUG ─ Creating the template's components graph.
109-
DEBUG ─ Syncing template state.
110-
DEBUG ─ Executing the template's components graph.
111-
DEBUG ─ Generating serverless handler...
112-
DEBUG ─ Generated serverless handler successfully.
113-
DEBUG ─ Compressing function koa-function file to /Users/yugasun/Desktop/Develop/serverless/tencent-koa/example/.serverless/koa-function.zip.
114-
DEBUG ─ Compressed function koa-function file successful
115-
DEBUG ─ Uploading service package to cos[sls-cloudfunction-ap-guangzhou-code]. sls-cloudfunction-default-koa-function-1584364164.zip
116-
koa-function [████████████████████████████████████████] 100% | ETA: 0s | Speed: 923.87k/s
117-
DEBUG ─ Uploaded package successful /Users/yugasun/Desktop/Develop/serverless/tencent-koa/example/.serverless/koa-function.zip
118-
DEBUG ─ Creating function koa-function
119-
DEBUG ─ Updating code...
120-
DEBUG ─ Updating configure...
121-
DEBUG ─ Created function koa-function successful
122-
DEBUG ─ Setting tags for function koa-function
123-
DEBUG ─ Creating trigger for function koa-function
124-
DEBUG ─ Deployed function koa-function successful
125-
DEBUG ─ Starting API-Gateway deployment with name ap-guangzhou-apigateway in the ap-guangzhou region
126-
DEBUG ─ Using last time deploy service id service-pnlxadhq
127-
DEBUG ─ Updating service with serviceId service-pnlxadhq.
128-
DEBUG ─ Endpoint ANY / already exists with id api-9415bswy.
129-
DEBUG ─ Updating api with api id api-9415bswy.
130-
DEBUG ─ Service with id api-9415bswy updated.
131-
DEBUG ─ Deploying service with id service-pnlxadhq.
132-
DEBUG ─ Deployment successful for the api named ap-guangzhou-apigateway in the ap-guangzhou region.
133-
134-
koa:
135-
functionName: koa-function
136-
functionOutputs:
137-
ap-guangzhou:
138-
Name: koa-function
139-
Runtime: Nodejs8.9
140-
Handler: serverless-handler.handler
141-
MemorySize: 128
142-
Timeout: 10
143-
Region: ap-guangzhou
144-
Namespace: default
145-
Description: This is a template function
146-
region: ap-guangzhou
147-
apiGatewayServiceId: service-pnlxadhq
148-
url: https://service-pnlxadhq-1251556596.gz.apigw.tencentcs.com/release/
149-
cns: (empty array)
150-
151-
36s › koa › done
100+
$ sls deploy
152101
```
153102

154103
You can now visit the output URL in the browser, and you should see the koa response.
155104

156105
### 5. Remove
157106

158107
```
159-
$ sls remove --debug
160-
161-
DEBUG ─ Flushing template state and removing all components.
162-
DEBUG ─ Removed function koa-function successful
163-
DEBUG ─ Removing any previously deployed API. api-9415bswy
164-
DEBUG ─ Removing any previously deployed service. service-pnlxadhq
165-
166-
14s › koa › done
108+
$ sls remove
167109
```
168110

169111
### New to Components?

README.md

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

33
# 腾讯云 Koa 组件
44

5-
[![npm](https://img.shields.io/npm/v/%40serverless%2Ftencent-koa)](http://www.npmtrends.com/%40serverless%2Ftencent-koa)
6-
[![NPM downloads](http://img.shields.io/npm/dm/%40serverless%2Ftencent-koa.svg?style=flat-square)](http://www.npmtrends.com/%40serverless%2Ftencent-koa)
7-
8-
简体中文 | [English](https://github.com/serverless-components/tencent-koa/blob/master/README.en.md)
5+
简体中文 | [English](https://github.com/serverless-components/tencent-koa/blob/v2/README.en.md)
96

107
## 简介
118

@@ -29,7 +26,7 @@ $ npm install -g serverless
2926

3027
### 2. 创建
3128

32-
本地创建 `serverless.yml` 文件和 `app.js`文件:
29+
本地创建 `serverless.yml` 文件:
3330

3431
```console
3532
$ touch serverless.yml
@@ -42,10 +39,10 @@ npm init # 创建后持续回车
4239
npm i --save koa # 安装 koa
4340
```
4441

45-
创建一个 `app.js`文件,并在其中创建您的 koa App:
42+
创建一个 `sls.js`文件,并在其中创建您的 koa App:
4643

4744
```console
48-
$ touch app.js
45+
$ touch sls.js
4946
```
5047

5148
```js
@@ -71,26 +68,27 @@ module.exports = app
7168
```yml
7269
# serverless.yml
7370

74-
koa:
75-
component: '@serverless/tencent-koa'
76-
inputs:
77-
region: ap-guangzhou
78-
functionName: koa-function
79-
runtime: Nodejs8.9
80-
code: ./
81-
functionConf:
82-
timeout: 10
83-
memorySize: 128
84-
environment:
85-
variables:
86-
TEST: vale
87-
apigatewayConf:
88-
protocols:
89-
- https
90-
environment: release
71+
org: orgDemo # (optional) serverless dashboard org. default is the first org you created during signup.
72+
app: appDemo # (optional) serverless dashboard app. default is the same as the name property.
73+
stage: dev # (optional) serverless dashboard stage. default is dev.
74+
component: koa # (required) name of the component. In that case, it's koa.
75+
name: koaDemo # (required) name of your koa component instance.
76+
77+
inputs:
78+
src:
79+
src: ./src # (optional) path to the source folder. default is a hello world app.
80+
exclude:
81+
- .env
82+
region: ap-guangzhou
83+
runtime: Nodejs10.15
84+
apigatewayConf:
85+
protocols:
86+
- http
87+
- https
88+
environment: release
9189
```
9290
93-
- [点击此处查看配置文档](https://github.com/serverless-components/tencent-koa/blob/master/docs/configure.md)
91+
- [点击此处查看配置文档](https://github.com/serverless-components/tencent-koa/blob/v2/docs/configure.md)
9492
9593
### 4. 部署
9694
@@ -101,56 +99,7 @@ koa:
10199
> 注:`sls`命令是`serverless`命令的缩写
102100

103101
```
104-
$ sls --debug
105-
106-
DEBUG ─ Resolving the template's static variables.
107-
DEBUG ─ Collecting components from the template.
108-
DEBUG ─ Downloading any NPM components found in the template.
109-
DEBUG ─ Analyzing the template's components dependencies.
110-
DEBUG ─ Creating the template's components graph.
111-
DEBUG ─ Syncing template state.
112-
DEBUG ─ Executing the template's components graph.
113-
DEBUG ─ Generating serverless handler...
114-
DEBUG ─ Generated serverless handler successfully.
115-
DEBUG ─ Compressing function koa-function file to /Users/yugasun/Desktop/Develop/serverless/tencent-koa/example/.serverless/koa-function.zip.
116-
DEBUG ─ Compressed function koa-function file successful
117-
DEBUG ─ Uploading service package to cos[sls-cloudfunction-ap-guangzhou-code]. sls-cloudfunction-default-koa-function-1584364164.zip
118-
koa-function [████████████████████████████████████████] 100% | ETA: 0s | Speed: 923.87k/s
119-
DEBUG ─ Uploaded package successful /Users/yugasun/Desktop/Develop/serverless/tencent-koa/example/.serverless/koa-function.zip
120-
DEBUG ─ Creating function koa-function
121-
DEBUG ─ Updating code...
122-
DEBUG ─ Updating configure...
123-
DEBUG ─ Created function koa-function successful
124-
DEBUG ─ Setting tags for function koa-function
125-
DEBUG ─ Creating trigger for function koa-function
126-
DEBUG ─ Deployed function koa-function successful
127-
DEBUG ─ Starting API-Gateway deployment with name ap-guangzhou-apigateway in the ap-guangzhou region
128-
DEBUG ─ Using last time deploy service id service-pnlxadhq
129-
DEBUG ─ Updating service with serviceId service-pnlxadhq.
130-
DEBUG ─ Endpoint ANY / already exists with id api-9415bswy.
131-
DEBUG ─ Updating api with api id api-9415bswy.
132-
DEBUG ─ Service with id api-9415bswy updated.
133-
DEBUG ─ Deploying service with id service-pnlxadhq.
134-
DEBUG ─ Deployment successful for the api named ap-guangzhou-apigateway in the ap-guangzhou region.
135-
136-
koa:
137-
functionName: koa-function
138-
functionOutputs:
139-
ap-guangzhou:
140-
Name: koa-function
141-
Runtime: Nodejs8.9
142-
Handler: serverless-handler.handler
143-
MemorySize: 128
144-
Timeout: 10
145-
Region: ap-guangzhou
146-
Namespace: default
147-
Description: This is a template function
148-
region: ap-guangzhou
149-
apiGatewayServiceId: service-pnlxadhq
150-
url: https://service-pnlxadhq-1251556596.gz.apigw.tencentcs.com/release/
151-
cns: (empty array)
152-
153-
36s › koa › done
102+
$ sls deploy
154103
```
155104
156105
部署完毕后,可以在浏览器中访问部署成功地 url。
@@ -160,14 +109,7 @@ $ sls --debug
160109
通过以下命令移除部署的 Koa 服务。
161110
162111
```
163-
$ sls remove --debug
164-
165-
DEBUG ─ Flushing template state and removing all components.
166-
DEBUG ─ Removed function koa-function successful
167-
DEBUG ─ Removing any previously deployed API. api-9415bswy
168-
DEBUG ─ Removing any previously deployed service. service-pnlxadhq
169-
170-
14s › koa › done
112+
$ sls remove
171113
```
172114
173115
### 账号配置(可选)

0 commit comments

Comments
 (0)