@k03mad/request 5.0.0 → 5.1.1
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/app/lib/curl.js +13 -18
- package/package.json +2 -2
package/app/lib/curl.js
CHANGED
|
@@ -24,27 +24,22 @@ export default (url, {
|
|
|
24
24
|
}, res) => {
|
|
25
25
|
const msg = [];
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const fullUrl = searchParams
|
|
28
|
+
? `${url}?${new URLSearchParams(searchParams).toString()}`
|
|
29
|
+
: url;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
resClone = resClone.response;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (resClone?.statusCode) {
|
|
35
|
-
msg.push(bgWhite(black(resClone.statusCode)));
|
|
36
|
-
}
|
|
31
|
+
const response = res?.response || res;
|
|
37
32
|
|
|
38
|
-
if (
|
|
39
|
-
msg.push(
|
|
33
|
+
if (response.statusCode) {
|
|
34
|
+
msg.push(bgWhite(black(response.statusCode)));
|
|
40
35
|
}
|
|
41
36
|
|
|
42
|
-
if (
|
|
43
|
-
msg.push(`[${
|
|
37
|
+
if (response.timings) {
|
|
38
|
+
msg.push(`[${response.timings.phases.total} ms]`);
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
if (
|
|
47
|
-
|
|
41
|
+
if (response.headers?.['content-length']) {
|
|
42
|
+
msg.push(`[${prettyBytes(Number(response.headers['content-length']))}]`);
|
|
48
43
|
}
|
|
49
44
|
|
|
50
45
|
msg.push(white('curl -v -X'), green(method));
|
|
@@ -53,7 +48,7 @@ export default (url, {
|
|
|
53
48
|
msg.push(dim(red(`-u ${username}:${password}`)));
|
|
54
49
|
}
|
|
55
50
|
|
|
56
|
-
msg.push(blue(
|
|
51
|
+
msg.push(blue(fullUrl));
|
|
57
52
|
|
|
58
53
|
let bodyParams;
|
|
59
54
|
|
|
@@ -77,8 +72,8 @@ export default (url, {
|
|
|
77
72
|
msg.push(dim(yellow(bodyParams)));
|
|
78
73
|
}
|
|
79
74
|
|
|
80
|
-
if (
|
|
81
|
-
const message = JSON.stringify(
|
|
75
|
+
if (response) {
|
|
76
|
+
const message = JSON.stringify(response.body || response.message);
|
|
82
77
|
|
|
83
78
|
if (message?.length < 1500) {
|
|
84
79
|
msg.push(`\n${dim(green(message))}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k03mad/request",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "Request library",
|
|
5
5
|
"maintainers": [
|
|
6
6
|
"Kirill Molchanov <k03.mad@gmail.com"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"pretty-bytes": "6.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@k03mad/eslint-config": "17.
|
|
23
|
+
"@k03mad/eslint-config": "17.12.3",
|
|
24
24
|
"eslint": "8.56.0",
|
|
25
25
|
"husky": "8.0.3"
|
|
26
26
|
},
|