-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase-client.js
More file actions
51 lines (44 loc) · 1.38 KB
/
supabase-client.js
File metadata and controls
51 lines (44 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* supabase-client.js
* Supabase initialization and singleton instance
*
* Provides centralized access to the Supabase client used by other modules.
*/
// Supabase configuration
const SUPABASE_URL = 'https://kgnqutpeerhmlddhjoza.supabase.co';
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImtnbnF1dHBlZXJobWxkZGhqb3phIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTM0MDI0NzYsImV4cCI6MjA2ODk3ODQ3Nn0.TWQq1X9T4rQXOd13xLkBkuEhbgpn1ygm4dJtHMq4Sco';
let supabaseInstance = null;
/**
* Initialize Supabase client
* @returns {Object} Supabase client instance
*/
export function initializeSupabase() {
if (supabaseInstance) {
return supabaseInstance;
}
try {
if (typeof window.supabase === 'undefined') {
throw new Error('Supabase library not loaded from CDN');
}
supabaseInstance = window.supabase.createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
console.log('Supabase client initialized successfully');
return supabaseInstance;
} catch (error) {
console.error('Failed to initialize Supabase:', error);
return null;
}
}
/**
* Get Supabase client instance (ensures initialization)
* @returns {Object} Supabase client instance
*/
export function getSupabaseClient() {
if (!supabaseInstance) {
return initializeSupabase();
}
return supabaseInstance;
}
export default {
initializeSupabase,
getSupabaseClient
};