| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- """
- Application configuration using Pydantic Settings.
- Environment variables are loaded from .env file.
- """
- from pydantic_settings import BaseSettings, SettingsConfigDict
- class Settings(BaseSettings):
- """Application settings loaded from environment variables."""
- # Database
- DATABASE_URL: str
- # ClickHouse
- CLICKHOUSE_HOST: str = "localhost"
- CLICKHOUSE_PORT: int = 8123
- CLICKHOUSE_USER: str = "default"
- CLICKHOUSE_PASSWORD: str = ""
- CLICKHOUSE_DATABASE: str = "mybeacon"
- # Redis
- REDIS_URL: str = "redis://localhost:6379/0"
- # Security
- SECRET_KEY: str
- ENCRYPTION_KEY: str # Fernet key for encrypting WiFi passwords
- ACCESS_TOKEN_EXPIRE_MINUTES: int = 15
- REFRESH_TOKEN_EXPIRE_DAYS: int = 30
- ALGORITHM: str = "HS256"
- # CORS
- CORS_ORIGINS: str = "http://localhost:5173"
- # File Storage
- UPLOAD_DIR: str = "/var/lib/mybeacon/uploads"
- # Email
- SMTP_HOST: str = "localhost"
- SMTP_PORT: int = 587
- SMTP_USER: str = ""
- SMTP_PASSWORD: str = ""
- SMTP_FROM: str = "noreply@mybeacon.com"
- # Application
- DEBUG: bool = False
- LOG_LEVEL: str = "INFO"
- API_V1_PREFIX: str = "/api/v1"
- PROJECT_NAME: str = "MyBeacon API"
- model_config = SettingsConfigDict(
- env_file=".env",
- env_file_encoding="utf-8",
- case_sensitive=False
- )
- @property
- def cors_origins_list(self) -> list[str]:
- """Parse CORS_ORIGINS string into list."""
- return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
- # Global settings instance
- settings = Settings()
|