31 lines
908 B
Python
31 lines
908 B
Python
|
|
from functools import lru_cache
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||
|
|
|
||
|
|
|
||
|
|
class Settings(BaseSettings):
|
||
|
|
"""Application settings sourced from environment / .env file."""
|
||
|
|
|
||
|
|
model_config = SettingsConfigDict(
|
||
|
|
env_file=".env",
|
||
|
|
env_file_encoding="utf-8",
|
||
|
|
extra="ignore",
|
||
|
|
)
|
||
|
|
|
||
|
|
yunke_base_url: str = "https://crm2.yunkecn.com"
|
||
|
|
yunke_username: str = ""
|
||
|
|
yunke_password: str = ""
|
||
|
|
db_url: str = "mysql+asyncmy://user:pass@localhost:3306/yunke"
|
||
|
|
redis_url: str = "redis://localhost:6379/0"
|
||
|
|
media_dir: Path = Path("./media")
|
||
|
|
# Fernet key for encrypting stored credentials. Required for real runs;
|
||
|
|
# empty default lets tests construct Settings without a key.
|
||
|
|
encryption_key: str = ""
|
||
|
|
|
||
|
|
|
||
|
|
@lru_cache
|
||
|
|
def get_settings() -> Settings:
|
||
|
|
"""Return the process-wide Settings singleton."""
|
||
|
|
return Settings()
|