sitcod3 commited on
Commit
f566598
·
verified ·
1 Parent(s): 3840483

Upload src/lib/supabaseClient.ts with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/lib/supabaseClient.ts +27 -0
src/lib/supabaseClient.ts ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createClient } from '@supabase/supabase-js';
2
+
3
+ const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
4
+ const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
5
+
6
+ export const supabase = supabaseUrl && supabaseAnonKey
7
+ ? createClient(supabaseUrl, supabaseAnonKey)
8
+ : null;
9
+
10
+ export const isSupabaseConfigured = () => {
11
+ return !!supabase;
12
+ };
13
+
14
+ /** Project ref derived from VITE_SUPABASE_URL (for status text + links). */
15
+ export const supabaseProjectRef = (): string => {
16
+ const url = import.meta.env.VITE_SUPABASE_URL as string | undefined;
17
+ const m = url?.match(/^https:\/\/([a-z0-9-]+)\.supabase\.co/i);
18
+ return m ? m[1] : "unconfigured";
19
+ };
20
+
21
+ /** Deep link to the configured project (or the dashboard when unset). */
22
+ export const supabaseDashboardUrl = (): string => {
23
+ const ref = supabaseProjectRef();
24
+ return ref === "unconfigured"
25
+ ? "https://supabase.com/dashboard"
26
+ : `https://supabase.com/dashboard/project/${ref}`;
27
+ };