
Features: - Project structure setup - Database configuration with SQLAlchemy - Item model and CRUD operations - API endpoints for items - Alembic migrations - Health check endpoint - Comprehensive documentation generated with BackendIM... (backend.im)
24 lines
669 B
Python
24 lines
669 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from app.database import get_db
|
|
|
|
router = APIRouter(tags=["Health"])
|
|
|
|
@router.get("/health", summary="Health check endpoint")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint that returns the status of the API and database connection.
|
|
"""
|
|
health_status = {
|
|
"status": "healthy",
|
|
"database": "connected"
|
|
}
|
|
|
|
try:
|
|
# Test database connection
|
|
db.execute("SELECT 1")
|
|
except Exception:
|
|
health_status["database"] = "disconnected"
|
|
health_status["status"] = "unhealthy"
|
|
|
|
return health_status |