PostHog / squeak

A Q&A widget for your docs
https://squeak.posthog.com/
MIT License
176 stars 15 forks source link

Supabase -> internal api/postgres refactor #191

Closed ajsharp closed 2 years ago

ajsharp commented 2 years ago

This PR moves squeak off supabase and replaces it with an internal rest API backed by postgres.

Most of the changes in this PR are essentially moving what previously were supabase client-side queries into internal API endpoints.

Prisma

I decided to go with Prisma as the ORM/database driver. It seems to have the best native typescript support, and overall seems like the most robust orm library currently. There are three core pieces to prisma: migrations, the client and the schema, and all work together.

Sessions

One of the other key differences is in how sessions are handled. Supabase issued JWTs; we now simply issue an encrypted session cookie. Adding support for JWTs would be trivial, but encrypted session cookies was simpler and works for our needs.

Related: https://github.com/PostHog/squeak-react/pull/57