feat: clone course (#582)
* feat: clone course work * feat: clone and delete a course * feat: clone and delete a course * feat: clean up * feat: attending to reviews * feat: attended to revies
This commit is contained in:
@@ -2,7 +2,7 @@ import { SupabaseClient, createClient } from '@supabase/supabase-js';
|
||||
|
||||
import { env } from '$src/config/env';
|
||||
|
||||
const { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } = env;
|
||||
const { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL, PRIVATE_SUPABASE_SERVICE_ROLE } = env;
|
||||
|
||||
export let supabase: SupabaseClient | null = null;
|
||||
|
||||
@@ -16,15 +16,9 @@ interface SupabaseConfig {
|
||||
export function getSupabase(config?: SupabaseConfig): SupabaseClient {
|
||||
if (supabase) return supabase;
|
||||
|
||||
const finalConfig = config ?? {
|
||||
supabaseConfig: {
|
||||
url: PUBLIC_SUPABASE_URL,
|
||||
anonKey: PUBLIC_SUPABASE_ANON_KEY
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
supabase = createClient(finalConfig.supabaseConfig.url, finalConfig.supabaseConfig.anonKey, {
|
||||
// Use service role key to bypass RLS policies
|
||||
supabase = createClient(PUBLIC_SUPABASE_URL, PRIVATE_SUPABASE_SERVICE_ROLE, {
|
||||
auth: { persistSession: false }
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -34,3 +28,4 @@ export function getSupabase(config?: SupabaseConfig): SupabaseClient {
|
||||
|
||||
return supabase;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user