import url from 'url'; interface RequestConfig { endpoint: string; timeout?: number; query?: Record; data?: BodyInit | null; headers?: Record; method?: RequestInit['method'] } export const httpRequest = async (config: RequestConfig) => { const { endpoint, timeout = 10 * 60 * 1000, query, headers, data, method = 'GET' } = config; const controller = new AbortController(); const id = setTimeout(() => controller.abort(), timeout); const params = url.format({ query: query }); const res = await fetch(endpoint + params, { method, headers, body: data, signal: controller.signal }); clearTimeout(id); return res; };