UNPKG

@qso-soft/shared

Version:

Shared library for QSO-soft

30 lines 848 B
import { BASE_TIMEOUT } from '../../constants'; import { getHeaders } from './get-headers'; export const getAxiosConfig = async ({ proxyAgent, token, headers = getHeaders(), timeout = BASE_TIMEOUT, isScraper = false, }) => { const proxyAgentConfig = { ...(!!proxyAgent && { [isScraper ? 'agent' : 'httpsAgent']: proxyAgent, }), }; const authHeader = { ...(!!token && { Authorization: `Bearer ${token}`, }), }; const scraperConfig = { ...(!!isScraper && { json: true, }), }; return { ...proxyAgentConfig, timeout, signal: AbortSignal.timeout(timeout), headers: { ...authHeader, ...headers, }, ...scraperConfig, }; }; //# sourceMappingURL=get-axios-config.js.map