Open
Description
What’s missing?
There is currently no simple way to parse and verify an incoming http request object at the same time. It's only possible as part of the event API of a webhooks
instance, which might be overkill / not the best fit for a serverless/function environment
This would permit for code such as this:
export async function handler(event) {
try {
const githubEvent = await verifyAndParse(secret, event)
// handle valid event
return { body: text, statusCode: 200 };
} catch (error) {
// handle errors
return { body: 'oh noes!', statusCode: 500 }
}
}
Why?
This is a follow up to #372 (comment), see the discussion for more reasoning.
In a nutshell, @G-Rath's use case is to separate receiving and verifying the event request from running any event handlers to avoid AWS Lambda timeouts.
Alternatives you tried
export async function handler(event) {
const webhooks = new Webhooks(options)
webhooks.on(['check_run', 'code_scanning_alert', 'commit_comment'], async (event) => {
// handle valid events
})
try {
await webhooks.verifyAndReceive(awsEventToOctokitEvent(event))
return { statusCode: 200 };
} catch (error) {
// handle error
return { body: 'oh noes!', statusCode: 500 }
}
}