Skip to content

Dropped `node-fetch` and used `urllib`

Compare
Choose a tag to compare
@montumodi montumodi released this 20 May 15:08
· 105 commits to master since this release

This library uses digest authentication which was implemented using node-fetch and digest-fetch. These packages recently has introduced some vulnerabilities and it was not possible to move to higher version because of incompatibility between node-fetch and digest-fetch. To mitigate this issue, these have now been replaced with urllib.

Ideally there shouldn't be any breaking change in this but since underlying library has been changed so there could be some changes on how errors are retuened. Happy scenarios should work as it. If you face any issue while using version 3 of this library, feel free to raise an issue.

As part of improvement a new options called httpOptions has been introduced (via options) which can be used to send some specific http options supported by urllib library. For more information, see readme seciton.

For example to send a custom timeout following code can be used

const getClient = require("mongodb-atlas-api-client");
const {user, cluster} = getClient({
  "publicKey": "some public key",
  "privateKey": "some private key",
  "baseUrl": "https://cloud.mongodb.com/api/atlas/v1.0",
  "projectId": "some project/group id"
});

const options = {
  "envelope": true,
  "itemsPerPage": 10,
  "pretty": true,
  "httpOptions": { // This parameter will not be sent as querystring. This will be send to http request package `urllib`
    "timeout": 5000
  }
}

const response = await user.getAll(options); // get All users