Skip to content

Commit 025680d

Browse files
committed
fix: migrate to slsplus
1 parent 7df2d8d commit 025680d

File tree

11 files changed

+53
-115
lines changed

11 files changed

+53
-115
lines changed

CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
## [1.0.5](https://github.com/yugasun/tencent-serverless-http/compare/v1.0.4...v1.0.5) (2020-02-09)
1+
## [1.0.5](https://github.com/serverless-plus/tencent-serverless-http/compare/v1.0.4...v1.0.5) (2020-02-09)
22

33

44
### Bug Fixes
55

6-
* get tencent api query ([6e740ab](https://github.com/yugasun/tencent-serverless-http/commit/6e740ab))
6+
* get tencent api query ([6e740ab](https://github.com/serverless-plus/tencent-serverless-http/commit/6e740ab))
77

8-
## [1.0.4](https://github.com/yugasun/tencent-serverless-http/compare/v1.0.3...v1.0.4) (2020-01-16)
8+
## [1.0.4](https://github.com/serverless-plus/tencent-serverless-http/compare/v1.0.3...v1.0.4) (2020-01-16)
99

1010

1111
### Bug Fixes
1212

13-
* update lowest node version to 8 ([654b6b8](https://github.com/yugasun/tencent-serverless-http/commit/654b6b8))
13+
* update lowest node version to 8 ([654b6b8](https://github.com/serverless-plus/tencent-serverless-http/commit/654b6b8))
1414

15-
## [1.0.1](https://github.com/yugasun/tencent-serverless-http/compare/v1.0.0...v1.0.1) (2020-01-15)
15+
## [1.0.1](https://github.com/serverless-plus/tencent-serverless-http/compare/v1.0.0...v1.0.1) (2020-01-15)
1616

1717

1818
### Bug Fixes
1919

20-
* update readme ([bc3491e](https://github.com/yugasun/tencent-serverless-http/commit/bc3491e))
20+
* update readme ([bc3491e](https://github.com/serverless-plus/tencent-serverless-http/commit/bc3491e))

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Tencent Serverless Http
22

3-
[![Build Status](https://travis-ci.com/yugasun/tencent-serverless-http.svg?branch=master)](https://travis-ci.com/yugasun/tencent-serverless-http)
4-
[![npm](https://img.shields.io/npm/v/tencent-serverless-http.svg)]()
5-
[![npm](https://img.shields.io/npm/dm/tencent-serverless-http.svg)]()
6-
[![dependencies Status](https://david-dm.org/yugasun/tencent-serverless-http/status.svg)](https://david-dm.org/yugasun/tencent-serverless-http)
3+
[![Build Status](https://travis-ci.com/serverless-plus/tencent-serverless-http.svg?branch=master)](https://travis-ci.com/serverless-plus/tencent-serverless-http)
4+
[![npm](https://img.shields.io/npm/v/%40slsplus%2Ftencent-serverless-http.svg)](http://www.npmtrends.com/%40slsplus%2Ftencent-serverless-http)
5+
[![NPM downloads](https://img.shields.io/npm/dm/%40slsplus%2Ftencent-serverless-http.svg)](http://www.npmtrends.com/%40slsplus%2Ftencent-serverless-http)
76

87
This project is a fork of
98
[aws-serverless-express](https://github.com/awslabs/aws-serverless-express.git),
@@ -12,15 +11,15 @@ and modify for tencent cloud scf.
1211
## Install
1312

1413
```bash
15-
npm install tencent-serverless-http
14+
npm install @slsplus/tencent-serverless-http
1615
```
1716

1817
## Usage
1918

2019
```js
2120
// handler.js
2221
'use strict';
23-
const tencentServerlessHttp = require('tencent-serverless-http');
22+
const tencentServerlessHttp = require('@slsplus/tencent-serverless-http');
2423
const app = require('./app');
2524
const server = tencentServerlessHttp.createServer(app);
2625

@@ -29,11 +28,11 @@ exports.handler = (event, context) => {
2928
};
3029
```
3130

32-
This package includes middleware to easily get the event object Lambda receives
31+
This package includes middleware to easily get the event object SCF receives
3332
from API Gateway
3433

3534
```js
36-
const tencentServerlessHttpMiddleware = require('tencent-serverless-http/middleware');
35+
const tencentServerlessHttpMiddleware = require('@slsplus/tencent-serverless-http/middleware');
3736
app.use(tencentServerlessHttpMiddleware.eventContext());
3837
app.get('/', (req, res) => {
3938
res.json(req.apiGateway.event);

SCOPE.txt

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

__tests__/integration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ function makeEvent (eventOverrides) {
2424
function expectedRootResponse () {
2525
return makeResponse({
2626
'headers': {
27-
'content-length': '3682',
27+
'content-length': '3446',
2828
'content-type': 'text/html; charset=utf-8',
29-
'etag': 'W/"e62-NHyvvU4yLNxWfyDMGcW+pYANLZ4"'
29+
'etag': 'W/"d76-UV3AoJfpe2/C0l+IRqFcasVbyD0"'
3030
}
3131
})
3232
}

examples/basic-starter/README.md

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

examples/basic-starter/app.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const express = require('express')
44
const bodyParser = require('body-parser')
55
const cors = require('cors')
66
const compression = require('compression')
7-
const tencentServerlessNodejsMiddleware = require('tencent-serverless-http/middleware')
7+
const tencentServerlessNodejsMiddleware = require('@slsplus/tencent-serverless-http/middleware')
88
const app = express()
99
const router = express.Router()
1010

@@ -28,7 +28,9 @@ app.set('views', path.join(__dirname, 'views'))
2828

2929
router.get('/', (req, res) => {
3030
res.render('index', {
31-
apiUrl: req.apiGateway ? `https://${req.apiGateway.event.headers.Host}/${req.apiGateway.event.requestContext.stage}` : 'http://localhost:3000'
31+
apiUrl: req.apiGateway
32+
? `https://${req.apiGateway.event.headers.Host}/${req.apiGateway.event.requestContext.stage}`
33+
: 'http://localhost:3000'
3234
})
3335
})
3436

@@ -75,17 +77,21 @@ router.delete('/users/:userId', (req, res) => {
7577
res.json(users)
7678
})
7779

78-
const getUser = (userId) => users.find(u => u.id === parseInt(userId))
79-
const getUserIndex = (userId) => users.findIndex(u => u.id === parseInt(userId))
80+
const getUser = (userId) => users.find((u) => u.id === parseInt(userId))
81+
const getUserIndex = (userId) =>
82+
users.findIndex((u) => u.id === parseInt(userId))
8083

8184
// Ephemeral in-memory data store
82-
const users = [{
83-
id: 1,
84-
name: 'Joe'
85-
}, {
86-
id: 2,
87-
name: 'Jane'
88-
}]
85+
const users = [
86+
{
87+
id: 1,
88+
name: 'Joe'
89+
},
90+
{
91+
id: 2,
92+
name: 'Jane'
93+
}
94+
]
8995
let userIdCounter = users.length
9096

9197
// The tencent-serverless-http library creates a server and listens on a Unix

examples/basic-starter/lambda.js renamed to examples/basic-starter/handler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
const awsServerlessExpress = require(process.env.NODE_ENV === 'test' ? '../../index' : 'tencent-serverless-http')
2+
const serverlessExpress = require(process.env.NODE_ENV === 'test' ? '../../index' : '@slsplus/tencent-serverless-http')
33
const app = require('./app')
44

55
// NOTE: If you get ERR_CONTENT_DECODING_FAILED in your browser, this is likely
@@ -25,6 +25,6 @@ const binaryMimeTypes = [
2525
'text/text',
2626
'text/xml'
2727
]
28-
const server = awsServerlessExpress.createServer(app, null, binaryMimeTypes)
28+
const server = serverlessExpress.createServer(app, null, binaryMimeTypes)
2929

30-
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context)
30+
exports.handler = (event, context) => serverlessExpress.proxy(server, event, context)

examples/basic-starter/package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basic-starter/package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,13 @@
22
"name": "tencent-serverless-express-example",
33
"version": "2.1.1",
44
"description": "Example application for running a Node Express app on Tencent Cloud SCF using API Gateway.",
5-
"main": "lambda.js",
6-
"config": {
7-
"s3BucketName": "YOUR_UNIQUE_BUCKET_NAME",
8-
"region": "YOUR_AWS_REGION",
9-
"cloudFormationStackName": "AwsServerlessExpressStack",
10-
"functionName": "YOUR_SERVERLESS_EXPRESS_LAMBDA_FUNCTION_NAME",
11-
"accountId": "YOUR_ACCOUNT_ID"
12-
},
5+
"main": "handler.js",
136
"scripts": {
147
"start": "node app.local.js"
158
},
169
"license": "Apache-2.0",
1710
"dependencies": {
18-
"tencent-serverless-http": "^1.0.5",
11+
"@slsplus/tencent-serverless-http": "^1.0.5",
1912
"body-parser": "^1.17.1",
2013
"compression": "^1.6.2",
2114
"cors": "^2.8.3",

examples/basic-starter/views/index.pug

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ html
4444
h1 My Serverless Application
4545
img.sam-logo(src='sam')
4646
p
47-
| Welcome to your AWS serverless application. This example application has several resources configured for you to explore. State is stored in memory in a given container, and is therfore ephemeral - see
48-
a(href='https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/', target='_blank') Understanding Container Reuse in AWS Lambda
49-
|  for more information.
47+
| Welcome to your Tencetn SCF serverless application. This example application has several resources configured for you to explore.
5048
section.resources
5149
h2 Resources
5250
section.resource

0 commit comments

Comments
 (0)