UNPKG

@directus/api

Version:

Directus is a real-time API and App dashboard for managing SQL database content

20 lines (19 loc) 652 B
//#region src/request/index.ts const _cache = { axiosInstance: null }; async function getAxios() { if (!_cache.axiosInstance) { const axios = (await import("axios")).default; const { Agent: AgentHttp } = await import("node:http"); const { Agent: AgentHttps } = await import("node:https"); const { agentWithIpValidation } = await import("./agent-with-ip-validation.js"); const httpAgent = agentWithIpValidation(new AgentHttp()); const httpsAgent = agentWithIpValidation(new AgentHttps()); _cache.axiosInstance = axios.create({ httpAgent, httpsAgent }); } return _cache.axiosInstance; } //#endregion export { _cache, getAxios };