feat: add Supabase CLI scaffold and client SDK setup

Initializes the local Supabase project (supabase/config.toml) and adds
a thin src/lib/supabase.ts wrapper around @supabase/supabase-js that
reads connection details from Vite env vars, tested with a mocked
createClient.
This commit is contained in:
belviskhoremk
2026-08-08 12:46:42 +00:00
parent 7d8d89d0fc
commit d98d66b066
8 changed files with 559 additions and 0 deletions

22
src/lib/supabase.test.ts Normal file
View File

@@ -0,0 +1,22 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
const createClientMock = vi.fn(() => ({ type: 'mock-supabase-client' }))
vi.mock('@supabase/supabase-js', () => ({ createClient: createClientMock }))
describe('supabase client setup', () => {
beforeEach(() => {
vi.resetModules()
createClientMock.mockClear()
})
it('creates the client with the URL and anon key read from Vite env vars', async () => {
vi.stubEnv('VITE_SUPABASE_URL', 'https://test-project.supabase.co')
vi.stubEnv('VITE_SUPABASE_ANON_KEY', 'test-anon-key')
const { supabase } = await import('./supabase')
expect(createClientMock).toHaveBeenCalledWith('https://test-project.supabase.co', 'test-anon-key')
expect(supabase).toEqual({ type: 'mock-supabase-client' })
})
})

6
src/lib/supabase.ts Normal file
View File

@@ -0,0 +1,6 @@
import { createClient } from '@supabase/supabase-js'
export const supabase = createClient(
import.meta.env.VITE_SUPABASE_URL,
import.meta.env.VITE_SUPABASE_ANON_KEY,
)