Skip to content

Commit

Permalink
fix: migrate to slsplus
Browse files Browse the repository at this point in the history
  • Loading branch information
yugasun committed Mar 9, 2020
1 parent 7df2d8d commit 025680d
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 115 deletions.
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## [1.0.5](https://github.com/yugasun/tencent-serverless-http/compare/v1.0.4...v1.0.5) (2020-02-09)
## [1.0.5](https://github.com/serverless-plus/tencent-serverless-http/compare/v1.0.4...v1.0.5) (2020-02-09)


### Bug Fixes

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

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


### Bug Fixes

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

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


### Bug Fixes

* update readme ([bc3491e](https://github.com/yugasun/tencent-serverless-http/commit/bc3491e))
* update readme ([bc3491e](https://github.com/serverless-plus/tencent-serverless-http/commit/bc3491e))
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Tencent Serverless Http

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

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

```bash
npm install tencent-serverless-http
npm install @slsplus/tencent-serverless-http
```

## Usage

```js
// handler.js
'use strict';
const tencentServerlessHttp = require('tencent-serverless-http');
const tencentServerlessHttp = require('@slsplus/tencent-serverless-http');
const app = require('./app');
const server = tencentServerlessHttp.createServer(app);

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

This package includes middleware to easily get the event object Lambda receives
This package includes middleware to easily get the event object SCF receives
from API Gateway

```js
const tencentServerlessHttpMiddleware = require('tencent-serverless-http/middleware');
const tencentServerlessHttpMiddleware = require('@slsplus/tencent-serverless-http/middleware');
app.use(tencentServerlessHttpMiddleware.eventContext());
app.get('/', (req, res) => {
res.json(req.apiGateway.event);
Expand Down
25 changes: 0 additions & 25 deletions SCOPE.txt

This file was deleted.

4 changes: 2 additions & 2 deletions __tests__/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ function makeEvent (eventOverrides) {
function expectedRootResponse () {
return makeResponse({
'headers': {
'content-length': '3682',
'content-length': '3446',
'content-type': 'text/html; charset=utf-8',
'etag': 'W/"e62-NHyvvU4yLNxWfyDMGcW+pYANLZ4"'
'etag': 'W/"d76-UV3AoJfpe2/C0l+IRqFcasVbyD0"'
}
})
}
Expand Down
36 changes: 0 additions & 36 deletions examples/basic-starter/README.md

This file was deleted.

28 changes: 17 additions & 11 deletions examples/basic-starter/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const compression = require('compression')
const tencentServerlessNodejsMiddleware = require('tencent-serverless-http/middleware')
const tencentServerlessNodejsMiddleware = require('@slsplus/tencent-serverless-http/middleware')
const app = express()
const router = express.Router()

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

router.get('/', (req, res) => {
res.render('index', {
apiUrl: req.apiGateway ? `https://${req.apiGateway.event.headers.Host}/${req.apiGateway.event.requestContext.stage}` : 'http://localhost:3000'
apiUrl: req.apiGateway
? `https://${req.apiGateway.event.headers.Host}/${req.apiGateway.event.requestContext.stage}`
: 'http://localhost:3000'
})
})

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

const getUser = (userId) => users.find(u => u.id === parseInt(userId))
const getUserIndex = (userId) => users.findIndex(u => u.id === parseInt(userId))
const getUser = (userId) => users.find((u) => u.id === parseInt(userId))
const getUserIndex = (userId) =>
users.findIndex((u) => u.id === parseInt(userId))

// Ephemeral in-memory data store
const users = [{
id: 1,
name: 'Joe'
}, {
id: 2,
name: 'Jane'
}]
const users = [
{
id: 1,
name: 'Joe'
},
{
id: 2,
name: 'Jane'
}
]
let userIdCounter = users.length

// The tencent-serverless-http library creates a server and listens on a Unix
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
const awsServerlessExpress = require(process.env.NODE_ENV === 'test' ? '../../index' : 'tencent-serverless-http')
const serverlessExpress = require(process.env.NODE_ENV === 'test' ? '../../index' : '@slsplus/tencent-serverless-http')
const app = require('./app')

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

exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context)
exports.handler = (event, context) => serverlessExpress.proxy(server, event, context)
16 changes: 8 additions & 8 deletions examples/basic-starter/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions examples/basic-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@
"name": "tencent-serverless-express-example",
"version": "2.1.1",
"description": "Example application for running a Node Express app on Tencent Cloud SCF using API Gateway.",
"main": "lambda.js",
"config": {
"s3BucketName": "YOUR_UNIQUE_BUCKET_NAME",
"region": "YOUR_AWS_REGION",
"cloudFormationStackName": "AwsServerlessExpressStack",
"functionName": "YOUR_SERVERLESS_EXPRESS_LAMBDA_FUNCTION_NAME",
"accountId": "YOUR_ACCOUNT_ID"
},
"main": "handler.js",
"scripts": {
"start": "node app.local.js"
},
"license": "Apache-2.0",
"dependencies": {
"tencent-serverless-http": "^1.0.5",
"@slsplus/tencent-serverless-http": "^1.0.5",
"body-parser": "^1.17.1",
"compression": "^1.6.2",
"cors": "^2.8.3",
Expand Down
4 changes: 1 addition & 3 deletions examples/basic-starter/views/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ html
h1 My Serverless Application
img.sam-logo(src='sam')
p
| 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
a(href='https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/', target='_blank') Understanding Container Reuse in AWS Lambda
|  for more information.
| Welcome to your Tencetn SCF serverless application. This example application has several resources configured for you to explore.
section.resources
h2 Resources
section.resource
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "tencent-serverless-http",
"name": "@slsplus/tencent-serverless-http",
"version": "1.0.5",
"publishConfig": {
"access": "public"
},
"description": "This library enables you to utilize Tencent Cloud API Gateway to respond to web and API requests using your existing Node.js application framework.",
"keywords": [
"tencent-cloud",
Expand All @@ -10,9 +13,9 @@
"scf",
"nodejs"
],
"homepage": "https://github.com/yugasun/tencent-serverless-http",
"homepage": "https://github.com/serverless-plus/tencent-serverless-http",
"bugs": {
"url": "https://github.com/yugasun/tencent-serverless-http/issues"
"url": "https://github.com/serverless-plus/tencent-serverless-http/issues"
},
"license": "Apache-2.0",
"files": [
Expand All @@ -23,7 +26,7 @@
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/yugasun/tencent-serverless-http.git"
"url": "https://github.com/serverless-plus/tencent-serverless-http.git"
},
"engines": {
"node": ">=8"
Expand Down

0 comments on commit 025680d

Please sign in to comment.