Skip to content

Commit fdacf6a

Browse files
Staging (#881)
1 parent ae58d47 commit fdacf6a

File tree

2 files changed

+386
-347
lines changed

2 files changed

+386
-347
lines changed

src/pages/api/webhook.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,29 @@ import {VercelRequest, VercelResponse} from "@vercel/node";
55
const probot = createProbot()
66
const loadingApp = probot.load(app)
77

8+
function getBody(request: VercelRequest): Promise<string> {
9+
return new Promise((resolve) => {
10+
const bodyParts: Uint8Array[] = [];
11+
let body;
12+
request.on('data', (chunk) => {
13+
bodyParts.push(chunk);
14+
}).on('end', async () => {
15+
body = Buffer.concat(bodyParts).toString();
16+
resolve(body)
17+
});
18+
});
19+
}
20+
21+
export const config = {
22+
api: {
23+
bodyParser: false
24+
}
25+
};
26+
827
export default async function (request: VercelRequest, response: VercelResponse) {
928
try {
1029
await loadingApp;
11-
const payload = JSON.stringify(request.body);
30+
const payload = await getBody(request);
1231
const id = request.headers['X-GitHub-Delivery'] || request.headers['x-github-delivery'];
1332
const eventName = request.headers['X-GitHub-Event'] || request.headers['x-github-event'];
1433
const signature = request.headers['X-Hub-Signature-256'] || request.headers['x-hub-signature-256'];

0 commit comments

Comments
 (0)