Skip to content

Commit 61bd482

Browse files
committed
fix: change entry to sls.js
1 parent 2a9167e commit 61bd482

File tree

11 files changed

+68
-75
lines changed

11 files changed

+68
-75
lines changed

README.en.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,23 @@ Here's a complete reference of the `serverless.yml` file for the express compone
9797

9898
```yml
9999
component: express # (required) name of the component. In that case, it's express.
100-
name: express-api # (required) name of your express component instance.
101-
org: serverlessinc # (optional) serverless dashboard org. default is the first org you created during signup.
102-
app: myApp # (optional) serverless dashboard app. default is the same as the name property.
100+
name: expressDemo # (required) name of your express component instance.
101+
org: orgDemo # (optional) serverless dashboard org. default is the first org you created during signup.
102+
app: appDemo # (optional) serverless dashboard app. default is the same as the name property.
103103
stage: dev # (optional) serverless dashboard stage. default is dev.
104104

105105
inputs:
106106
src: ./src # (optional) path to the source folder. default is a hello world app.
107-
memory: 512 # (optional) lambda memory size.
108-
timeout: 10 # (optional) lambda timeout.
109-
description: My Express App # (optional) lambda & api gateway description.
110-
env: # (optional) env vars.
111-
DEBUG: 'express:*' # this express specific env var will print express debug logs.
112-
roleArn: arn:aws:abc # (optional) custom role arn.
113-
traffic: 0.2 # (optional) traffic percentage to apply to this deployment.
114-
domain: api.serverless.com # (optional) domain name.
115-
region: us-east-2 # (optional) aws region to deploy to. default is us-east-1.
107+
functionName: expressDemo
108+
region: ap-guangzhou
109+
runtime: Nodejs10.15
110+
exclude:
111+
- .env
112+
apigatewayConf:
113+
protocols:
114+
- http
115+
- https
116+
environment: release
116117
```
117118
118119
Once you've chosen your configuration, run `serverless deploy` again (or simply just `serverless`) to deploy your changes.

README.md

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
- [x] **便捷协作** - 通过云端的状态信息和部署日志,方便的进行多人协作开发。
1616
- [x] **自定义域名** - 支持配置自定义域名及 HTTPS 访问
1717

18-
1918
<br/>
2019

2120
<img align="right" width="400" src="https://scf-dev-tools-1253665819.cos.ap-guangzhou.myqcloud.com/express_demo_light_sm_resize.gif" />
@@ -31,26 +30,30 @@
3130
7. [**移除**](#7-移除)
3231

3332
更多资源:
34-
* [**架构说明**](#架构说明)
35-
* [**账号配置**](#账号配置)
33+
34+
- [**架构说明**](#架构说明)
35+
- [**账号配置**](#账号配置)
3636

3737
&nbsp;
3838

3939
### 1. 安装
4040

41-
通过 npm 安装最新版本的 Serverless Framework
41+
通过 npm 安装最新版本的 Serverless Framework
42+
4243
```
4344
$ npm install -g serverless
4445
```
4546

4647
### 2. 创建
4748

4849
创建并进入一个全新目录:
50+
4951
```
5052
$ mkdir tencent-express && cd tencent-express
5153
```
5254

5355
通过如下命令和模板链接,快速创建一个 express 应用:
56+
5457
```
5558
$ serverless create --template-url https://github.com/serverless-components/tencent-express/tree/v2/example
5659
$ cd example
@@ -61,7 +64,9 @@ $ cd example
6164
```
6265
$ cd src && npm install
6366
```
67+
6468
安装完毕后,目录结构如下所示:
69+
6570
```
6671
|- src
6772
| ├── app.js
@@ -74,11 +79,11 @@ $ cd src && npm install
7479

7580
`serverless.yml` 文件下的目录中运行 `serverless deploy` 进行 express 项目的部署。第一次部署可能耗时相对较久,但后续的二次部署会在几秒钟之内完成。部署完毕后,你可以在命令行的输出中查看到你 express 应用的 URL 地址,点击地址即可访问你的 express 项目。
7681

77-
**注意:**
82+
**注意:**
7883

7984
如您的账号未[登陆](https://cloud.tencent.com/login)[注册](https://cloud.tencent.com/register)腾讯云,您可以直接通过`微信`扫描命令行中的二维码进行授权登陆和注册。
8085

81-
如果出现了 `internal server error` 的报错,请检查是否在创建模板后没有运行 `npm install`
86+
如果出现了 `internal server error` 的报错,请检查是否在创建模板后没有运行 `npm install`
8287

8388
如果希望查看更多部署过程的信息,可以通过`sls deploy --debug` 命令查看部署过程中的实时日志信息,`sls``serverless` 命令的缩写。
8489

@@ -93,36 +98,24 @@ Express 组件支持 0 配置部署,也就是可以直接通过配置文件中
9398
```yml
9499
# serverless.yml
95100

96-
component: express # (必填) 引用 component 的名称,当前用到的是 express-tencent 组件
97-
name: express-api # (必填) 该 express 组件创建的实例名称
98-
org: test # (可选) 用于记录组织信息,默认值为您的腾讯云账户 appid
99-
app: expressApp # (可选) 该 express 应用名称
100-
stage: dev # (可选) 用于区分环境信息,默认值是 dev
101+
component: express # (required) name of the component. In that case, it's express.
102+
name: expressDemo # (required) name of your express component instance.
103+
org: orgDemo # (optional) serverless dashboard org. default is the first org you created during signup.
104+
app: appDemo # (optional) serverless dashboard app. default is the same as the name property.
105+
stage: dev # (optional) serverless dashboard stage. default is dev.
101106

102107
inputs:
108+
src: ./src # (optional) path to the source folder. default is a hello world app.
109+
functionName: expressDemo
103110
region: ap-guangzhou
104-
functionName: express-api
105-
serviceName: mytest
106-
runtime: Nodejs8.9
107-
serviceId: service-np1uloxw
108-
src: ./src
109-
functionConf:
110-
timeout: 10
111-
memorySize: 128
112-
environment:
113-
variables:
114-
TEST: vale
111+
runtime: Nodejs10.15
112+
exclude:
113+
- .env
115114
apigatewayConf:
116-
customDomains:
117-
- domain: abc.com
118-
certificateId: abcdefg
119-
isDefaultMapping: 'FALSE'
120-
pathMappingSet:
121-
- path: /
122-
environment: release
123-
protocols:
124-
- http
125-
- https
115+
protocols:
116+
- http
117+
- https
118+
environment: release
126119
```
127120
128121
点此查看[全量配置及配置说明](https://github.com/serverless-components/tencent-express/blob/v2/docs/configure.md)

example/serverless.yml

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

77
inputs:
8-
src: ./src # (optional) path to the source folder. default is a hello world app.
8+
# src: ./src # (optional) path to the source folder. default is a hello world app.
9+
functionName: expressDemo
910
region: ap-guangzhou
1011
runtime: Nodejs10.15
1112
exclude:
File renamed without changes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless/express",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"main": "src/serverless.js",
55
"publishConfig": {
66
"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: express
2-
version: 0.0.7
2+
version: 0.0.8
33
author: Tencent Cloud Inc.
44
org: Tencent Cloud Inc.
55
description: Deploys a serverless Express.js application onto Tencent SCF and Tencent APIGateway.

src/_express/handler.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
const fs = require('fs')
2+
const path = require('path')
23
const { createServer, proxy } = require('tencent-serverless-http')
34

45
exports.handler = async (event, context) => {
5-
// NOTICE: require() is relative to this file, while existsSync() is relative to the cwd, which is the root of lambda
6+
const userSls = path.join(__dirname, '..', 'sls.js')
67
let app
7-
if (fs.existsSync('./app.js')) {
8+
if (fs.existsSync(userSls)) {
89
// load the user provided app
9-
app = require('../app.js')
10+
app = await require(userSls)
1011
} else {
1112
// load the built-in default app
12-
app = require('../_src/app.js')
13+
app = require('./sls.js')
1314
}
1415

1516
const server = createServer(app)
File renamed without changes.

src/_src/package.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless/express",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"main": "./serverless.js",
55
"publishConfig": {
66
"access": "public"
@@ -12,6 +12,7 @@
1212
"author": "Tencent Cloud, Inc.",
1313
"license": "MIT",
1414
"dependencies": {
15+
"download": "^8.0.0",
1516
"fs-extra": "^8.1.0",
1617
"tencent-component-toolkit": "^1.1.1",
1718
"type": "^2.0.0"

0 commit comments

Comments
 (0)