Skip to content

Commit 9e9942b

Browse files
author
Joel Lee
committed
feat: add magic
1 parent c633b4a commit 9e9942b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ postgrest-py = ">=0.9.1,<0.11.0"
2020
realtime = "^0.0.4"
2121
gotrue = "^0.5.0"
2222
httpx = "^0.21.3"
23+
supafunc="^0.1.0"
2324

2425
[tool.poetry.dev-dependencies]
2526
pre-commit = "^2.17.0"

supabase/client.py

+13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import re
12
from typing import Any, Dict
23

34
from httpx import Response
45
from postgrest_py import SyncPostgrestClient, SyncRequestBuilder
6+
from supafunc import FunctionsClient
57

68
from supabase.lib.auth_client import SupabaseAuthClient
79
from supabase.lib.client_options import ClientOptions
@@ -42,6 +44,14 @@ def __init__(
4244
self.realtime_url: str = f"{supabase_url}/realtime/v1".replace("http", "ws")
4345
self.auth_url: str = f"{supabase_url}/auth/v1"
4446
self.storage_url = f"{supabase_url}/storage/v1"
47+
is_platform = re.search(r"(supabase\.co)|(supabase\.in)", supabase_url)
48+
if is_platform:
49+
url_parts = supabase_url.split(".")
50+
self.functions_url = (
51+
f"{url_parts[0]}.functions.{url_parts[1]}.{url_parts[2]}"
52+
)
53+
else:
54+
self.functions_url = f"{supabase_url}/functions/v1"
4555
self.schema: str = options.schema
4656

4757
# Instantiate clients.
@@ -62,6 +72,9 @@ def __init__(
6272
headers=options.headers,
6373
)
6474

75+
def functions(self):
76+
return FunctionsClient(self.functions_url, self._get_auth_headers())
77+
6578
def storage(self) -> SupabaseStorageClient:
6679
"""Create instance of the storage client"""
6780
return SupabaseStorageClient(self.storage_url, self._get_auth_headers())

0 commit comments

Comments
 (0)