Patch Roulette manages Paper update work through a Cloudflare Worker, a Durable Object SQLite database, and a SvelteKit web interface.
Note
This project is intended for internal use and does not guarantee stability, compatibility, support, or semantic versioning.
- The Cloudflare Worker serves both the SvelteKit UI and the API.
- API routes are under
/apiand are used directly by browser and CLI clients; see docs/api.md. - A single Durable Object owns the SQLite database and serializes patch claims.
- Drizzle ORM manages the Durable Object schema and migrations.
- Cloudflare Access protects every deployed hostname and every route, including
/api. - Managed OAuth supplies CLI authentication. The application has no custom API-token system.
The Worker trusts Cloudflare Access as the authentication boundary. It extracts the iss and sub claims from Cf-Access-Jwt-Assertion and maps that external identity to an internal user. The deployed workers.dev or custom hostname must therefore be protected by the Access application; do not leave an alternate hostname unprotected.
Install the dependencies:
bun installRun the Vite frontend and local Worker together:
bun run devThe local Worker uses a fixed development identity and local Durable Object SQLite state. Wrangler's normal local persistence is left enabled. Reset it with:
bun run db:resetGenerate Drizzle migrations after changing src/lib/db/schema.ts:
bun run db:generatebun run check
bun run format:check
bun run lint
bun run test
bunx wrangler deploy --config wrangler.jsonc --dry-runThe temporary Spring-to-Worker migration procedure is documented in docs/legacy.md.
Build and deploy the Worker:
bun run deployConfigure Cloudflare Access separately for the actual hostname used by the deployment. Protect the entire hostname, including /api/* and the Managed OAuth discovery endpoints. If both a workers.dev hostname and a custom hostname are reachable, protect both or disable the unused hostname.