Automated Action 5935f302dc Create Small Business Inventory Management System with FastAPI and SQLite
- Set up project structure and FastAPI application
- Create database models with SQLAlchemy
- Implement authentication with JWT
- Add CRUD operations for products, inventory, categories
- Implement purchase order and sales functionality
- Create reporting endpoints
- Set up Alembic for database migrations
- Add comprehensive documentation in README.md
2025-05-16 08:53:15 +00:00

39 lines
934 B
Python

from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from app.db.session import get_db
import time
health_router = APIRouter()
@health_router.get("/health", tags=["health"])
async def health_check(db: Session = Depends(get_db)):
"""
Check service health
Checks:
- API is responsive
- Database connection is established
"""
# Basic health check
health_data = {
"status": "healthy",
"timestamp": time.time(),
"version": "0.1.0",
"checks": {
"api": "ok",
"database": "ok"
}
}
# Verify database connection
try:
# Run simple query to verify connection
db.execute("SELECT 1")
except Exception as e:
health_data["status"] = "unhealthy"
health_data["checks"]["database"] = "failed"
return health_data
return health_data