Skip to content

Commit

Permalink
Staging (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
robvanderleek authored Jul 28, 2024
1 parent ae58d47 commit fdacf6a
Show file tree
Hide file tree
Showing 2 changed files with 386 additions and 347 deletions.
21 changes: 20 additions & 1 deletion src/pages/api/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,29 @@ import {VercelRequest, VercelResponse} from "@vercel/node";
const probot = createProbot()
const loadingApp = probot.load(app)

function getBody(request: VercelRequest): Promise<string> {
return new Promise((resolve) => {
const bodyParts: Uint8Array[] = [];
let body;
request.on('data', (chunk) => {
bodyParts.push(chunk);
}).on('end', async () => {
body = Buffer.concat(bodyParts).toString();
resolve(body)
});
});
}

export const config = {
api: {
bodyParser: false
}
};

export default async function (request: VercelRequest, response: VercelResponse) {
try {
await loadingApp;
const payload = JSON.stringify(request.body);
const payload = await getBody(request);
const id = request.headers['X-GitHub-Delivery'] || request.headers['x-github-delivery'];
const eventName = request.headers['X-GitHub-Event'] || request.headers['x-github-event'];
const signature = request.headers['X-Hub-Signature-256'] || request.headers['x-hub-signature-256'];
Expand Down
Loading

0 comments on commit fdacf6a

Please sign in to comment.