Files
classroomio/apps/dashboard/src/lib/utils/functions/supabase.server.ts
T

25 lines
595 B
TypeScript
Raw Normal View History

2024-03-22 06:30:24 +01:00
import { PRIVATE_SUPABASE_SERVICE_ROLE } from '$env/static/private';
import { createClient, SupabaseClient } from '@supabase/supabase-js';
2024-04-20 04:39:16 +01:00
import { config } from '$lib/config';
2024-03-22 06:30:24 +01:00
export let supabase: SupabaseClient;
/**
* Should only be called on server files
*
* @returns supabase
*/
export const getServerSupabase = () => {
if (supabase) return supabase;
2024-04-20 04:39:16 +01:00
supabase = createClient(config.supabaseConfig.url, PRIVATE_SUPABASE_SERVICE_ROLE || '', {
2024-03-22 06:30:24 +01:00
auth: {
persistSession: false,
autoRefreshToken: false,
detectSessionInUrl: false
}
});
return supabase;
};