Port from Supabase to Neon + Better Auth#5
Merged
Conversation
Move the database to Neon (plain Postgres, server-side pg pool) and replace Supabase Auth with Better Auth (cookie sessions). Removes all Supabase deps. Database: - server/db.js points at DATABASE_URL with SSL; single data-access path - migrations moved supabase/ -> db/migrations/; user-id columns uuid -> text to match Better Auth ids; RLS migration dropped (auth.uid() is Supabase-only) - all Supabase SDK queries (.from/.rpc) and the PostgREST waitlist fetch rewritten to parameterized SQL across API routes, resolveHandler, idempotency Auth: - lib/auth.js (server instance + getUserFromRequest), lib/authClient.js (browser), pages/api/auth/[...all].js handler - user.create hook mirrors each auth user into the domain users table (users.id == user.id, display_name from signup, 2000 starting points) - frontend Bearer-token plumbing removed; same-origin cookies carry the session - deleted server/supabase*.js and lib/supabase.js Tests rewritten to run against Neon via pg. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the database to Neon (plain Postgres, accessed via a server-side
pgpool) and replaces Supabase Auth with Better Auth (cookie sessions). All Supabase dependencies are removed. Per the decision during planning, this is a clean slate — no data/user migration.Database → Neon
server/db.jspoints atDATABASE_URLwith SSL; it's the single data-access path.supabase/→db/migrations/; user-id columns switcheduuid→textto match Better Auth ids.auth.uid()is Supabase-only and adds nothing to a server-only pool). Themarket_resolve_with_ledgerRPC ports unchanged..from().select().eq(),.rpc()) and the PostgREST waitlistfetchrewritten to parameterized SQL across API routes,resolveHandler.js, andidempotency.js.Auth → Better Auth
lib/auth.js(server instance +getUserFromRequest),lib/authClient.js(browser),pages/api/auth/[...all].js.user.createhook mirrors each auth user into the domainuserstable (users.id == user.id,display_namefrom signup, 2000 starting points).server/supabase*.jsandlib/supabase.js.Verification
npm run build✅npm run test:db✅ andnpm test✅ — 12/12 integration assertions against Neon (resolve flow, ledger payouts, idempotency, auth guard).users.id == "user".idwith passwords stored.Deploy notes
Set
DATABASE_URL,BETTER_AUTH_SECRET, andBETTER_AUTH_URL(prod URL) as environment variables. Neon schema is already migrated.🤖 Generated with Claude Code