convertapi
Advanced tools
+22
-22
@@ -41,13 +41,12 @@ 'use strict'; | ||
| }; | ||
| this.httpsAgent = new _https2.default.Agent({ keepAlive: api.keepAlive }); | ||
| } | ||
| get(path, params = {}, timeout = null) { | ||
| const options = { | ||
| const options = this.buildOptions({ | ||
| method: 'get', | ||
| url: this.url(path), | ||
| headers: this.defaultHeader, | ||
| params, | ||
| timeout: timeout * 1000, | ||
| proxy: this.api.proxy | ||
| }; | ||
| timeout: timeout * 1000 | ||
| }); | ||
@@ -58,12 +57,8 @@ return (0, _axios2.default)(options).then(response => response.data).catch(error => Client.handleError(error)); | ||
| post(path, params, timeout = null) { | ||
| const options = { | ||
| const options = this.buildOptions({ | ||
| method: 'post', | ||
| url: this.url(path), | ||
| headers: this.defaultHeader, | ||
| data: (0, _utils.buildQueryString)(params), | ||
| maxContentLength: Infinity, | ||
| maxBodyLength: Infinity, | ||
| timeout: timeout * 1000, | ||
| proxy: this.api.proxy | ||
| }; | ||
| timeout: timeout * 1000 | ||
| }); | ||
@@ -77,8 +72,7 @@ return (0, _axios2.default)(options).then(response => response.data).catch(error => Client.handleError(error)); | ||
| return _asyncToGenerator(function* () { | ||
| const options = { | ||
| const options = _this.buildOptions({ | ||
| url, | ||
| timeout: _this.api.downloadTimeout * 1000, | ||
| proxy: _this.api.proxy, | ||
| responseType: 'stream' | ||
| }; | ||
| }); | ||
@@ -117,3 +111,3 @@ const response = yield (0, _axios2.default)(options).catch(function (error) { | ||
| const options = { | ||
| const options = this.buildOptions({ | ||
| method: 'post', | ||
@@ -123,8 +117,4 @@ url: this.url('upload'), | ||
| data: stream, | ||
| maxContentLength: Infinity, | ||
| maxBodyLength: Infinity, | ||
| timeout: this.api.uploadTimeout * 1000, | ||
| proxy: this.api.proxy, | ||
| httpsAgent: new _https2.default.Agent({ keepAlive: this.api.keepAlive }) | ||
| }; | ||
| timeout: this.api.uploadTimeout * 1000 | ||
| }); | ||
@@ -138,2 +128,12 @@ return (0, _axios2.default)(options).then(response => new _upload_result2.default(response.data)).catch(error => Client.handleError(error)); | ||
| buildOptions(options) { | ||
| return Object.assign({ | ||
| headers: this.defaultHeader, | ||
| maxContentLength: Infinity, | ||
| maxBodyLength: Infinity, | ||
| proxy: this.api.proxy, | ||
| httpsAgent: this.httpsAgent | ||
| }, options); | ||
| } | ||
| static handleError(error) { | ||
@@ -140,0 +140,0 @@ let data; |
+4
-4
| { | ||
| "name": "convertapi", | ||
| "version": "1.13.0", | ||
| "version": "1.14.0", | ||
| "description": "Official convertapi.com API client", | ||
@@ -44,7 +44,7 @@ "main": "./lib/index.js", | ||
| "dependencies": { | ||
| "axios": "^0.21.1" | ||
| "axios": "^1.6.2" | ||
| }, | ||
| "devDependencies": { | ||
| "babel-cli": "^6.26.0", | ||
| "babel-eslint": "^8.2.1", | ||
| "babel-eslint": "^10.1.0", | ||
| "babel-plugin-add-module-exports": "^0.2.1", | ||
@@ -64,5 +64,5 @@ "babel-polyfill": "^6.26.0", | ||
| "istanbul": "^1.0.0-alpha", | ||
| "mocha": "^5.0.0", | ||
| "mocha": "^10.2.0", | ||
| "rimraf": "^2.6.2" | ||
| } | ||
| } |
+0
-4
@@ -11,6 +11,2 @@ # ConvertAPI Node.js Client | ||
| ## Requirements | ||
| Node.js v6.0 and later. | ||
| ## Installation | ||
@@ -17,0 +13,0 @@ |
+19
-19
@@ -16,13 +16,12 @@ import axios from 'axios'; | ||
| }; | ||
| this.httpsAgent = new https.Agent({ keepAlive: api.keepAlive }); | ||
| } | ||
| get(path, params = {}, timeout = null) { | ||
| const options = { | ||
| const options = this.buildOptions({ | ||
| method: 'get', | ||
| url: this.url(path), | ||
| headers: this.defaultHeader, | ||
| params, | ||
| timeout: timeout * 1000, | ||
| proxy: this.api.proxy, | ||
| }; | ||
| }); | ||
@@ -35,12 +34,8 @@ return axios(options) | ||
| post(path, params, timeout = null) { | ||
| const options = { | ||
| const options = this.buildOptions({ | ||
| method: 'post', | ||
| url: this.url(path), | ||
| headers: this.defaultHeader, | ||
| data: buildQueryString(params), | ||
| maxContentLength: Infinity, | ||
| maxBodyLength: Infinity, | ||
| timeout: timeout * 1000, | ||
| proxy: this.api.proxy, | ||
| }; | ||
| }); | ||
@@ -53,8 +48,7 @@ return axios(options) | ||
| async download(url, path) { | ||
| const options = { | ||
| const options = this.buildOptions({ | ||
| url, | ||
| timeout: this.api.downloadTimeout * 1000, | ||
| proxy: this.api.proxy, | ||
| responseType: 'stream', | ||
| }; | ||
| }); | ||
@@ -91,3 +85,3 @@ const response = await axios(options) | ||
| const options = { | ||
| const options = this.buildOptions({ | ||
| method: 'post', | ||
@@ -97,8 +91,4 @@ url: this.url('upload'), | ||
| data: stream, | ||
| maxContentLength: Infinity, | ||
| maxBodyLength: Infinity, | ||
| timeout: this.api.uploadTimeout * 1000, | ||
| proxy: this.api.proxy, | ||
| httpsAgent: new https.Agent({ keepAlive: this.api.keepAlive }), | ||
| }; | ||
| }); | ||
@@ -114,2 +104,12 @@ return axios(options) | ||
| buildOptions(options) { | ||
| return Object.assign({ | ||
| headers: this.defaultHeader, | ||
| maxContentLength: Infinity, | ||
| maxBodyLength: Infinity, | ||
| proxy: this.api.proxy, | ||
| httpsAgent: this.httpsAgent, | ||
| }, options); | ||
| } | ||
| static handleError(error) { | ||
@@ -116,0 +116,0 @@ let data; |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
39236
-0.12%847
-0.24%177
-2.21%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
Updated