forked from deco-cx/deco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupabase.ts
26 lines (20 loc) · 946 Bytes
/
supabase.ts
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
import { supabase } from "./deps.ts";
let client: supabase.SupabaseClient | null = null;
// From supabase docs:
// "This key is safe to use in a browser if you have enabled Row Level Security for your tables and configured policies."
export const SUPABASE_LIVE_ENDPOINT =
"https://ozksgdmyrqcxcwhnbepg.supabase.co";
export const SUPABASE_LIVE_ANON_KEY =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im96a3NnZG15cnFjeGN3aG5iZXBnIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTY3MjM3NDYsImV4cCI6MTk3MjI5OTc0Nn0.HMdsG6NZlq6dvYFCK1_tuJh38TmsqLeN8H4OktTHt_M";
let userEndpoint = SUPABASE_LIVE_ENDPOINT;
let userKey = SUPABASE_LIVE_ANON_KEY;
export function setupSupabase(endpoint: string, key: string) {
userEndpoint = endpoint;
userKey = key;
}
export default function getSupabaseClient(accessToken?: string) {
if (!client) {
client = supabase.createClient(userEndpoint, accessToken || userKey);
}
return client;
}