
- Set up project structure and dependencies - Create database models and schemas for tasks - Implement CRUD operations for tasks - Add API endpoints for task management - Create Alembic migrations for the database - Add health check endpoint - Implement error handling - Add documentation in README.md
32 lines
740 B
Python
32 lines
740 B
Python
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.database import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/", tags=["Health"])
|
|
async def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint.
|
|
|
|
Verifies:
|
|
- API is running
|
|
- Database connection is working
|
|
"""
|
|
try:
|
|
# Test database connection
|
|
db.execute("SELECT 1")
|
|
|
|
return {
|
|
"status": "healthy",
|
|
"api": "up",
|
|
"database": "up",
|
|
}
|
|
except Exception as e:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
|
detail=f"Service unhealthy: {str(e)}",
|
|
) from e
|