
- Set up FastAPI application structure - Create database models for User, Product, Cart, CartItem, Order, and OrderItem - Set up Alembic for database migrations - Create Pydantic schemas for request/response models - Implement API endpoints for products, cart operations, and checkout process - Add health endpoint - Update README with project details and documentation
25 lines
624 B
Python
25 lines
624 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.sql import text
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.db.session import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint to verify the API is running and has database connectivity.
|
|
"""
|
|
try:
|
|
# Check database connection by executing a simple query
|
|
db.execute(text("SELECT 1"))
|
|
db_status = "healthy"
|
|
except Exception as e:
|
|
db_status = f"unhealthy: {str(e)}"
|
|
|
|
return {
|
|
"status": "healthy",
|
|
"database": db_status
|
|
} |