diff --git a/src/app/interfaces/api/v1/endpoints/debug/resources.py b/src/app/interfaces/api/v1/endpoints/debug/resources.py index b981c05..ded5bde 100644 --- a/src/app/interfaces/api/v1/endpoints/debug/resources.py +++ b/src/app/interfaces/api/v1/endpoints/debug/resources.py @@ -1,10 +1,13 @@ -from typing import Annotated, Dict +from typing import Annotated from fastapi import APIRouter, Body, Request +from fastapi.responses import JSONResponse +from starlette.status import HTTP_200_OK, HTTP_400_BAD_REQUEST + from src.app.application.container import container as services_container -from src.app.interfaces.api.v1.endpoints.debug.schemas.req_schemas import MessageReq from src.app.config.settings import settings from src.app.infrastructure.messaging.mq_client import mq_client +from src.app.interfaces.api.v1.endpoints.debug.schemas.req_schemas import MessageReq router = APIRouter(prefix="/debug") @@ -41,7 +44,10 @@ async def send_message( @router.get("/health-check/", status_code=200) async def health_check( request: Request, -) -> Dict[str, str]: +) -> JSONResponse: is_healthy = await services_container.common_service.is_healthy() status = "OK" if is_healthy else "NOT OK" - return {"status": status} + status_code = HTTP_200_OK if is_healthy else HTTP_400_BAD_REQUEST + resp = JSONResponse(content={"status": status}, status_code=status_code) + + return resp diff --git a/src/app/interfaces/grpc/services/debug_service.py b/src/app/interfaces/grpc/services/debug_service.py index fee8e1f..0330b87 100644 --- a/src/app/interfaces/grpc/services/debug_service.py +++ b/src/app/interfaces/grpc/services/debug_service.py @@ -27,5 +27,5 @@ async def SendMessage(self, request, context) -> pb2.MessageResp: # type: ignor async def HealthCheck(self, request, context) -> pb2.HealthCheckResp: # type: ignore is_healthy = await services_container.common_service.is_healthy() - status = "OK" if is_healthy else "NOT OK" + status = "SERVING" if is_healthy else "NOT_SERVING" return pb2.HealthCheckResp(status=status) # type: ignore