47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
|
|
"""Configuration via environment variables (Pydantic Settings)."""
|
||
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||
|
|
|
||
|
|
|
||
|
|
class Settings(BaseSettings):
|
||
|
|
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
||
|
|
|
||
|
|
environment: str = "dev"
|
||
|
|
|
||
|
|
# Postgres
|
||
|
|
db_host: str
|
||
|
|
db_port: int = 5433
|
||
|
|
db_name: str = "eh_vehicles"
|
||
|
|
db_user: str = "search_read"
|
||
|
|
db_password: str
|
||
|
|
|
||
|
|
# Redis
|
||
|
|
redis_host: str = "eh-search-redis"
|
||
|
|
redis_port: int = 6379
|
||
|
|
redis_db: int = 0
|
||
|
|
|
||
|
|
# Cache TTLs
|
||
|
|
cache_ttl_result: int = 60
|
||
|
|
cache_ttl_suggest: int = 600
|
||
|
|
cache_ttl_empty: int = 300
|
||
|
|
|
||
|
|
# Directus
|
||
|
|
directus_url: str = "http://10.0.0.10:8055"
|
||
|
|
directus_slug_refresh_seconds: int = 300
|
||
|
|
|
||
|
|
# CORS
|
||
|
|
cors_origins: str = ""
|
||
|
|
|
||
|
|
@property
|
||
|
|
def dsn(self) -> str:
|
||
|
|
return (
|
||
|
|
f"postgresql://{self.db_user}:{self.db_password}"
|
||
|
|
f"@{self.db_host}:{self.db_port}/{self.db_name}"
|
||
|
|
)
|
||
|
|
|
||
|
|
@property
|
||
|
|
def cors_origin_list(self) -> list[str]:
|
||
|
|
return [o.strip() for o in self.cors_origins.split(",") if o.strip()]
|
||
|
|
|
||
|
|
|
||
|
|
settings = Settings()
|