You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
627 B
21 lines
627 B
from fastapi import APIRouter
|
|
|
|
from app.db.health import ping_database
|
|
from app.db.session import create_engine
|
|
from app.schemas.system import HealthResponse, ReadyResponse
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health", response_model=HealthResponse)
|
|
async def health_check() -> HealthResponse:
|
|
return HealthResponse(status="ok")
|
|
|
|
|
|
@router.get("/ready", response_model=ReadyResponse)
|
|
async def readiness_check() -> ReadyResponse:
|
|
database_ok = await ping_database(create_engine())
|
|
return ReadyResponse(
|
|
status="ready" if database_ok else "degraded",
|
|
database="ok" if database_ok else "error",
|
|
)
|
|
|