const { createClient } = require('@supabase/supabase-js'); require('dotenv').config(); const supabaseUrl = process.env.SUPABASE_URL; const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY; const anonKey = process.env.SUPABASE_ANON_KEY; const supabaseKey = serviceRoleKey || anonKey; if (!supabaseUrl) { throw new Error('Variável SUPABASE_URL não configurada. Defina-a no arquivo .env.'); } if (!supabaseKey) { throw new Error('Defina SUPABASE_SERVICE_ROLE_KEY (recomendado) ou SUPABASE_ANON_KEY no arquivo .env.'); } const supabase = createClient(supabaseUrl, supabaseKey); module.exports = supabase;