feat(app): optional Supabase connection in runtime config + lazy typed client

- env.ts: supabase: SupabaseConnection | null resolved from env.js
  (supabaseUrl/supabaseAnonKey), VITE_SUPABASE_*, else null; half config refused
- lib/supabase.ts: getSupabaseClient() null when unconfigured, one client per URL
- entrypoint.sh writes the two public values; .env.example placeholders
- Dockerfile copies packages/supabase manifest for the install layer
- no UI change; 7 new tests (278 app)
This commit is contained in:
bchanot committed 2026-10-08 22:43:18 +02:00
1 parent ce76c6597a
commit d239374d81
9 files changed
+153 -23

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { describe, it, expect } from 'vitest'
import { getSupabaseClient, isSupabaseConfigured } from '@/lib/supabase'
import type { AppConfig } from '@/config/env'
const base: AppConfig = {
siteName: 'S',
brandName: 'B',
footerName: 'F',
tagline: 'T',
supabase: null,
}
describe('getSupabaseClient', () => {
it('returns null when no backend is configured (current default)', () => {
expect(getSupabaseClient(base)).toBeNull()
expect(isSupabaseConfigured(base)).toBe(false)
})
it('creates one client per connection and reuses it', () => {
const configured: AppConfig = {
...base,
supabase: { url: 'http://127.0.0.1:54321', anonKey: 'anon' },
}
const first = getSupabaseClient(configured)
expect(first).not.toBeNull()
expect(getSupabaseClient(configured)).toBe(first)
expect(isSupabaseConfigured(configured)).toBe(true)
})
})