feat(*): first mvp
This commit is contained in:
3
backend/src/utils/convex/__init__.py
Normal file
3
backend/src/utils/convex/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .client import ConvexClient
|
||||
|
||||
__all__ = ["ConvexClient"]
|
||||
21
backend/src/utils/convex/client.py
Normal file
21
backend/src/utils/convex/client.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
from convex import ConvexClient as SyncConvexClient
|
||||
|
||||
|
||||
class ConvexClient:
|
||||
def __init__(self, url: str) -> None:
|
||||
self._client = SyncConvexClient(url)
|
||||
|
||||
async def query(self, name: str, args: dict[str, Any] | None = None) -> Any: # noqa: ANN401
|
||||
return await asyncio.to_thread(self._client.query, name, args or {})
|
||||
|
||||
async def mutation(self, name: str, args: dict[str, Any] | None = None) -> Any: # noqa: ANN401
|
||||
return await asyncio.to_thread(self._client.mutation, name, args or {})
|
||||
|
||||
async def action(self, name: str, args: dict[str, Any] | None = None) -> Any: # noqa: ANN401
|
||||
return await asyncio.to_thread(self._client.action, name, args or {})
|
||||
|
||||
def subscribe(self, name: str, args: dict[str, Any] | None = None) -> Any: # noqa: ANN401
|
||||
return self._client.subscribe(name, args or {})
|
||||
@@ -6,6 +6,10 @@ class BotSettings(BaseSettings):
|
||||
token: SecretStr
|
||||
|
||||
|
||||
class SiteSettings(BaseSettings):
|
||||
url: str = Field(default="https://localhost")
|
||||
|
||||
|
||||
class LogSettings(BaseSettings):
|
||||
level: str = "INFO"
|
||||
level_external: str = "WARNING"
|
||||
@@ -15,6 +19,7 @@ class LogSettings(BaseSettings):
|
||||
|
||||
class Settings(BaseSettings):
|
||||
bot: BotSettings
|
||||
site: SiteSettings
|
||||
log: LogSettings
|
||||
|
||||
convex_url: str = Field(validation_alias=AliasChoices("CONVEX_SELF_HOSTED_URL"))
|
||||
|
||||
Reference in New Issue
Block a user