Licence
MIT
Version
0.3.1
Deps
1
Size
247 kB
Vulns
0
Weekly
0
@thebookingkit/server
Auth, webhooks, API keys, workflows, and adapter interfaces for booking system backends.
Part of The Booking Kit — The Headless Booking Primitive.
Install
npm install @thebookingkit/serverQuick Start
import { withAuth, signWebhookPayload, generateApiKey } from "@thebookingkit/server";
// Protect a route with auth middleware
const handler = withAuth(async (req) => {
const user = req.auth; // typed AuthUser
return Response.json({ ok: true });
});
// Sign and verify webhook payloads
const signature = signWebhookPayload(payload, secret);Key Features
- Auth Middleware —
withAuth, ownership assertions, pluggableAuthAdapter(NextAuth.js, Clerk, Supabase, Lucia) - Webhooks — HMAC-SHA256 signing/verification, retry with exponential backoff, subscription matching
- API Key Management — Generation, hashing, verification, scopes, expiration, rate limiting
- Booking Tokens — Secure token generation and verification for confirmation/cancellation links
- Workflows — Trigger-based automation with conditions, template variables, and action routing
- Notifications — Email templates (confirmation, reminder, cancellation, reschedule) and calendar sync
- Multi-Tenancy — Role-based permissions, settings inheritance (org > provider > event type), tenant scoping
- Serialization Retry —
withSerializableRetryfor SERIALIZABLE transaction conflict handling - Adapter Interfaces — Swappable
EmailAdapter,CalendarAdapter,JobAdapter,StorageAdapter,SmsAdapter,PaymentAdapter(with built-inStripePaymentAdapter) - Stripe Deposits —
initiateDeposit/refundDepositorchestration helpers and ahandleStripeWebhookhandler with signature verification and idempotency onevent.id
Documentation
License
MIT