summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/api/health.py
blob: abb1b53edccd2d9777eb0185a96c690bea61bc49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Healthcheck endpoint — no auth required (monitoring probes)."""

from fastapi import APIRouter, Depends
from sqlalchemy import text
from sqlalchemy.ext.asyncio import AsyncSession

from meshbay_hub import __version__
from meshbay_hub.api.revocation import get_connected_node_count
from meshbay_hub.db.engine import get_db

router = APIRouter(tags=["health"])


@router.get("/v1/health")
async def health(db: AsyncSession = Depends(get_db)):
    """Liveness: database reachable, version, connected nodes."""
    await db.execute(text("SELECT 1"))
    return {
        "status": "ok",
        "version": __version__,
        "connected_nodes": get_connected_node_count(),
    }