Skip to content

Conversation

oscarvz
Copy link

@oscarvz oscarvz commented Dec 12, 2024

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

Copy link

changeset-bot bot commented Dec 12, 2024

🦋 Changeset detected

Latest commit: 5a7ec29

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

@yusukebe
Copy link
Member

yusukebe commented Jan 5, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants