
- Set up project structure with FastAPI and SQLite - Create models for products and cart items - Implement schemas for API request/response validation - Add database migrations with Alembic - Create service layer for business logic - Implement API endpoints for cart operations - Add health endpoint for monitoring - Update documentation - Fix linting issues
25 lines
609 B
Python
25 lines
609 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.db.session import get_db
|
|
|
|
router = APIRouter(prefix="/health", tags=["health"])
|
|
|
|
|
|
@router.get("")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint to verify the API is running correctly.
|
|
"""
|
|
# Check database connection
|
|
try:
|
|
# Execute a simple query to check the database connection
|
|
db.execute("SELECT 1")
|
|
db_status = "healthy"
|
|
except Exception:
|
|
db_status = "unhealthy"
|
|
|
|
return {
|
|
"status": "ok",
|
|
"database": db_status,
|
|
} |