Implement Monlet MVP stack and UI updates
This commit is contained in:
22
server/monlet_server/api/health.py
Normal file
22
server/monlet_server/api/health.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from ..db import get_session
|
||||
from ..schemas import HealthResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/health", response_model=HealthResponse)
|
||||
async def health() -> HealthResponse:
|
||||
return HealthResponse()
|
||||
|
||||
|
||||
@router.get("/ready", response_model=HealthResponse)
|
||||
async def ready(session: AsyncSession = Depends(get_session)) -> HealthResponse:
|
||||
try:
|
||||
await session.execute(text("SELECT 1"))
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=503, detail="database not reachable") from exc
|
||||
return HealthResponse()
|
||||
Reference in New Issue
Block a user