@serenity-js/rest
Version:
Serenity/JS Screenplay Pattern library for interacting with REST and other HTTP-based services, supporting comprehensive API testing and blended testing scenarios
34 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.axiosProxyOverridesFor = axiosProxyOverridesFor;
const tiny_types_1 = require("tiny-types");
const createUrl_1 = require("./createUrl");
const ProxyAgent_1 = require("./ProxyAgent");
/**
* @param options
*/
function axiosProxyOverridesFor(options) {
const envProxyOverride = options.proxy
&& (0, createUrl_1.createUrl)({
username: options.proxy?.auth?.username,
password: options.proxy?.auth?.password,
protocol: options.proxy?.protocol,
hostname: (0, tiny_types_1.ensure)('proxy.host', options.proxy?.host, (0, tiny_types_1.isDefined)()),
port: options.proxy?.port ? Number(options.proxy?.port) : undefined,
}).toString();
const agent = new ProxyAgent_1.ProxyAgent({
httpAgent: options.httpAgent,
httpsAgent: options.httpsAgent,
// if there's a specific proxy override configured, use it
// if not - detect proxy automatically based on env variables
getProxyForUrl: envProxyOverride
? (url_) => envProxyOverride
: undefined,
});
return {
proxy: false,
httpAgent: agent,
httpsAgent: agent,
};
}
//# sourceMappingURL=axiosProxyOverridesFor.js.map