Cloudflare Worker server for the YAOS Obsidian plugin. It relays Yjs CRDT updates through a Durable Object and stores attachments plus snapshots in R2.
- One vault maps to one Durable Object-backed sync room.
- Yjs sync runs through
y-partyserver. - Durable Object storage persists the live CRDT snapshot.
- Attachments are uploaded through the Worker and stored in R2.
- Snapshots are gzipped CRDT archives stored in R2.
- Auth uses the claimed setup token by default, with
SYNC_TOKENas an optional hard override.
cd server
npm install
npm run dev -- --var SYNC_TOKEN:dev-sync-tokenThe local Worker will be served by Wrangler. Use its printed local URL as the plugin's Server host.
Passing SYNC_TOKEN locally is optional. If you omit it, the server starts unclaimed and you can claim it in a browser.
Use the Deploy to Cloudflare button above for the default setup. It targets the server/ subdirectory so Cloudflare treats this folder as the project root.
This repo intentionally keeps .env.example free of assignments so the deploy flow does not prompt for SYNC_TOKEN by default.
The local wrangler.toml in this directory defines:
- the Worker entrypoint (
server/src/index.ts) - the
VaultSyncServerDurable Object binding - the
ServerConfigDurable Object binding
The default deploy is text-only:
- no
SYNC_TOKENsecret is required up front - no R2 binding is required up front
- the first browser visit shows the claim page
That claim page generates a token in the browser and returns an obsidian://yaos?... setup link you can use to configure the plugin.
The Deploy to Cloudflare button creates a new repository in your own Git account and connects this Worker to that new repo.
That means future pushes to your generated repo will redeploy automatically, but future pushes to the original kavinsood/yaos template repo will not update your existing Worker on their own.
To pick up new YAOS changes later:
- Add your generated repo URL in the plugin settings (
Deployment repo URL). - Use Initialize updater once (GitHub) if workflows are missing.
- Use Open update action from plugin settings and run the update workflow.
- Cloudflare redeploys automatically after the workflow push.
cd server
npm install
npm run deployIf you want attachments and snapshots later:
- Create an R2 bucket in the Cloudflare dashboard.
- Open your Worker in Workers & Pages.
- Add an R2 binding named
YAOS_BUCKET.
The same Worker will then begin reporting attachments and snapshots as available.
wss://<host>/vault/sync/<vaultId>?token=<setup-token>
POST /vault/<vaultId>/blobs/existsPUT /vault/<vaultId>/blobs/<sha256>GET /vault/<vaultId>/blobs/<sha256>
POST /vault/<vaultId>/snapshots/maybePOST /vault/<vaultId>/snapshotsGET /vault/<vaultId>/snapshotsGET /vault/<vaultId>/snapshots/<snapshotId>
GET /vault/<vaultId>/debug/recent
All HTTP endpoints require Authorization: Bearer <setup-token> once the server has been claimed.
If you set SYNC_TOKEN, that environment value becomes the required token instead.
- Blob uploads are capped at 10 MB by default.
- Blob existence checks use bounded concurrency.
- Snapshot creation is daily-idempotent through the
/snapshots/mayberoute. - Snapshot archives are stored compressed to keep R2 usage modest.
The canonical infrastructure config lives in this server/ directory, and the Deploy to Cloudflare button should target the server/ subdirectory path in GitHub.