31 lines
795 B
Python
31 lines
795 B
Python
|
|
"""Environment-backed application configuration."""
|
||
|
|
|
||
|
|
from functools import lru_cache
|
||
|
|
from typing import Literal
|
||
|
|
|
||
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||
|
|
|
||
|
|
|
||
|
|
class Settings(BaseSettings):
|
||
|
|
"""Validated process configuration at the application boundary."""
|
||
|
|
|
||
|
|
app_name: str = "Zhixing Server"
|
||
|
|
app_env: Literal["development", "test", "production"] = "development"
|
||
|
|
log_level: str = "INFO"
|
||
|
|
|
||
|
|
model_config = SettingsConfigDict(
|
||
|
|
env_file=".env",
|
||
|
|
env_prefix="ZHIXING_",
|
||
|
|
extra="ignore",
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
@lru_cache
|
||
|
|
def get_settings() -> Settings:
|
||
|
|
"""Return one immutable-by-convention configuration object per process.
|
||
|
|
|
||
|
|
Returns:
|
||
|
|
Settings populated from defaults, `.env`, and process environment variables.
|
||
|
|
"""
|
||
|
|
return Settings()
|