
- Set up project structure with FastAPI - Implement SQLAlchemy models for inventory items and categories - Create database connection with SQLite - Add CRUD operations for inventory management - Implement API endpoints for categories, items, and inventory transactions - Add health check endpoint - Set up Alembic for database migrations - Update README with documentation
31 lines
619 B
Python
31 lines
619 B
Python
from typing import Dict
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.db.session import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/")
|
|
def health_check(
|
|
db: Session = Depends(get_db),
|
|
) -> Dict:
|
|
"""
|
|
Perform health check of the application.
|
|
|
|
Checks:
|
|
- Database connection
|
|
"""
|
|
# Test database connection
|
|
db_status = "healthy"
|
|
try:
|
|
db.execute("SELECT 1")
|
|
except Exception:
|
|
db_status = "unhealthy"
|
|
|
|
return {
|
|
"status": "healthy" if db_status == "healthy" else "unhealthy",
|
|
"database": db_status
|
|
} |