sveltejs / api.svelte.dev

The API worker source for https://api.svelte.dev
14 stars 4 forks source link

Relinquish OAuth responsibilities #19

Closed Rich-Harris closed 2 years ago

Rich-Harris commented 2 years ago

18

Rich-Harris commented 2 years ago

I took the opportunity to tweak a couple of things — I kept getting confused about what uid meant in different contexts, so I moved towards more specific things like gistid, guestid, userid and so on. If that's a terrible decision we can revert, but I figured we're going to need to update the migration process anyway to remove some of these rough edges so now would be a good time to do this sort of thing.

Speaking of which, how does the migration work? Where does the script live? Should it be in this repo?

Rich-Harris commented 2 years ago

Made a decent amount of progress on here and https://github.com/sveltejs/sites/pull/78 — you can log in, create gists, fork and save them.

But I think I've hit a bit of a roadblock with https://svelte.dev/apps. There's really no good way to paginate data in a KV store. We could fudge it, by slicing the array in the worker — would be fine in practice at the scales we're dealing with — but it sort of defeats the point of pagination. That, combined with the observation that we have to maintain a list of ownership separately from the gists themselves (synced non-transactionally), and the fact that there's no good way to periodically purge expired sessions, eventually forced me to conclude that we're just using the wrong tool for the job. KV is great for docs, but for gists/sessions/todos we need a relational database.

I'm going to investigate Supabase and see if it'll work for our needs.

Rich-Harris commented 2 years ago

Supabase is working well on https://github.com/sveltejs/sites/pull/78, so I've removed all the auth/gists stuff from here. Have left the todos stuff until the Kit template can be updated to also use Supabase