@nxtedition/lib 19.8.7 → 19.8.8
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/couch.js +13 -27
- package/package.json +2 -2
package/couch.js
CHANGED
|
@@ -7,7 +7,7 @@ import tp from 'timers/promises'
|
|
|
7
7
|
import { defaultDelay as delay } from './http.js'
|
|
8
8
|
import urljoin from 'url-join'
|
|
9
9
|
import { AbortError } from './errors.js'
|
|
10
|
-
import {
|
|
10
|
+
import { dispatch, Agent, Pool, parseHeaders } from '@nxtedition/nxt-undici'
|
|
11
11
|
|
|
12
12
|
// https://github.com/fastify/fastify/blob/main/lib/reqIdGenFactory.js
|
|
13
13
|
// 2,147,483,647 (2^31 − 1) stands for max SMI value (an internal optimization of V8).
|
|
@@ -1091,24 +1091,24 @@ class PromiseOutput {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
|
-
const dispatcherCache = new WeakMap()
|
|
1095
1094
|
const defaultDispatcher = new Agent({
|
|
1096
1095
|
pipelining: 4,
|
|
1097
1096
|
connections: 8,
|
|
1098
1097
|
})
|
|
1098
|
+
|
|
1099
1099
|
export function request(
|
|
1100
1100
|
url,
|
|
1101
1101
|
{
|
|
1102
|
-
body,
|
|
1102
|
+
body = null,
|
|
1103
1103
|
method = body ? 'POST' : 'GET',
|
|
1104
|
-
query,
|
|
1105
|
-
headers,
|
|
1104
|
+
query = null,
|
|
1105
|
+
headers = null,
|
|
1106
1106
|
dispatcher = defaultDispatcher,
|
|
1107
|
-
signal,
|
|
1108
|
-
logger,
|
|
1109
|
-
stream,
|
|
1107
|
+
signal = null,
|
|
1108
|
+
logger = null,
|
|
1109
|
+
stream = false,
|
|
1110
1110
|
blocking = Boolean(stream),
|
|
1111
|
-
},
|
|
1111
|
+
} = {},
|
|
1112
1112
|
) {
|
|
1113
1113
|
signal?.throwIfAborted()
|
|
1114
1114
|
|
|
@@ -1118,13 +1118,12 @@ export function request(
|
|
|
1118
1118
|
}
|
|
1119
1119
|
|
|
1120
1120
|
const opts = {
|
|
1121
|
-
|
|
1122
|
-
path: url.pathname + '?' + querystring.stringify(query),
|
|
1121
|
+
url,
|
|
1123
1122
|
method,
|
|
1123
|
+
query,
|
|
1124
1124
|
blocking,
|
|
1125
1125
|
headers: {
|
|
1126
1126
|
'content-type': body != null && typeof body === 'object' ? 'application/json' : 'plain/text',
|
|
1127
|
-
'user-agent': globalThis.userAgent ?? 'nxt-lib',
|
|
1128
1127
|
accept: 'application/json',
|
|
1129
1128
|
...headers,
|
|
1130
1129
|
},
|
|
@@ -1132,27 +1131,14 @@ export function request(
|
|
|
1132
1131
|
body: body != null && typeof body === 'object' ? JSON.stringify(body) : body,
|
|
1133
1132
|
}
|
|
1134
1133
|
|
|
1135
|
-
let wrappedDispatcher = dispatcherCache.get(dispatcher)
|
|
1136
|
-
if (!wrappedDispatcher) {
|
|
1137
|
-
wrappedDispatcher = dispatcher.compose(
|
|
1138
|
-
interceptors.responseError(),
|
|
1139
|
-
interceptors.log(),
|
|
1140
|
-
interceptors.dns(),
|
|
1141
|
-
interceptors.requestId(),
|
|
1142
|
-
interceptors.responseRetry(),
|
|
1143
|
-
interceptors.responseVerify(),
|
|
1144
|
-
)
|
|
1145
|
-
dispatcherCache.set(dispatcher, wrappedDispatcher)
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
1134
|
if (stream) {
|
|
1149
1135
|
const handler = new StreamOutput({ signal, ...stream })
|
|
1150
|
-
|
|
1136
|
+
dispatch(dispatcher, opts, handler)
|
|
1151
1137
|
return handler
|
|
1152
1138
|
} else {
|
|
1153
1139
|
return new Promise((resolve, reject) => {
|
|
1154
1140
|
const handler = new PromiseOutput({ resolve, reject, signal })
|
|
1155
|
-
|
|
1141
|
+
dispatch(dispatcher, opts, handler)
|
|
1156
1142
|
})
|
|
1157
1143
|
}
|
|
1158
1144
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "19.8.
|
|
3
|
+
"version": "19.8.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@aws-sdk/client-s3": "^3.600.0",
|
|
83
83
|
"@elastic/elasticsearch": "^8.14.0",
|
|
84
84
|
"@elastic/transport": "^8.6.1",
|
|
85
|
-
"@nxtedition/nxt-undici": "^3.
|
|
85
|
+
"@nxtedition/nxt-undici": "^3.3.1",
|
|
86
86
|
"content-type": "^1.0.5",
|
|
87
87
|
"date-fns": "^3.6.0",
|
|
88
88
|
"fast-querystring": "^1.1.1",
|