Automated Action 8a1b373ff6 feat: Implement Todo API with FastAPI and SQLite
- Setup project structure and dependencies
- Create Todo model and SQLAlchemy database connection
- Set up Alembic for database migrations
- Implement CRUD operations and API endpoints
- Add health check endpoint
- Update README with project documentation

generated with BackendIM... (backend.im)
2025-05-12 10:11:52 +00:00

25 lines
608 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.database import get_db
router = APIRouter(
prefix="/health",
tags=["health"],
)
@router.get("/")
def health_check(db: Session = Depends(get_db)):
"""Health check endpoint to verify API and database connectivity."""
try:
# Verify database connection by executing a simple query
db.execute("SELECT 1")
db_status = "healthy"
except Exception:
db_status = "unhealthy"
return {
"status": "healthy",
"database": db_status,
"version": "0.1.0"
}