Automated Action 3a29a346a9 Initial implementation of cryptocurrency data API service using CoinCap API
* Created FastAPI application structure
* Added database models for assets, exchanges, markets, and rates
* Integrated with CoinCap API
* Implemented REST API endpoints
* Setup SQLite persistence with Alembic migrations
* Added comprehensive documentation

Generated with BackendIM... (backend.im)
2025-05-14 12:18:27 +00:00

29 lines
863 B
Python

from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from typing import Dict
import time
from app.core.database import get_db
router = APIRouter()
@router.get("/health", status_code=status.HTTP_200_OK)
def health_check(db: Session = Depends(get_db)) -> Dict[str, object]:
"""
Health check endpoint to verify API is running and database connection works
"""
try:
# Check database connection
db.execute("SELECT 1")
return {
"status": "ok",
"timestamp": int(time.time() * 1000),
"message": "Service is healthy",
"database": "connected"
}
except Exception as e:
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail=f"Database connection error: {str(e)}"
)