38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { createClient } from '@supabase/supabase-js';
|
|
import type { Database } from './database.types';
|
|
|
|
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
|
|
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
|
|
|
|
// Check if Supabase is configured
|
|
export const isSupabaseConfigured = !!(supabaseUrl && supabaseAnonKey &&
|
|
supabaseUrl !== 'https://your-project-ref.supabase.co' &&
|
|
supabaseAnonKey !== 'your-anon-key-here');
|
|
|
|
// Use fallback values for development if not configured
|
|
const fallbackUrl = 'https://demo.supabase.co';
|
|
const fallbackKey = 'demo-key';
|
|
|
|
export const supabase = createClient<Database>(
|
|
supabaseUrl || fallbackUrl,
|
|
supabaseAnonKey || fallbackKey,
|
|
{
|
|
auth: {
|
|
autoRefreshToken: isSupabaseConfigured,
|
|
persistSession: isSupabaseConfigured,
|
|
detectSessionInUrl: isSupabaseConfigured
|
|
}
|
|
}
|
|
);
|
|
|
|
// Auth helpers
|
|
export const auth = supabase.auth;
|
|
|
|
// Database helpers
|
|
export const db = supabase.from;
|
|
|
|
// Storage helpers
|
|
export const storage = supabase.storage;
|
|
|
|
// Real-time helpers
|
|
export const channel = supabase.channel;
|