52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
"""Application configuration via pydantic-settings."""
|
|
|
|
from functools import lru_cache
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# App
|
|
APP_NAME: str = "AGP Backend"
|
|
APP_VERSION: str = "0.1.0"
|
|
DEBUG: bool = True
|
|
|
|
# Database (async)
|
|
DATABASE_URL: str = "postgresql+asyncpg://agp_user:agp_password@localhost:5432/agp_db"
|
|
|
|
# Redis
|
|
REDIS_URL: str = "redis://localhost:6379/0"
|
|
|
|
# JWT / Auth
|
|
SECRET_KEY: str = "change-me-to-a-secure-random-string"
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
|
|
|
# CORS
|
|
CORS_ORIGINS: str = "http://localhost:8080,http://localhost:3000"
|
|
|
|
# File uploads
|
|
UPLOAD_DIR: str = "uploads"
|
|
MAX_UPLOAD_SIZE_MB: int = 100
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=True,
|
|
extra="ignore",
|
|
)
|
|
|
|
@property
|
|
def cors_origins_list(self) -> list[str]:
|
|
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
|
|
|
|
|
|
@lru_cache()
|
|
def get_settings() -> Settings:
|
|
"""Return cached settings instance."""
|
|
return Settings()
|
|
|
|
|
|
# Convenience singleton
|
|
settings = get_settings()
|