Skip to content

Commit 0e26f92

Browse files
author
Joel Lee
committed
chore: rename and update README
1 parent 5c93da6 commit 0e26f92

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Functions-py
2+
3+
4+
## Installation
5+
6+
`pip3 install supafunc`
7+
8+
## Usage
9+
10+
Deploy your function as per documentation.
11+
12+
13+
```python3
14+
15+
from supafunc import FunctionsClient
16+
async def run_func():
17+
fc = FunctionsClient("https://<project_ref>.functions.supabase.co", {})
18+
res = await fc.invoke("payment-sheet", {"responseType": "json"})
19+
20+
if __name__ == "__main__":
21+
asyncio.run(run_func())
22+
```

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[tool.poetry]
2-
name = "functionz"
2+
name = "supafunc"
33
version = "0.1.0"
44
description = ""
55
authors = ["Joel Lee <[email protected]>"]
66
license = "MIT"
77

88
[tool.poetry.dependencies]
99
python = "^3.9"
10-
10+
httpx = "^0.22.0"
1111
[tool.poetry.dev-dependencies]
1212

1313
[build-system]

supafunc/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__version__ = "0.1.0"
2+
3+
__all__ = ['supafunc']

functionz/functionz.py renamed to supafunc/supafunc.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Dict
22
import httpx
3-
3+
import asyncio
44

55
class FunctionsClient:
66
def __init__(self, url: str, headers: Dict):
@@ -11,12 +11,12 @@ async def invoke(self, function_name: str, invoke_options: Dict):
1111
try:
1212
headers = invoke_options.get('headers')
1313
body = invoke_options.get('body')
14-
response = await httpx.post(f"{self.url}/{function_name}", headers=headers)
14+
response = httpx.post(f"{self.url}/{function_name}", headers=headers)
1515
is_relay_error = response.headers.get('x-relay-header')
1616
if is_relay_error and is_relay_error == 'true':
1717
return {
1818
"data": None,
19-
"error": response.tex
19+
"error": response.text
2020
}
2121
# TODO: Convert type accordingly
2222

@@ -26,3 +26,12 @@ async def invoke(self, function_name: str, invoke_options: Dict):
2626
"data": None,
2727
"error": e
2828
}
29+
30+
async def run_func():
31+
fc = FunctionsClient("https://aipvgapcvmokjooimzlr.functions.supabase.co", {})
32+
res = await fc.invoke("payment-sheet", {"responseType": "json"})
33+
34+
if __name__ == "__main__":
35+
asyncio.run(run_func())
36+
37+

0 commit comments

Comments
 (0)