health.ts 640 B

1234567891011121314151617181920
  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, userId?: string) {
  6. if (mockMode) return mockHealth();
  7. const { data } = await axios.get<ServiceHealth>("/health", {
  8. headers: {
  9. ...(apiKey ? { "x-api-key": apiKey } : {}),
  10. ...(userId ? { "x-user-id": userId } : {}),
  11. },
  12. });
  13. return data;
  14. }
  15. export async function getServicesHealth() {
  16. const { data } = await apiClient.get<GatewayServicesHealth>("/services/health");
  17. return data;
  18. }