mangopay2-nodejs-sdk
mangopay2-nodejs-sdk copied to clipboard
config and requestOptions should NOT be a prototype of Api
There is fundamental error in the way Api gets instantiated:
const Mangopay = require('mangopay2-nodejs-sdk');
const client = new Mangopay(options);
By doing this, essentially the developer thinks that client is an isolated new instance of Mangopay. So is safe to create several clients in the same process:
const client1 = new Mangopay(options1);
const client2 = new Mangopay(options2);
The problem is, that Api sets config a requestOptions as prototypes: https://github.com/Mangopay/mangopay2-nodejs-sdk/blob/096af0e64be49e5c3bbd135e496a3ce0f84995ed/lib/api.js#L67
This means that client2 configuration override client1 configuration! It makes no sense to set the configuration as Prototype.
Hello @domingosl,
Thank you for your suggestion. The technical team is reviewing it.
Have a nice day,
I was hit by this bug a few times causing production requests to hit the sandbox. This is pretty bad design. Please fix 🙏