Spaces:
Running
Running
Download backend/app/core/supabase.py from axeronis/microfunnel-api: direct link, hf CLI and curl.
- Browser
- Download file 848 Bytes
-
https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/backend/app/core/supabase.py
- Command line
-
hf download hf://spaces/axeronis/microfunnel-api/backend/app/core/supabase.py
-
curl -L -o supabase.py https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/backend/app/core/supabase.py
848 Bytes
| from supabase import create_client, Client | |
| from app.core.config import settings | |
| def get_supabase_client() -> Client: | |
| """ | |
| Get or create Supabase client. | |
| Prefers SERVICE_KEY (bypasses RLS) over regular KEY. | |
| """ | |
| if not settings.SUPABASE_URL: | |
| raise RuntimeError("SUPABASE_URL not configured") | |
| # Use service key if available (bypasses RLS policies) | |
| # Otherwise fallback to regular key for backward compatibility | |
| api_key = settings.SUPABASE_SERVICE_KEY or settings.SUPABASE_KEY | |
| if not api_key: | |
| raise RuntimeError("SUPABASE_KEY or SUPABASE_SERVICE_KEY required") | |
| return create_client(settings.SUPABASE_URL, api_key) | |
| # Global accessibility | |
| supabase_client = get_supabase_client() if (settings.SUPABASE_URL and (settings.SUPABASE_SERVICE_KEY or settings.SUPABASE_KEY)) else None | |