Automated Action 629ba0ee1c Create REST API with FastAPI and SQLite
- Set up project structure with FastAPI app
- Implement SQLAlchemy models and async database connection
- Create CRUD endpoints for items resource
- Add health endpoint for monitoring
- Configure Alembic for database migrations
- Create comprehensive documentation

generated with BackendIM... (backend.im)
2025-05-15 15:49:28 +00:00

26 lines
641 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from app.db.database import get_db
from app.db.database import engine
router = APIRouter(tags=["health"])
@router.get("/health", summary="Check API health")
async def health_check(db: AsyncSession = Depends(get_db)):
"""
Check the health of the API.
Returns:
dict: Health status information
"""
try:
# Check database connection
db_status = True
except Exception:
db_status = False
return {
"status": "healthy",
"database": db_status,
"version": "0.1.0"
}