Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function handleWebhook(req: any, res: any) {
if (
!verify(
await keyManager.getWebhookSecret(),
req.rawBody.toString(),
req.get('X-Hub-Signature'),
)
) {
console.error('Invalid signature.');
res.status(400).end();
return;
}
const event = req.body;
const eventType = req.get('X-GitHub-Event');
switch (eventType) {
case 'pull_request':
await handlePullRequest(event);
break;