from fastapi import APIRouter from fastapi import HTTPException from sqlalchemy import text from app.database import async_session_maker from app.redis_client import redis_client router = APIRouter(tags=["health"]) @router.get("/health/live") def live(): return {"status": "ok"} @router.get("/health/ready") async def ready(): try: async with async_session_maker() as session: await session.execute(text("SELECT 1")) await redis_client.ping() return {"status": "ok"} except Exception: raise HTTPException(status_code=503, detail="unavailable") @router.get("/") def home(): return { "service": "MTUSI Messenger", "version": "1.1.0", "docs": "/docs", }