Cloudflare
Code lives in hosts/cloudflare. Protocol handling is shared (shared/http, shared/api); this package is the Worker + D1 + Durable Object wiring.
Storage
Bags live in D1. The important batch methods:
setBags (PUSH)
- Builds one
INSERT … SELECT COALESCE(MAX(seq),0)+1 … RETURNING seqper bag (seq allocated in SQL). - Runs statements with
D1.batch(one SQL transaction per chunk of ≤500 statements). - Returns the assigned seq list to the PUSH handler for the response and NOTF fan-out.
getBodies (PULL)
SELECT seq, bodyCph FROM bags WHERE userPubKey = ? AND seq IN (…)in chunks of ≤99 seq binds (~100 bound variables per statement on D1/SQLite; one slot isuserPubKey). Same chunking on Deno/Bun hosts.- Returns only rows that exist.
See host storage, PUSH, PULL.
Realtime
- [x] Durable Objects notify clients over websocket (
WebSocketServerV2). - [ ] Store large bodies in R2, indexed by D1 (optional scale-out).

