template
This commit is contained in:
62
backend/routers/health.py
Normal file
62
backend/routers/health.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""
|
||||
=============================================================================
|
||||
HEALTH CHECK ROUTER
|
||||
=============================================================================
|
||||
|
||||
Simple health check endpoints for monitoring and deployment.
|
||||
|
||||
These are useful for:
|
||||
- Load balancer health checks
|
||||
- Kubernetes readiness probes
|
||||
- Monitoring systems
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter
|
||||
from config import settings
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
async def health_check():
|
||||
"""
|
||||
Basic health check endpoint.
|
||||
Returns 200 if the server is running.
|
||||
"""
|
||||
return {
|
||||
"status": "healthy",
|
||||
"environment": settings.ENVIRONMENT,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/health/detailed")
|
||||
async def detailed_health_check():
|
||||
"""
|
||||
Detailed health check with service status.
|
||||
Useful for debugging connection issues.
|
||||
"""
|
||||
# Check AI provider configuration
|
||||
ai_configured = bool(
|
||||
settings.OPENAI_API_KEY or settings.ANTHROPIC_API_KEY
|
||||
)
|
||||
|
||||
# Check Supabase configuration
|
||||
supabase_configured = bool(
|
||||
settings.SUPABASE_URL and settings.SUPABASE_SERVICE_KEY
|
||||
)
|
||||
|
||||
return {
|
||||
"status": "healthy",
|
||||
"environment": settings.ENVIRONMENT,
|
||||
"services": {
|
||||
"ai": {
|
||||
"configured": ai_configured,
|
||||
"provider": settings.AI_PROVIDER,
|
||||
"model": settings.AI_MODEL,
|
||||
},
|
||||
"database": {
|
||||
"configured": supabase_configured,
|
||||
"provider": "supabase",
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user