Skip to content

Commit b9e12f0

Browse files
authored
Merge pull request #4 from listenlin/feature/raw-body
refactor: use raw-body to pass buffer data, to support binary body.
2 parents c77ff71 + a8c157c commit b9e12f0

File tree

3 files changed

+64
-48
lines changed

3 files changed

+64
-48
lines changed

package-lock.json

+59-41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless-devs/fc-http",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "running web framework(express,koa) on aliyun function computer with nodejs runtime",
55
"main": "src/index.js",
66
"repository": {
@@ -18,7 +18,7 @@
1818
"Serverless-Core"
1919
],
2020
"dependencies": {
21-
"body": "^5.1.0",
21+
"raw-body": "^2.5.1",
2222
"serverless-http": "^2.7.0"
2323
},
2424
"author": "@serverless-devs",
@@ -27,4 +27,4 @@
2727
"url": "https://github.com/Serverless-Devs/fc-http/issues"
2828
},
2929
"homepage": "https://github.com/Serverless-Devs/fc-http#readme"
30-
}
30+
}

src/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const serverless = require('serverless-http');
2-
const body = require('body');
2+
const getRawBody = require('raw-body');
33

44
const makeResolver = (ctx) => {
55
return data => {
@@ -46,9 +46,7 @@ const getBody = async (request) =>
4646
resolve('');
4747
}
4848
try {
49-
body(request, (e, b) => {
50-
resolve(b);
51-
});
49+
getRawBody(request).then(resolve, reject);
5250
} catch (e) {
5351
reject(e);
5452
}

0 commit comments

Comments
 (0)