Skip to content

Commit e40dbea

Browse files
semantic-release-botyugasun
authored andcommitted
feat: remove middleware
1 parent 9bfd2e1 commit e40dbea

File tree

10 files changed

+8
-141
lines changed

10 files changed

+8
-141
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Yuga Sun
3+
Copyright (c) 2020 Serverless Plus
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ exports.handler = (event, context) => {
2828
};
2929
```
3030

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

34-
```js
35-
const tencentServerlessHttpMiddleware = require('tencent-serverless-http/middleware');
36-
app.use(tencentServerlessHttpMiddleware.eventContext());
37-
app.get('/', (req, res) => {
38-
res.json(req.apiGateway.event);
39-
});
40-
```
33+
MIT License
34+
35+
Copyright (c) 2020 Serverless Plus

__tests__/middleware.js

-73
This file was deleted.

__tests__/unit.js

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ test('mapApiGatewayEventToHttpRequest: with headers', () => {
7070
expect(r.httpRequest).toEqual({
7171
method: 'GET',
7272
path: '/foo',
73+
protocol: 'http:',
7374
headers: {
7475
'x-foo': 'foo',
7576
'Content-Length': Buffer.byteLength('Hello serverless!')
@@ -84,6 +85,7 @@ test('mapApiGatewayEventToHttpRequest: without headers', () => {
8485
expect(r.httpRequest).toEqual({
8586
method: 'GET',
8687
path: '/foo',
88+
protocol: 'http:',
8789
headers: {
8890
'Content-Length': Buffer.byteLength('Hello serverless!')
8991
},

examples/basic-starter/app.js

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ 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')
87
const app = express()
98
const router = express.Router()
109

@@ -21,7 +20,6 @@ if (process.env.NODE_ENV === 'test') {
2120
router.use(cors())
2221
router.use(bodyParser.json())
2322
router.use(bodyParser.urlencoded({ extended: true }))
24-
router.use(tencentServerlessNodejsMiddleware.eventContext())
2523

2624
// NOTE: tests can't find the views directory without this
2725
app.set('views', path.join(__dirname, 'views'))

index.js

-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
/*
2-
* Copyright 2016-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License").
5-
* You may not use this file except in compliance with the License.
6-
* A copy of the License is located at
7-
*
8-
* http://aws.amazon.com/apache2.0/
9-
*
10-
* or in the "license" file accompanying this file.
11-
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12-
* express or implied. See the License for the specific language governing
13-
* permissions and limitations under the License.
14-
*/
151
'use strict'
162

173
module.exports = require('./src/index')

middleware.js

-17
This file was deleted.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"license": "Apache-2.0",
2121
"files": [
2222
"index.js",
23-
"middleware.js",
2423
"src/"
2524
],
2625
"main": "index.js",

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function mapApiGatewayEventToHttpRequest (event, context, socketPath) {
3737

3838
return {
3939
method: event.httpMethod,
40-
protocol: headers['x-api-scheme'] || 'http',
40+
protocol: headers['x-api-scheme'] ? `${headers['x-api-scheme']}:` : 'http:',
4141
path: getPathWithQueryStringParams(event),
4242
headers,
4343
socketPath

src/middleware.js

-23
This file was deleted.

0 commit comments

Comments
 (0)