oex2003/evolution-api
0
1import { HttpsProxyAgent } from 'https-proxy-agent';2 3type Proxy = {4 host: string;5 password?: string;6 port: string;7 protocol: string;8 username?: string;9};10 11export function makeProxyAgent(proxy: Proxy | string) {12 if (typeof proxy === 'string') {13 return new HttpsProxyAgent(proxy);14 }15 16 const { host, password, port, protocol, username } = proxy;17 let proxyUrl = `${protocol}://${host}:${port}`;18 19 if (username && password) {20 proxyUrl = `${protocol}://${username}:${password}@${host}:${port}`;21 }22 return new HttpsProxyAgent(proxyUrl);23}24 