"""
Central configuration for Nexus Autoparts.
"""
import os

# Database
DB_URL = os.environ.get("DATABASE_URL")
if not DB_URL:
    raise ValueError(
        "DATABASE_URL environment variable is required. "
        "Example: postgresql://user:pass@localhost/nexus_autoparts"
    )

MASTER_DB_URL = os.environ.get("MASTER_DB_URL") or DB_URL
TENANT_DB_URL_TEMPLATE = os.environ.get("TENANT_DB_URL_TEMPLATE") or DB_URL.replace("nexus_autoparts", "{db_name}")

# Legacy SQLite path (used only by migration script)
SQLITE_PATH = os.path.join(
    os.path.dirname(os.path.abspath(__file__)),
    "vehicle_database", "vehicle_database.db"
)

# JWT Authentication
JWT_SECRET = os.environ.get("JWT_SECRET")
if not JWT_SECRET:
    raise ValueError(
        "JWT_SECRET environment variable is required. "
        "Generate one with: python3 -c 'import secrets; print(secrets.token_hex(32))'"
    )

JWT_ACCESS_EXPIRES = 900       # 15 minutes
JWT_REFRESH_EXPIRES = 2592000  # 30 days

# Application identity
APP_NAME = "NEXUS AUTOPARTS"
APP_SLOGAN = "Tu conexión directa con las partes que necesitas"
