post-get-service
Advanced tools
@@ -9,2 +9,4 @@ /* eslint-disable unicorn/no-object-as-default-parameter */ | ||
| const default_headers = { 'Content-Type': 'application/json' }; | ||
| function is_retryable_network_error(err) { | ||
@@ -71,2 +73,3 @@ if (err && err.code) { | ||
| * @param {*} headers | ||
| * @param {number} [timeout] timeout | ||
| * @returns {{ | ||
@@ -80,5 +83,6 @@ * host, | ||
| * method, | ||
| * timeout, | ||
| * }} | ||
| */ | ||
| function prepare_request_opts(url, method, headers = {}) { | ||
| function prepare_request_opts(url, method, headers = {}, timeout) { | ||
| const { host, port, pathname, protocol, href } = new URL(url); | ||
@@ -96,2 +100,3 @@ | ||
| method, | ||
| timeout, | ||
| }; | ||
@@ -127,5 +132,6 @@ } | ||
| * @param {!{[k: string]: string}} [headers] request headers | ||
| * @param {number} [timeout] timeout | ||
| */ | ||
| async function get(url, headers = { 'Content-Type': 'application/json' }) { | ||
| const request_opts = prepare_request_opts(url, 'GET', headers); | ||
| async function get(url, headers = { 'Content-Type': 'application/json' }, timeout) { | ||
| const request_opts = prepare_request_opts(url, 'GET', headers, timeout); | ||
@@ -144,5 +150,6 @@ const result = await handle_request(request_opts); | ||
| * @param {!{[k: string]: string}} [headers] request headers | ||
| * @param {number} [timeout] timeout | ||
| */ | ||
| async function post(url, data, headers = { 'Content-Type': 'application/json' }) { | ||
| const request_opts = prepare_request_opts(url, 'POST', headers); | ||
| async function post(url, data, headers = { 'Content-Type': 'application/json' }, timeout) { | ||
| const request_opts = prepare_request_opts(url, 'POST', headers, timeout); | ||
@@ -161,2 +168,3 @@ const result = await handle_request(request_opts, data); | ||
| post, | ||
| default_headers, | ||
| }; |
+1
-1
| { | ||
| "name": "post-get-service", | ||
| "version": "0.0.4", | ||
| "version": "0.0.5", | ||
| "description": "simple way to create node http in memory server", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
20372
1.33%533
1.33%