Files
comiaunicaty/backend/app/core/config.py

37 lines
1.2 KiB
Python

from functools import lru_cache
from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
app_name: str = "GroupHome"
environment: str = "development"
dev_mode: bool = True
server_name: str = "GroupHome Local"
server_origin: str = "http://localhost:8000"
api_base_url: str = "http://localhost:8000/api"
frontend_origin: str = "http://localhost:5173"
database_url: str = "sqlite:///./grouphome.db"
session_secret: str = "dev-change-me"
session_cookie_name: str = "grouphome_session"
cookie_secure: bool = False
cors_origins: str = "http://localhost:5173,http://127.0.0.1:5173,http://localhost:4173"
upload_dir: Path = Path("./storage/uploads")
max_upload_bytes: int = 10 * 1024 * 1024
remote_request_timeout_seconds: float = 8.0
@property
def allowed_origins(self) -> list[str]:
return [origin.strip() for origin in self.cors_origins.split(",") if origin.strip()]
@lru_cache
def get_settings() -> Settings:
settings = Settings()
settings.upload_dir.mkdir(parents=True, exist_ok=True)
return settings