text: import logging
  
  from fastapi import APIRouter, Depends
  from fastapi.responses import JSONResponse
  from starlette.status import HTTP_200_OK, HTTP_503_SERVICE_UNAVAILABLE
  from sqlalchemy.ext.asyncio.session import AsyncSession
  
  
  from app.database.session import get_async_db_session
  from app.routers.services.healthcheck_service import HealthcheckException, application_healthcheck, database_healthcheck, servicebus_healthcheck
  
  logger = logging.getLogger(__name__)
  router = APIRouter()
  
  
  @router.get("",
              tags=["health"],
              summary="Helsesjekk av applikasjonen")
  async def router_healthcheck_application(db_session: AsyncSession = Depends(get_async_db_session)):
      status_code = HTTP_200_OK
      status_message = "healthy"
  
      try:
          await application_healthcheck(db_session)
      except HealthcheckException as error:
          status_code = HTTP_503_SERVICE_UNAVAILABLE
          status_message = "unhealthy"
          logger.critical(str(error))
  
      return JSONResponse(
          content={"status": status_message},
          status_code=status_code,
          headers={
              "Cache-Control": "no-cache",
          }
      )
  
  
  @router.get("/database",
              tags=["health"],
              summary="Helsesjekk av databasen")
  async def router_healthcheck_database(db_session: AsyncSession = Depends(get_async_db_session)):
      status_code = HTTP_200_OK
      status_message = "database is healthy"
  
      try:
          await database_healthcheck(db_session)
      except HealthcheckException as error:
          status_code = HTTP_503_SERVICE_UNAVAILABLE
          status_message = "unhealthy"
          logger.critical(str(error))
  
      return JSONResponse(
          content={"status": status_message},
          status_code=status_code,
          headers={
              "Cache-Control": "no-cache",
          }
      )
  
  
  @router.get("/servicebus",
              tags=["health"],
              summary="Helsesjekk av servicebus")
  async def router_healthcheck_servicebus():
      status_code = HTTP_200_OK
      status_message = "servicebus is healthy"
  
      try:
          await servicebus_healthcheck()
      except HealthcheckException as error:
          status_code = HTTP_503_SERVICE_UNAVAILABLE
          status_message = "unhealthy"
          logger.critical(str(error))
  
      return JSONResponse(
          content={"status": status_message},
          status_code=status_code,
          headers={
              "Cache-Control": "no-cache",
          }
      )
  