| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- from functools import lru_cache
- from pathlib import Path
- from dotenv import load_dotenv
- from pydantic_settings import BaseSettings, SettingsConfigDict
- _BASE_DIR = Path(__file__).resolve().parent.parent
- _ENV_FILE = _BASE_DIR / ".env"
- load_dotenv(_ENV_FILE)
- class Settings(BaseSettings):
- model_config = SettingsConfigDict(
- env_file=str(_ENV_FILE),
- env_file_encoding="utf-8",
- env_prefix="TAPPO_",
- case_sensitive=False,
- )
- app_name: str = "TappoCloud Store API"
- debug: bool = False
- db_host: str = "localhost"
- db_port: int = 3306
- db_user: str = "root"
- db_password: str = ""
- db_name: str = "tappocloud"
- default_page_size: int = 20
- max_page_size: int = 100
- # JWT
- jwt_secret: str = "change-me-in-production"
- jwt_algorithm: str = "HS256"
- jwt_expire_hours: int = 24
- # Storage
- storage_base_url: str = "http://localhost:8000/storage"
- storage_path: Path = _BASE_DIR / "storage"
- @property
- def database_url(self) -> str:
- return f"mysql+aiomysql://{self.db_user}:{self.db_password}@{self.db_host}:{self.db_port}/{self.db_name}"
- @lru_cache
- def get_settings() -> Settings:
- return Settings()
|