feat: GitHub Webhooks middleware
Introduces middleware that allows you to receive and process GitHub Webhooks events in your Hono application. It conveniently validates the incoming requests and provides you with a simple API to handle the events.
Usage
import { Hono } from 'hono'
import { gitHubWebhooksMiddleware } from '@hono/github-webhooks'
type Env = {
GITHUB_WEBHOOK_SECRET: string
}
const app = new Hono<{ Bindings: Env }>()
app.use('/webhook', gitHubWebhooksMiddleware())
app.post('/webhook', async (c) => {
const webhooks = c.get('webhooks') /* const webhooks = c.var.webhooks */
webhooks.on('star.created', async ({ id, name, payload }) => {
// handle star creation here
})
webhooks.on('issues.opened', async ({ id, name, payload }) => {
// handle opened issue here
})
})
TODO
- [ ] update https://github.com/honojs/website/blob/main/docs/middleware/third-party.md
🦋 Changeset detected
Latest commit: 5a7ec2990ce0aca5655931682939aa99f746feb2
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @hono/github-webhooks | Major |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Hi @oscarvz
Sorry for the late reply. Looks good. I think it will be helpful if you write this as an example on "Examples" in our doc like the "Stripe Webhook": https://hono.dev/examples/stripe-webhook
Maintaining middleware is harder than updating documentation, so I think it's better to make it a document than adding the middleware to this repo.