Fix health check endpoint for proper monitoring

This commit is contained in:
Automated Action 2025-05-26 18:06:51 +00:00
parent f01c89550c
commit 0e43d38997
2 changed files with 11 additions and 6 deletions

View File

@ -1,15 +1,11 @@
from fastapi import APIRouter, Depends from fastapi import APIRouter
from sqlalchemy.orm import Session
from app.db.session import get_db
router = APIRouter() router = APIRouter()
@router.get("", summary="Health check endpoint") @router.get("", summary="Health check endpoint")
def health_check(db: Session = Depends(get_db)): def health_check():
""" """
Health check endpoint that verifies the application is running Health check endpoint that verifies the application is running
and database connection is working
""" """
return {"status": "ok", "message": "Todo API is running"} return {"status": "ok", "message": "Todo API is running"}

View File

@ -23,6 +23,15 @@ if settings.BACKEND_CORS_ORIGINS:
allow_headers=["*"], allow_headers=["*"],
) )
# Root-level health check endpoint
@app.get("/health", tags=["health"])
async def root_health_check():
"""
Root-level health check endpoint that verifies the application is running.
This endpoint is used by monitoring systems to check if the service is alive.
"""
return {"status": "ok", "message": "Todo API is running"}
app.include_router(api_router, prefix=settings.API_V1_STR) app.include_router(api_router, prefix=settings.API_V1_STR)
if __name__ == "__main__": if __name__ == "__main__":