All checks were successful
Backend CI / unit-test (push) Successful in 34s
* api calls for auth * exchange now bind to user
35 lines
883 B
Python
35 lines
883 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
import yaml
|
|
from pydantic import ConfigDict
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
host: str = "0.0.0.0" # noqa: S104
|
|
port: int = 8000
|
|
workers: int = 1
|
|
log_level: str = "info"
|
|
database_url: str = "sqlite:///:memory:"
|
|
api_base: str = "/api/v1"
|
|
session_expiry_seconds: int = 3600 * 24 * 7 # 7 days
|
|
hmac_key: str | None = None
|
|
|
|
model_config = ConfigDict(env_file=".env", env_file_encoding="utf-8")
|
|
|
|
|
|
def load_settings() -> Settings:
|
|
cfg_path = os.getenv("CONFIG_FILE")
|
|
if cfg_path and Path(cfg_path).exists():
|
|
with Path(cfg_path).open(encoding="utf-8") as f:
|
|
data: dict[str, Any] = yaml.safe_load(f) or {}
|
|
return Settings(**data)
|
|
return Settings()
|
|
|
|
|
|
settings = load_settings()
|