Skip to content

Latest commit

 

History

334 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Patch Roulette

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.

Architecture

  • The Cloudflare Worker serves both the SvelteKit UI and the API.
  • API routes are under /api and 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.

Development

Install the dependencies:

bun install

Run the Vite frontend and local Worker together:

bun run dev

The 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:reset

Generate Drizzle migrations after changing src/lib/db/schema.ts:

bun run db:generate

Checks

bun run check
bun run format:check
bun run lint
bun run test
bunx wrangler deploy --config wrangler.jsonc --dry-run

Migration

The temporary Spring-to-Worker migration procedure is documented in docs/legacy.md.

Deployment

Build and deploy the Worker:

bun run deploy

Configure 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.

Sponsor this project

Used by

Contributors

Languages