pounce/backend/app/config.py

86 lines
2.5 KiB
Python

"""Application configuration using pydantic-settings."""
from functools import lru_cache
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
# Database
database_url: str = "sqlite+aiosqlite:///./domainwatch.db"
# JWT Settings
secret_key: str = "dev-secret-key-change-in-production"
algorithm: str = "HS256"
access_token_expire_minutes: int = 1440 # 24 hours
# App Settings
app_name: str = "DomainWatch"
debug: bool = True
# Email Settings (optional)
smtp_host: str = ""
smtp_port: int = 587
smtp_user: str = ""
smtp_password: str = ""
email_from: str = ""
# CORS Settings
cors_origins: str = "http://localhost:3000,http://127.0.0.1:3000"
# Scheduler Settings
check_hour: int = 6
check_minute: int = 0
scheduler_check_interval_hours: int = 24
enable_scheduler: bool = False # Run APScheduler jobs in this process (recommend: separate scheduler process)
# Job Queue / Redis (Phase 2)
redis_url: str = "" # e.g. redis://redis:6379/0
enable_job_queue: bool = False
# Observability (Phase 2)
enable_metrics: bool = True
metrics_path: str = "/metrics"
enable_db_query_metrics: bool = False
# Rate limiting storage (SlowAPI / limits). Use Redis in production.
rate_limit_storage_uri: str = "memory://"
# Database pooling (PostgreSQL)
db_pool_size: int = 5
db_max_overflow: int = 10
db_pool_timeout: int = 30
# =================================
# External API Credentials
# =================================
# DropCatch API (Official Partner API)
# Docs: https://www.dropcatch.com/hiw/dropcatch-api
dropcatch_client_id: str = ""
dropcatch_client_secret: str = ""
dropcatch_api_base: str = "https://api.dropcatch.com"
# Sedo API (Partner API - XML-RPC)
# Docs: https://api.sedo.com/apidocs/v1/
# Find your credentials: Sedo.com → Mein Sedo → API-Zugang
sedo_partner_id: str = ""
sedo_sign_key: str = ""
sedo_api_base: str = "https://api.sedo.com/api/v1/"
# Moz API (SEO Data)
moz_access_id: str = ""
moz_secret_key: str = ""
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
extra = "ignore" # Ignore extra fields in .env
@lru_cache()
def get_settings() -> Settings:
"""Get cached settings instance."""
return Settings()