MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
947 stars 278 forks source link

feat: add agent options #643

Closed Youkehai closed 8 months ago

Youkehai commented 9 months ago

When your computer or server encounters network errors, timeouts, etc. while accessing Shopify, if you have a proxy server, you can set the proxy IP and port to resolve issues related to access timeouts and slowness.

lpinca commented 9 months ago

It would be better to only add an agent option and forward the value to got without adding a new dependency. This allows the user to use a different package. For example

const Shopify = require('shopify-api-node');
const { HttpsProxyAgent } = require('hpagent');

const agent = {
  https: new HttpsProxyAgent({
    keepAlive: true,
    keepAliveMsecs: 1000,
    maxSockets: 256,
    maxFreeSockets: 256,
    scheduling: 'lifo',
    proxy: 'https://localhost:8080'
  })
};

const shopify = new Shopify({
  shopName: 'shop-name',
  accessToken: 'token',
  agent
});

Anyway, there are also packages like https://github.com/gajus/global-agent so I would prefer to not add the option.

Youkehai commented 9 months ago

Sorry, I modified my method

coveralls commented 8 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling 814a74acca75f1966ba73a1d821838d52d2cc42e on Youkehai:master into a75493b86e71ab2b783b073dc5b4f4a9d6e4e02d on MONEI:master.

lpinca commented 8 months ago

Thank you.