health.ts 715 B

123456789101112131415161718192021
  1. import axios from "axios";
  2. import { apiClient } from "./client";
  3. import { mockHealth, mockMode } from "./mock";
  4. import type { GatewayServicesHealth, ServiceHealth } from "@/types";
  5. export async function getHealth(apiKey?: string, tenantId?: string, userId?: string) {
  6. if (mockMode) return mockHealth();
  7. const { data } = await axios.get<ServiceHealth>("/health", {
  8. headers: {
  9. ...(apiKey ? { "x-api-key": apiKey } : {}),
  10. ...(tenantId ? { "x-tenant-id": tenantId } : {}),
  11. ...(userId ? { "x-user-id": userId } : {}),
  12. },
  13. });
  14. return data;
  15. }
  16. export async function getServicesHealth() {
  17. const { data } = await apiClient.get<GatewayServicesHealth>("/services/health");
  18. return data;
  19. }