Files
madbase/tests/integration/setup.ts
Vlad Durnea a66d908eff
Some checks failed
CI / podman-build (push) Has been cancelled
CI / rust (push) Has been cancelled
chore: full stack stability and migration fixes, plus react UI progress
2026-03-18 09:01:38 +02:00

38 lines
1.1 KiB
TypeScript

import { createClient, SupabaseClient } from '@supabase/supabase-js';
import dotenv from 'dotenv';
import path from 'path';
dotenv.config({ path: path.resolve(process.cwd(), '../../.env') });
const SUPABASE_URL = process.env.MADBASE_URL || 'http://localhost:8000';
const SUPABASE_ANON_KEY = process.env.MADBASE_ANON_KEY || '';
const SUPABASE_SERVICE_ROLE_KEY = process.env.MADBASE_SERVICE_ROLE_KEY || '';
if (!SUPABASE_ANON_KEY || !SUPABASE_SERVICE_ROLE_KEY) {
throw new Error('Missing MADBASE_ANON_KEY or MADBASE_SERVICE_ROLE_KEY');
}
export const createAnonClient = (): SupabaseClient => {
return createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
auth: {
persistSession: false,
autoRefreshToken: false,
},
global: {
headers: {
'x-project-ref': 'default',
},
},
accessToken: async () => SUPABASE_ANON_KEY,
});
};
export const createServiceRoleClient = (): SupabaseClient => {
return createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
auth: {
persistSession: false,
autoRefreshToken: false,
},
});
};