npm.io
0.3.1 • Published 2d ago

@thebookingkit/server

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.

npm version License: MIT TypeScript

Part of The Booking Kit — The Headless Booking Primitive.

Install

npm install @thebookingkit/server

Quick 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 MiddlewarewithAuth, ownership assertions, pluggable AuthAdapter (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 RetrywithSerializableRetry for SERIALIZABLE transaction conflict handling
  • Adapter Interfaces — Swappable EmailAdapter, CalendarAdapter, JobAdapter, StorageAdapter, SmsAdapter, PaymentAdapter (with built-in StripePaymentAdapter)
  • Stripe DepositsinitiateDeposit/refundDeposit orchestration helpers and a handleStripeWebhook handler with signature verification and idempotency on event.id

Documentation

Full Documentation

License

MIT

Keywords