Skip to content

mehdigmira/basehook

Repository files navigation

Basehook

Transform any push-based system into pull-based one. Basehook handles bufferization, and concurrency for you, so you can just start consuming payloads. It also offers a UI for inspecting and replaying events.

Demo Video

Core Concepts

Thread-based grouping: Webhooks are grouped by thread ID. Configure JSON paths to extract thread IDs and revision numbers from any format (Slack, GitHub, Shopify, etc.).

Two consumption modes:

  • pop(only_last_revision=False) - Process updates one by one in order
  • pop(only_last_revision=True) - Buffer updates and only consume the latest revision, skipping outdated ones

Pull-based processing: Your application pulls updates via pop() instead of receiving direct webhook POSTs. Failed processing is marked as ERROR and visible in the UI for manual retry.

Quick Deploy

Docker Compose (Self-hosting)

git clone https://github.com/mehdigmira/basehook.git
cd basehook
docker-compose up -d

Access at http://localhost:8000

Railway (Cloud)

Deploy on Railway

One-click deploy with PostgreSQL auto-configured.

Usage

1. Configure webhook

Visit the UI and create a webhook with thread ID and revision number paths.

2. Install client library

pip install basehook

3. Consume updates

import asyncio
from basehook import Basehook

basehook = Basehook(database_url="postgresql+asyncpg://...")
webhook_name = ...

async def process_one():
    # Process updates one by one (in order)
    async with basehook.pop(webhook_name, only_last_revision=False) as update:
        if update:
            print(update)

async def process_last():
    # Process last
    async with basehook.pop(webhook_name, only_last_revision=True) as update:
        if update:
            print(update)

if __name__ == "__main__":
    asyncio.run(process_one())

License

MIT

About

Consume, inspect or replay any webhook event

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors