35 lines
919 B
Python
35 lines
919 B
Python
from functools import lru_cache
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=False,
|
|
extra="ignore",
|
|
)
|
|
|
|
app_env: str = "development"
|
|
app_name: str = "zhuangxiu-api"
|
|
log_level: str = "INFO"
|
|
api_host: str = "0.0.0.0"
|
|
api_port: int = 8000
|
|
cors_origins: str = "http://localhost:3000"
|
|
|
|
runtime_settings_dir: str = ".runtime"
|
|
settings_master_key: str = ""
|
|
|
|
database_url: str = "postgresql://zhuangxiu:zhuangxiu@localhost:5432/zhuangxiu"
|
|
redis_url: str = "redis://localhost:6379/0"
|
|
|
|
@property
|
|
def cors_origin_list(self) -> list[str]:
|
|
return [origin.strip() for origin in self.cors_origins.split(",") if origin.strip()]
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
return Settings()
|