@verii/http-client 1.1.0-pre.1770077593 → 1.1.0-pre.1770080046
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/package.json +12 -11
- package/src/client.js +10 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verii/http-client",
|
|
3
|
-
"version": "1.1.0-pre.
|
|
3
|
+
"version": "1.1.0-pre.1770080046",
|
|
4
4
|
"description": "HTTP client for Verii network",
|
|
5
5
|
"repository": "https://github.com/LFDT-Verii/core",
|
|
6
6
|
"main": "index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"test": "cross-env NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout 'test/**/*.test.js'",
|
|
12
12
|
"test:ci": "NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage --test-coverage-include='src/**' --test-reporter=spec --test-reporter=junit --test-reporter-destination=stdout --test-reporter-destination=test-results.junit.xml --test-reporter=lcov --test-reporter-destination=lcov.info 'test/**/*.test.js'",
|
|
13
13
|
"lint": "eslint . --format json >> eslint.json",
|
|
14
|
-
"lint:fix": "eslint --fix
|
|
14
|
+
"lint:fix": "eslint --fix ."
|
|
15
15
|
},
|
|
16
16
|
"author": "Itay Podhajcer",
|
|
17
17
|
"license": "Apache-2.0",
|
|
@@ -24,23 +24,24 @@
|
|
|
24
24
|
"undici-oidc-interceptor": "^0.6.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"eslint": "
|
|
28
|
-
"eslint-config-airbnb-
|
|
29
|
-
"eslint-config-prettier": "
|
|
30
|
-
"eslint-plugin-autofix": "
|
|
31
|
-
"eslint-plugin-better-mutation": "1.
|
|
27
|
+
"eslint": "9.39.2",
|
|
28
|
+
"eslint-config-airbnb-extended": "3.0.1",
|
|
29
|
+
"eslint-config-prettier": "10.1.8",
|
|
30
|
+
"eslint-plugin-autofix": "2.2.0",
|
|
31
|
+
"eslint-plugin-better-mutation": "2.1.0",
|
|
32
32
|
"eslint-plugin-import": "2.32.0",
|
|
33
33
|
"eslint-plugin-prefer-arrow-functions": "3.9.1",
|
|
34
|
-
"eslint-plugin-prettier": "
|
|
35
|
-
"eslint-watch": "
|
|
34
|
+
"eslint-plugin-prettier": "5.5.5",
|
|
35
|
+
"eslint-watch": "8.0.0",
|
|
36
36
|
"expect": "30.2.0",
|
|
37
|
+
"globals": "16.5.0",
|
|
37
38
|
"nodemon": "3.1.11",
|
|
38
|
-
"prettier": "
|
|
39
|
+
"prettier": "3.8.1"
|
|
39
40
|
},
|
|
40
41
|
"nx": {
|
|
41
42
|
"tags": [
|
|
42
43
|
"lib"
|
|
43
44
|
]
|
|
44
45
|
},
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "b095afed30b67c9643860bfddec83169ef8a50b4"
|
|
46
47
|
}
|
package/src/client.js
CHANGED
|
@@ -52,7 +52,7 @@ const initHttpClient = (options) => {
|
|
|
52
52
|
host,
|
|
53
53
|
{ traceId, log },
|
|
54
54
|
body,
|
|
55
|
-
contentType
|
|
55
|
+
contentType,
|
|
56
56
|
) => {
|
|
57
57
|
const reqId = nanoid();
|
|
58
58
|
const reqHeaders = buildReqHeaders(reqOptions, contentType, traceId);
|
|
@@ -81,13 +81,13 @@ const initHttpClient = (options) => {
|
|
|
81
81
|
const bodyJson = await rawBody.json();
|
|
82
82
|
log.info(
|
|
83
83
|
{ origin, url, reqId, statusCode, resHeaders, body: bodyJson },
|
|
84
|
-
'HttpClient response'
|
|
84
|
+
'HttpClient response',
|
|
85
85
|
);
|
|
86
86
|
return bodyJson;
|
|
87
87
|
} catch (error) {
|
|
88
88
|
log.error(
|
|
89
89
|
{ origin, url, reqId, statusCode, resHeaders, error },
|
|
90
|
-
'JSON parsing error'
|
|
90
|
+
'JSON parsing error',
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
return {};
|
|
@@ -97,7 +97,7 @@ const initHttpClient = (options) => {
|
|
|
97
97
|
const bodyText = await rawBody.text();
|
|
98
98
|
log.info(
|
|
99
99
|
{ origin, url, reqId, statusCode, resHeaders, body: bodyText },
|
|
100
|
-
'HttpClient response'
|
|
100
|
+
'HttpClient response',
|
|
101
101
|
);
|
|
102
102
|
return bodyText;
|
|
103
103
|
},
|
|
@@ -135,7 +135,7 @@ const initHttpClient = (options) => {
|
|
|
135
135
|
host,
|
|
136
136
|
context,
|
|
137
137
|
isObject(payload) ? JSON.stringify(payload) : payload,
|
|
138
|
-
calcContentType(payload, reqOptions?.headers)
|
|
138
|
+
calcContentType(payload, reqOptions?.headers),
|
|
139
139
|
),
|
|
140
140
|
delete: (url, reqOptions = {}) =>
|
|
141
141
|
request(url, reqOptions, HTTP_VERBS.DELETE, host, context),
|
|
@@ -157,7 +157,7 @@ const parseArgs = (presetHost, args) => {
|
|
|
157
157
|
return { host: parsePrefixUrl(args[0]), context: args[1] };
|
|
158
158
|
}
|
|
159
159
|
throw new Error(
|
|
160
|
-
`HttpClient: Expected 1 or 2 arguments, received ${args.length}
|
|
160
|
+
`HttpClient: Expected 1 or 2 arguments, received ${args.length}`,
|
|
161
161
|
);
|
|
162
162
|
};
|
|
163
163
|
|
|
@@ -188,12 +188,12 @@ const buildInterceptorChain = (
|
|
|
188
188
|
clientSecret,
|
|
189
189
|
scopes,
|
|
190
190
|
audience,
|
|
191
|
-
}
|
|
191
|
+
},
|
|
192
192
|
) => {
|
|
193
193
|
const chain = [];
|
|
194
194
|
if (!isTest) {
|
|
195
195
|
chain.push(
|
|
196
|
-
interceptors.dns({ maxTTL: 300000, maxItems: 2000, dualStack: false })
|
|
196
|
+
interceptors.dns({ maxTTL: 300000, maxItems: 2000, dualStack: false }),
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -234,7 +234,7 @@ const buildUrl = (host, url, reqOptions) => {
|
|
|
234
234
|
}
|
|
235
235
|
if (!host) {
|
|
236
236
|
throw new Error(
|
|
237
|
-
'HttpClient: Cannot build URL without prefixUrl or full url'
|
|
237
|
+
'HttpClient: Cannot build URL without prefixUrl or full url',
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
return [host.origin, buildRelativePath(host.rootPath ?? '', url, reqOptions)];
|
|
@@ -255,7 +255,7 @@ const buildRelativePath = (rootPath, url, reqOptions) => {
|
|
|
255
255
|
return addSearchParams(
|
|
256
256
|
pathname,
|
|
257
257
|
new URLSearchParams(searchParamsString),
|
|
258
|
-
reqOptions?.searchParams
|
|
258
|
+
reqOptions?.searchParams,
|
|
259
259
|
);
|
|
260
260
|
};
|
|
261
261
|
|