Follow Conventional Commits.
<type>(<scope>): <short summary>
<optional body>
| Type | When to use |
|---|---|
feat |
New feature |
fix |
Bug fix |
refactor |
Code change that neither fixes a bug nor adds a feature |
docs |
Documentation only |
test |
Adding or updating tests |
chore |
Build, CI, scripts, dependencies |
style |
Formatting, whitespace (no logic change) |
| Scope | Applies to |
|---|---|
api |
@hookwire/api Worker + routes |
sdk |
@hookwire/sdk client library |
types |
@hookwire/types shared types |
do |
ChannelDO Durable Object |
sse |
Server-Sent Events endpoint |
ws |
WebSocket endpoint |
ui |
HTML pages (home, viewer, SDK docs) |
docs |
API docs / Scalar / OpenAPI |
deps |
Dependency changes |
ci |
CI/CD configuration |
feat(api): add SSE endpoint with 1s polling and keepalive
fix(do): use toArray() instead of nonexistent first() on SQLite cursor
refactor(do): replace RPC with fetch() handler + internal Hono routing
test(sdk): add client connect, disconnect, and event handler tests
chore(sdk): switch build to rslib with publishConfig for dev/prod paths
docs(readme): add WebSocket and SSE protocol comparison table
hookwire/
├── packages/
│ ├── types/ @hookwire/types Shared TypeScript types
│ ├── server/ @hookwire/server ChannelDO + ingest/events routes (embeddable)
│ ├── api/ @hookwire/api Cloudflare Worker hosting @hookwire/server
│ └── sdk/ @hookwire/sdk Browser / Node.js client
├── scripts/ fire.sh etc.
└── SPEC.md Original channel design spec (now outdated)
- Development:
mainpoints to./src/index.ts(workspace resolves TypeScript directly) - Published:
publishConfig.mainpoints to./dist/index.js(rslib output)
npm run build -w @hookwire/types
npm run build -w @hookwire/sdknpm run publish:types # build + publish @hookwire/types
npm run publish:sdk # build + publish @hookwire/sdk
npm run publish:all # both- URL is the channel — no create API, no tokens, no signup. Just a random string.
- DO is the service — one channel = one Durable Object, internal Hono routing.
- Worker is a proxy — Worker only uses
stub.fetch()to forward to DO. No business logic. - No external DB — no D1, no R2. Channel metadata lives inside the DO.
# Production deploy
npm run deploy
# Preview version (upload without promoting)
npm run deploy:version
# Then promote via Cloudflare Dashboard → Workers → hookwire-api → VersionsEvery wrangler deploy restarts all Durable Objects, dropping active WebSocket
connections. Mitigations:
- Use gradual rollouts —
wrangler versions upload+ promote via Dashboard to minimize simultaneous disconnects. - Client SDK auto-reconnects —
HookwireClienthas exponential backoff reconnect built in. - Future: Durable Object hibernation with WS attachment serialization can preserve connections across code updates (not yet implemented).
Both WebSocket and SSE support the ?since= parameter for replay:
/ch/:name/ws → real-time only
/ch/:name/ws?since=0 → full replay + real-time
/ch/:name/ws?since=42 → replay from seq 42 + real-time
/ch/:name/sse → real-time only
/ch/:name/sse?since=0 → full replay + real-time
/ch/:name/sse?since=42 → replay from seq 42 + real-time
- Server replays history events before switching to real-time stream.
- SDK automatically appends
?since=${lastSeq}on reconnect. - Client deduplicates by seq (skips events with seq <= lastSeen).
- Retention window: max 10,000 events / 7 days. Events outside window are lost.
See the "Event Replay" section in README for consumer-facing docs.
npm test -w @hookwire/api # API e2e (vitest + app.request + mock DO stub)
npm test -w @hookwire/sdk # SDK unit (vitest + vi.fn for WebSocket/fetch)- API tests use
app.request()with mock DO stubs implementingfetch(). - SDK tests use
vi.fn()mocks forWebSocketandfetch. - No real network or Cloudflare runtime in tests.