Skip to content

Commit

Permalink
chore(): use minimal proxy implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Feb 13, 2024
1 parent 614721d commit 16a085b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ jobs:
API_SECRET_COM: ${{ secrets.API_SECRET_COM }}
PROXY_ENABLED: ${{ secrets.PROXY_ENABLED }}
PROXY_HOST: ${{ secrets.PROXY_HOST }}
PROXY_PASS: ${{ secrets.PROXY_PASS }}
PROXY_PORT: ${{ secrets.PROXY_PORT }}
PROXY_USER: ${{ secrets.PROXY_USER }}
PROXY_PASS: ${{ secrets.PROXY_PASS }}
21 changes: 15 additions & 6 deletions test/proxy.util.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import { getHttpsProxyAgent } from '../src';
import { AxiosRequestConfig } from 'axios';

export function getTestProxy() {
export function getTestProxy(): AxiosRequestConfig {
if (process.env.PROXY_ENABLED !== 'true') {
return;
return {};
}
const host = process.env.PROXY_HOST;
const port = process.env.PROXY_PORT;
const user = process.env.PROXY_USER;
const pass = process.env.PROXY_PASS;
if (!host || !port || !user || !pass) {
throw new Error(`One or more env vars missing for proxy support`);
throw new Error('One or more env vars missing for proxy support');
}

const httpsAgent = getHttpsProxyAgent(host, port, user, pass);
return httpsAgent;
return {
proxy: {
host,
port: Number(port),
auth: {
username: user,
password: pass,
},
protocol: 'http',
},
};
}

0 comments on commit 16a085b

Please sign in to comment.