Musadiq7860 commited on
Commit
45a0fac
·
1 Parent(s): 86c1ac3

fix: restore get_supabase_client for other routers to fix RUNTIME_ERROR

Browse files
Files changed (1) hide show
  1. db/supabase_client.py +10 -0
db/supabase_client.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  import httpx
 
3
  from dotenv import load_dotenv
4
 
5
  load_dotenv()
@@ -26,3 +27,12 @@ def supabase_rest_call(method: str, endpoint: str, json_data: dict = None) -> li
26
  response.raise_for_status()
27
  return response.json()
28
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import httpx
3
+ from supabase import create_client, Client
4
  from dotenv import load_dotenv
5
 
6
  load_dotenv()
 
27
  response.raise_for_status()
28
  return response.json()
29
 
30
+ _client: Client | None = None
31
+
32
+ def get_supabase_client() -> Client:
33
+ """Return a cached Supabase client using the service role key."""
34
+ global _client
35
+ if _client is None:
36
+ _client = create_client(SUPABASE_URL, SUPABASE_SERVICE_KEY)
37
+ return _client
38
+