from pydantic_settings import BaseSettings from datetime import timedelta class Settings(BaseSettings): # ========================= # ENVIRONMENT # ========================= ENV: str # ========================= # DATABASE # ========================= DATABASE_HOST: str DATABASE_PORT: int DATABASE_USER: str DATABASE_PASSWORD: str DATABASE_NAME: str # ========================= # FASTAPI # ========================= DEBUG: bool = True APP_TITLE: str = "MokPyo API" APP_VERSION: str = "1.0.0" APP_DESCRIPTION: str = "MokPyo" APP_DOMAIN: str = "localhost" STATIC_DIR: str = "app/static" # ========================= # SERVER # ========================= HOST: str = "0.0.0.0" PORT: int = 8000 UVICORN_WORKERS: int = 4 # ========================= # SECURITY / AUTH # ========================= SECRET_KEY: str ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 ALGORITHM: str = "HS256" # ========================= # EMAIL (optionnel) # ========================= SMTP_HOST: str = "" SMTP_PORT: int = 587 SMTP_USER: str = "" SMTP_PASSWORD: str = "" EMAIL_FROM: str = "" # ========================= # LOGGING # ========================= LOG_LEVEL: str = "INFO" LOG_FILE: str = "logs/app.log" # ========================= # UPLOADS / FILES # ========================= MAX_UPLOAD_SIZE: int = 10_485_760 # 10 MB # ========================= # ORJSON # ========================= ORJSON_STRICT: bool = True @property def database_url(self) -> str: return f"mysql+://{self.DATABASE_USER}:{self.DATABASE_PASSWORD}@{self.DATABASE_HOST}:{self.DATABASE_PORT}/{self.DATABASE_NAME}" @property def access_token_expire(self) -> timedelta: return timedelta(minutes=self.ACCESS_TOKEN_EXPIRE_MINUTES) class Config: env_file = ".env" env_file_encoding = "utf-8" # Instance globale settings = Settings()