Tldraw/apps/dotcom-worker
Mitja Bezenšek ddebf3fc5c
Move storing of snapshots to R2 (#3693)
Instead of storing them in supabse we will store them in r2.

I have already created `room-snapshots` and `room-snapshots-preview`
buckets on cloudflare.

We could also migrate all the data from supabase, but it seems we
haven't done so for the rooms, so I also didn't look into doing it for
snapshots.

One slight drawback of moving to R2 is that it's harder to query data by
parent slug. So answering questions like which room is the parent to the
most snapshots is a bit harder to answer. Instead of just a simple query
we'd need to do some custom logic to go through the bucket. Not sure if
have ever needed this info though.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [ ] `sdk` — Changes the tldraw SDK
- [x] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [x] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know


### Test Plan

Existing snapshots:

1. Load an existing snapshot. It should still load correctly. The best
way to do that is probably to generate a few of them in advance.

New snapshots:
1. Create a new room.
2. Create a few snapshot links.
3. They should work.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Move storing of snapshots to cloudflare R2.
2024-05-08 09:06:02 +00:00
..
scripts
src/lib Move storing of snapshots to R2 (#3693) 2024-05-08 09:06:02 +00:00
.gitignore
CHANGELOG.md
README.md
package.json
tsconfig.json
wrangler.toml Move storing of snapshots to R2 (#3693) 2024-05-08 09:06:02 +00:00

README.md

@tldraw/tlsync-worker

Enable database persistence for local dev

The values for env.SUPABASE_KEY and env.SUPABASE_URL are stored in the Cloudflare Workers dashboard for this worker. However we use --local mode for local development, which doesn't read these values from the dashboard.

To workaround this, create a file called .dev.vars under merge-server with the required values (which you can currently find at https://app.supabase.com/project/bfcjbbjqflgfzxhskwct/settings/api). This will be read by wrangler dev --local and used to populate the environment variables.

SUPABASE_URL=<url>
SUPABASE_KEY=<key>