Bun binding
The Bun binding loads Knocker’s SQLite extension through FFI and exposes the shared receive, worker, operator, and retention contract.
Install
Section titled “Install”The package is currently repo-local. Build the extension first:
cargo build --release -p knocker-extensionIf Bun cannot locate libsqlite3, set:
export KNOCKER_SQLITE3_LIB=/path/to/libsqlite3.dylibThen import the binding from the package path:
import { KnockerSqlite } from "./packages/knocker-bun/index";const webhooks = new KnockerSqlite("app.db");
webhooks.addEndpoint({ name: "automation", path: "/webhooks/automation", provider: "token-header", secrets: ["dev-secret"],});
webhooks.registerHandler("automation", (event, tx) => { console.log("handled", event.id);}, "invoice.created");
const result = webhooks.receive({ endpoint: "automation", body: Buffer.from('{"id":"evt_1","type":"invoice.created"}'), headers: { "X-Knocker-Token": "dev-secret" },});
await webhooks.runWorker({ workerId: "bun-worker", maxJobs: 1 });receive(...) delegates provider verification to the Rust/SQLite
knocker_receive(...) path. runWorker(...) runs handlers later against
stored SQLite rows and rolls handler writes back before retry/dead-letter
bookkeeping when the handler throws.
make test-bun