Add Pydantic models and FastAPI router structure for agent and backend
CI / basic-check (push) Has been cancelled
CI / basic-check (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.schemas import HealthCheck, HealthResponse
|
||||
|
||||
router = APIRouter(tags=['health'])
|
||||
START_TIME = time.time()
|
||||
|
||||
|
||||
def build_health() -> HealthResponse:
|
||||
return HealthResponse(
|
||||
status='pass',
|
||||
service='netmapper-backend',
|
||||
version='0.1.0',
|
||||
time=datetime.now(timezone.utc),
|
||||
uptime_s=round(time.time() - START_TIME, 2),
|
||||
checks={'db': HealthCheck(status='warn', detail='database not configured yet')},
|
||||
)
|
||||
|
||||
|
||||
@router.get('/live', response_model=HealthResponse)
|
||||
def live() -> HealthResponse:
|
||||
return build_health()
|
||||
|
||||
|
||||
@router.get('/ready', response_model=HealthResponse)
|
||||
def ready() -> HealthResponse:
|
||||
return build_health()
|
||||
|
||||
|
||||
@router.get('/health', response_model=HealthResponse)
|
||||
def health() -> HealthResponse:
|
||||
return build_health()
|
||||
Reference in New Issue
Block a user