@nxtedition/lib 19.8.7 → 19.8.9
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 +17 -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,26 @@ 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
|
+
headerTimeout,
|
|
1112
|
+
bodyTimeout,
|
|
1113
|
+
} = {},
|
|
1112
1114
|
) {
|
|
1113
1115
|
signal?.throwIfAborted()
|
|
1114
1116
|
|
|
@@ -1118,41 +1120,29 @@ export function request(
|
|
|
1118
1120
|
}
|
|
1119
1121
|
|
|
1120
1122
|
const opts = {
|
|
1121
|
-
|
|
1122
|
-
path: url.pathname + '?' + querystring.stringify(query),
|
|
1123
|
+
url,
|
|
1123
1124
|
method,
|
|
1125
|
+
query,
|
|
1124
1126
|
blocking,
|
|
1125
1127
|
headers: {
|
|
1126
1128
|
'content-type': body != null && typeof body === 'object' ? 'application/json' : 'plain/text',
|
|
1127
|
-
'user-agent': globalThis.userAgent ?? 'nxt-lib',
|
|
1128
1129
|
accept: 'application/json',
|
|
1129
1130
|
...headers,
|
|
1130
1131
|
},
|
|
1131
1132
|
logger,
|
|
1132
1133
|
body: body != null && typeof body === 'object' ? JSON.stringify(body) : body,
|
|
1133
|
-
|
|
1134
|
-
|
|
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)
|
|
1134
|
+
headerTimeout,
|
|
1135
|
+
bodyTimeout,
|
|
1146
1136
|
}
|
|
1147
1137
|
|
|
1148
1138
|
if (stream) {
|
|
1149
1139
|
const handler = new StreamOutput({ signal, ...stream })
|
|
1150
|
-
|
|
1140
|
+
dispatch(dispatcher, opts, handler)
|
|
1151
1141
|
return handler
|
|
1152
1142
|
} else {
|
|
1153
1143
|
return new Promise((resolve, reject) => {
|
|
1154
1144
|
const handler = new PromiseOutput({ resolve, reject, signal })
|
|
1155
|
-
|
|
1145
|
+
dispatch(dispatcher, opts, handler)
|
|
1156
1146
|
})
|
|
1157
1147
|
}
|
|
1158
1148
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "19.8.
|
|
3
|
+
"version": "19.8.9",
|
|
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",
|