myst/web/app/config.py
ZTatman dcf60f4082 Add FastAPI lifespan pattern with async SQLAlchemy and Docker setup
- Move get_db to main.py for cleaner separation of concerns
- Remove engine/sessionmaker from database.py (keep only Base class)
- Fix config.py: add +asyncpg to database_url, remove @dataclass
- Add lifespan context manager for engine lifecycle
- Add docker-compose.yml for web + postgres services
- Add web/Dockerfile for containerized FastAPI app
- Add web/.env.example as environment template
2026-04-24 13:27:58 -04:00

23 lines
593 B
Python

from functools import lru_cache
from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
env_file = Path(__file__).parent.parent / ".env"
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
app_name: str = "Myst"
database_url: str = "postgresql+asyncpg://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:
"""Cached settings instance."""
return Settings()