Spaces:
Sleeping
Sleeping
File size: 627 Bytes
86ac4e1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | """Lazy-initialised Supabase client (uses service-role key → bypasses RLS)."""
from __future__ import annotations
from supabase import create_client, Client
from config import SUPABASE_URL, SUPABASE_SERVICE_KEY
_client: Client | None = None
def get_supabase() -> Client:
global _client
if _client is None:
if not SUPABASE_URL or not SUPABASE_SERVICE_KEY:
raise RuntimeError(
"SUPABASE_URL and SUPABASE_SERVICE_KEY must be set in .env "
"→ see .env.example"
)
_client = create_client(SUPABASE_URL, SUPABASE_SERVICE_KEY)
return _client
|