/**
 * Shared Supabase client configuration for Edge Functions
 */

import { createClient } from 'https://esm.sh/@supabase/supabase-js@2';

export function createSupabaseClient(authHeader: string) {
  return createClient(
    Deno.env.get('SUPABASE_URL') ?? '',
    Deno.env.get('SUPABASE_ANON_KEY') ?? '',
    {
      global: {
        headers: {
          Authorization: authHeader,
          apikey: Deno.env.get('SUPABASE_ANON_KEY') ?? '',
        },
      },
    }
  );
}

export function createServiceClient() {
  return createClient(
    Deno.env.get('SUPABASE_URL') ?? '',
    Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') ?? ''
  );
}
