config.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import secrets
  2. from typing import Any, Dict, List, Optional, Union
  3. from pydantic import AnyHttpUrl, BaseSettings, EmailStr, HttpUrl, PostgresDsn, validator, DirectoryPath
  4. class Settings(BaseSettings):
  5. API_V1_STR: str = "/api/v1"
  6. SECRET_KEY: str = secrets.token_urlsafe(32)
  7. # 60 minutes * 24 hours * 8 days = 8 days
  8. ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
  9. SERVER_HOST: AnyHttpUrl = "http://cmm.ai:8088"
  10. SMTP_TLS: bool = True
  11. SMTP_PORT: Optional[int] = None
  12. SMTP_HOST: Optional[str] = None
  13. SMTP_USER: Optional[str] = None
  14. SMTP_PASSWORD: Optional[str] = None
  15. EMAILS_FROM_EMAIL: Optional[EmailStr] = None
  16. EMAILS_FROM_NAME: Optional[str] = None
  17. EMAILS_ENABLED: bool = True
  18. @validator("EMAILS_ENABLED", pre=True, check_fields=False)
  19. def get_emails_enabled(cls, v: bool, values: Dict[str, Any]) -> bool:
  20. return bool(
  21. values.get("SMTP_HOST")
  22. and values.get("SMTP_PORT")
  23. and values.get("EMAILS_FROM_EMAIL")
  24. )
  25. EMAIL_TEMPLATES_DIR: str = "C:\/Users\/s1301\/PycharmProjects\/fastdemo\/app\email-templates"
  26. EMAIL_RESET_TOKEN_EXPIRE_HOURS: int = 48
  27. settings = Settings()