from fastapi import APIRouter
from sqlalchemy import text
from sqlalchemy import create_engine

from app.core.config import settings

router = APIRouter()


@router.get("/health")
def health() -> dict:
    return {"status": "ok", "service": "backend"}


@router.get("/ready")
def ready() -> dict:
    engine = create_engine(settings.database_url, pool_pre_ping=True)
    with engine.connect() as conn:
        conn.execute(text("SELECT 1"))
    return {"status": "ready", "database": "ok"}
