import { QueryClient } from "@tanstack/react-query";
import axios from "axios";

// Create axios instance with default config
export const buildApi = (baseURL: string) =>
  axios.create({
    baseURL,
    headers: {
      "Content-Type": "application/json",
    },
    timeout: 5000,
  });

// Create React Query client with default options
export const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: 5 * 60 * 1000, // 5 minutes
      retry: 1,
      refetchOnWindowFocus: false,
    },
  },
});
