@ezs/basics 2.10.1 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/url-connect.js +4 -1
- package/lib/url-parse.js +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -738,6 +738,7 @@ Useful to send JSON data to an API and get results.
|
|
|
738
738
|
* `noerror` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Ignore all errors (optional, default `false`)
|
|
739
739
|
* `retries` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The maximum amount of times to retry the connection (optional, default `5`)
|
|
740
740
|
* `encoder` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The statement to encode each chunk to a string (optional, default `dump`)
|
|
741
|
+
* `method` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The method to use for the HTTP request (optional, default `POST`)
|
|
741
742
|
|
|
742
743
|
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
|
|
743
744
|
|
package/lib/url-connect.js
CHANGED
|
@@ -14,6 +14,7 @@ var _asyncRetry = _interopRequireDefault(require("async-retry"));
|
|
|
14
14
|
var _getStream = _interopRequireDefault(require("get-stream"));
|
|
15
15
|
var _fetchWithProxy = _interopRequireDefault(require("fetch-with-proxy"));
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
const restMethods = ['POST', 'GET', 'DELETE', 'PUT', 'PATCH', 'HEAD', 'OPTIONS', 'TRACE'];
|
|
17
18
|
/**
|
|
18
19
|
* Take an `Object` and send it to an URL.
|
|
19
20
|
*
|
|
@@ -29,6 +30,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
29
30
|
* @param {Boolean} [noerror=false] Ignore all errors
|
|
30
31
|
* @param {Number} [retries=5] The maximum amount of times to retry the connection
|
|
31
32
|
* @param {String} [encoder=dump] The statement to encode each chunk to a string
|
|
33
|
+
* @param {String} [method=POST] The method to use for the HTTP request
|
|
32
34
|
* @returns {Object}
|
|
33
35
|
*/
|
|
34
36
|
async function URLConnect(data, feed) {
|
|
@@ -36,6 +38,7 @@ async function URLConnect(data, feed) {
|
|
|
36
38
|
const streaming = Boolean(this.getParam('streaming', false));
|
|
37
39
|
const retries = Number(this.getParam('retries', 5));
|
|
38
40
|
const noerror = Boolean(this.getParam('noerror', false));
|
|
41
|
+
const method = ['POST'].concat(this.getParam('method')).filter(item => restMethods.includes(item)).pop();
|
|
39
42
|
const json = this.getParam('json', true);
|
|
40
43
|
const encoder = this.getParam('encoder', 'dump');
|
|
41
44
|
const {
|
|
@@ -58,7 +61,7 @@ async function URLConnect(data, feed) {
|
|
|
58
61
|
}
|
|
59
62
|
const parameters = {
|
|
60
63
|
timeout,
|
|
61
|
-
method
|
|
64
|
+
method,
|
|
62
65
|
body: bodyIn,
|
|
63
66
|
headers
|
|
64
67
|
};
|
package/lib/url-parse.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezs/basics",
|
|
3
3
|
"description": "Basics statements for EZS",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.11.0",
|
|
5
5
|
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Inist-CNRS/ezs/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"directories": {
|
|
37
37
|
"test": "test"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "02365191717b60d7f9c9b128d6a7e228b921ee3b",
|
|
40
40
|
"homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
|
|
41
41
|
"keywords": [
|
|
42
42
|
"ezs"
|