Advertisement
Guest User

proxymodule

a guest
Jul 23rd, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ENVIRONMENT = process.env.environment;
  2. const PROXY_ON = process.env.PROXY_ON;
  3.  
  4. exports.setupAndRotateRequestLib = function (requestLib, company) {
  5.     //if in local environment, proxy is not used
  6.     var token = getSessionToken(company);
  7.     return ENVIRONMENT && PROXY_ON === 'true'? require(requestLib).defaults({proxy : `http://lum-customer-incodde-zone-residential-session-${token}:dd64777275cb@zproxy.lum-superproxy.io:22225`, simple: false}) : require(requestLib).defaults({simple: false});
  8. };
  9.  
  10. function getSessionToken(company) {
  11.     return ENVIRONMENT + company + Math.floor((Math.random() * 10000) + 1);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement