All checks were successful
Gitea Actions Demo / host-commands (push) Successful in 0s
40 lines
979 B
Python
40 lines
979 B
Python
from pydantic_settings import BaseSettings
|
|
from pydantic import Field
|
|
from config.env_loader import load_env
|
|
|
|
# 先加载 ENV & .env
|
|
load_env()
|
|
|
|
class Settings(BaseSettings):
|
|
# 环境
|
|
ENV: str = Field("dev")
|
|
DEBUG: bool = Field(True)
|
|
|
|
# 日志
|
|
LOG_LEVEL: str = Field("LOG_LEVEL")
|
|
LOG_FILE_PATH: str = Field("logs")
|
|
LOG_TYPE: str = Field("console")
|
|
|
|
# 数据库
|
|
DB_HOST: str
|
|
DB_PORT: int
|
|
DB_USER: str
|
|
DB_PASS: str
|
|
DB_NAME: str
|
|
|
|
# 邮件发送配置
|
|
SMTP_HOST: str = Field("SMTP_HOST")
|
|
SMTP_PORT: int = Field(587, env="SMTP_PORT")
|
|
SMTP_USER: str = Field("SMTP_USER")
|
|
SMTP_PASSWORD: str = Field("SMTP_PASSWORD")
|
|
SMTP_USE_TLS: bool = Field(True, env="SMTP_USE_TLS")
|
|
SMTP_FROM: str = Field("SMTP_FROM")
|
|
ERROR_NOTIFICATION_EMAIL: str = Field("ERROR_NOTIFICATION_EMAIL")
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
env_file_encoding = "utf-8"
|
|
|
|
|
|
# 全局唯一配置实例
|
|
settings = Settings() |