Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

Webhook Inspector (Monorepo)

Simple project to inspect webhooks, organized as a monorepo with two applications:

Project Overview

  • api (Fastify + Drizzle ORM + PostgreSQL): exposes endpoints to list, fetch, delete, and capture webhooks, and can generate a TypeScript handler from payloads using AI (Gemini via the ai SDK).
  • web (React + Vite + TanStack Router/Query + Tailwind): UI to explore captured webhooks and generate the handler.

Requirements

  • Node.js 20+ and pnpm (workspace)
  • Docker (to run PostgreSQL via docker-compose)
  • Google Generative AI API key (GOOGLE_GENERATIVE_AI_API_KEY) for the handler generation route

Quick setup

  1. Install dependencies at the monorepo root:
    • pnpm install
  2. Configure the database:
    • Copy api/.env.example to api/.env and adjust variables (DATABASE_URL, GOOGLE_GENERATIVE_AI_API_KEY, PORT if desired).
    • Start PostgreSQL: inside api/ run docker compose up -d.
    • Run migrations: pnpm -C api db:migrate (optional: pnpm -C api db:seed).
  3. Start the API (Fastify):
    • pnpm -C api dev
    • API runs at http://localhost:3333 and docs at http://localhost:3333/docs.
  4. Start the front-end (Vite):
    • pnpm -C web dev

Key API endpoints

  • GET /api/webhooks — paginated list of webhooks
  • GET /api/webhooks/:id — webhook details
  • DELETE /api/webhooks/:id — delete a webhook
  • POST /api/generate — generate a TypeScript handler from selected webhooks (requires GOOGLE_GENERATIVE_AI_API_KEY)
  • ANY /capture/* — capture endpoint (persists the request)
  • GET /docs — interactive reference (Swagger + Scalar)

Quick capture test

Send a sample webhook to be stored:

curl -X POST \
  http://localhost:3333/capture/test \
  -H 'Content-Type: application/json' \
  -d '{"event":"order.created","data":{"id":123,"total":199.9}}'

Then open the web UI to see the saved item in the list and its details.

Diagram (Mermaid)

sequenceDiagram
    autonumber
    actor S as External Service
    participant A as API (Fastify)
    participant DB as PostgreSQL (Drizzle)
    participant W as Web (React)

    S->>A: ANY /capture/* (webhook payload)
    A->>DB: Insert record (method, headers, body, etc.)
    A-->>S: 201 { id }

    W->>A: GET /api/webhooks (list)
    A-->>W: 200 { webhooks[], nextCursor }
    W->>A: GET /api/webhooks/:id (details)
    A-->>W: 200 { webhook }

    W->>A: POST /api/generate { webhookIds[] }
    A->>A: Build prompt with bodies
    A->>Gemini: generateText
    A-->>W: 201 { code }
Loading

Useful scripts

  • API (api/package.json):
    • pnpm -C api dev — start dev server
    • pnpm -C api db:migrate — apply migrations
    • pnpm -C api db:generate — generate migrations (Drizzle Kit)
    • pnpm -C api db:studio — open Drizzle Studio
    • pnpm -C api db:seed — seed data (optional)
  • Web (web/package.json):
    • pnpm -C web dev — start Vite dev server
    • pnpm -C web build — production build
    • pnpm -C web preview — preview the build

Project structure

  • api/ — capture, listing, and handler generation services
    • src/routes/* — routes (/api/webhooks, /capture/*, /api/generate)
    • src/db/* — Drizzle (schema, migrations)
    • docker-compose.yml — local PostgreSQL
  • web/ — React app to inspect webhooks
    • src/components/* — UI (list, details, code block)
    • src/routes/* — front-end routes (/, /webhooks/$id)

Notes

  • GOOGLE_GENERATIVE_AI_API_KEY is required for handler generation (POST /api/generate).
  • Adjust API PORT/host in .env if needed (defaults to 3333).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages