- Add config.py with pydantic-settings for env configuration - Add database.py with async SQLAlchemy (asyncpg driver) - Add Grant model with id, token, timestamps, and grant_type - Use Literal[public, private] for type-safe enum storage - Add routes/links.py with Pydantic request/response models - Update pyproject.toml dependencies
32 lines
875 B
Python
32 lines
875 B
Python
from dataclasses import dataclass
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
env_file = Path(__file__).parent.parent / ".env"
|
|
|
|
|
|
@dataclass
|
|
class Settings(BaseSettings):
|
|
"""Settings for the Myst application.
|
|
|
|
Args:
|
|
app_name (str): The name of the application.
|
|
database_url (str): The URL of the database.
|
|
forgejo_base_url (str): The base URL of the Forgejo instance.
|
|
forgejo_pat (str): The Forgejo personal access token.
|
|
"""
|
|
|
|
app_name: str = "Myst"
|
|
database_url: str = "postgresql://myst:myst@db:5432/myst_db"
|
|
forgejo_base_url: str = ""
|
|
forgejo_pat: str = ""
|
|
|
|
model_config = SettingsConfigDict(env_file=str(env_file))
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
"""Get the settings for the application."""
|
|
return Settings()
|