# Webhook inbox

An address to send webhooks to, and a page that shows each one as it arrives, headers and body. Test Stripe, GitHub or Shopify hooks without a paid tool.

## Get it

```sh
$ dukoi init webhook-inbox
```

It makes a `webhook-inbox` folder and deploys it. On the phone instead: **Try a template → Webhook inbox → Deploy**.

## What you get

Every request to `/hook`, or anything under it, is saved on the phone and shows up on the page within two seconds. The newest one opens by itself.

quiet-river-kite.trycloudflare.com

-   POST /hook/stripe just now
-   POST /hook/github 4 min ago
-   GET /hook?ping=1 12 min ago

Services on the internet can’t reach your Wi-Fi, so give the app a [public URL](/docs/public-urls.md) and paste that, plus `/hook`, into the service’s webhook settings.

```sh
$ dukoi expose
```

## Make it yours

Five files. You only need to touch one.

- `handle.js`: What to do with each webhook. Edit this one.
- `server.js`: Saves requests and serves the page
- `public/index.html`: The inbox page
- `package.json`: Its name and packages
- `README.md`: How to run it, in five minutes

Act on GitHub pushes in `handle.js`. What it returns is the reply:

```
export async function handle({ headers, body }) {
  if (headers['x-github-event'] === 'push') {
    const push = JSON.parse(body)
    console.log(`${push.pusher.name} pushed to ${push.repository.full_name}`)
  }
}
```

```sh
$ dukoi deploy
```

> The page shows headers
> 
> Some services put secrets in headers. Don’t share the URL, or add a password check in `server.js`.
