@nxtedition/lib 21.4.0 → 21.4.2
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 +2 -2
- package/http.js +13 -3
- package/package.json +1 -1
- package/serializers.js +4 -0
package/couch.js
CHANGED
|
@@ -117,7 +117,7 @@ export function makeCouch(opts) {
|
|
|
117
117
|
* @param {number} [options.heartbeat=60000] - The interval at which to send a heartbeat.
|
|
118
118
|
* @param {function} [options.retry=null] - The function to retry the request on error.
|
|
119
119
|
* @param {string} [options.since=null] - The sequence number to start from.
|
|
120
|
-
* @param {
|
|
120
|
+
* @param {number} [options.highWaterMark=128 * 1024] - Buffering.
|
|
121
121
|
* @yields {Array<{ id: string, seq?: string, doc?: Object, deleted?: boolean, changes: Array<{ rev: string }> }>}
|
|
122
122
|
*/
|
|
123
123
|
async function* changes({ client = defaultClient, signal = null, logger, ...options } = {}) {
|
|
@@ -208,7 +208,7 @@ export function makeCouch(opts) {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
const highWaterMark = options.highWaterMark
|
|
211
|
+
const highWaterMark = options.highWaterMark || 128 * 1024
|
|
212
212
|
const live = options.live == null || !!options.live
|
|
213
213
|
const retry =
|
|
214
214
|
options.retry ??
|
package/http.js
CHANGED
|
@@ -35,6 +35,7 @@ function onTimeout() {
|
|
|
35
35
|
|
|
36
36
|
export class Context {
|
|
37
37
|
#id
|
|
38
|
+
#userAgent
|
|
38
39
|
#req
|
|
39
40
|
#res
|
|
40
41
|
#ac
|
|
@@ -47,16 +48,21 @@ export class Context {
|
|
|
47
48
|
assert(res)
|
|
48
49
|
assert(logger)
|
|
49
50
|
|
|
50
|
-
this.#id = req.headers['request-id'] || genReqId()
|
|
51
|
+
this.#id = req.headers['request-id'] || req.headers['Request-Id'] || genReqId()
|
|
52
|
+
this.#id = req.headers['user-agent'] || req.headers['User-Agent'] || ''
|
|
51
53
|
this.#req = req
|
|
52
54
|
this.#res = res
|
|
53
|
-
this.#logger = logger.child({ reqId: this.#id, url: req.url })
|
|
55
|
+
this.#logger = logger.child({ reqId: this.#id, url: req.url, userAgent: this.#userAgent })
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
get id() {
|
|
57
59
|
return this.#id
|
|
58
60
|
}
|
|
59
61
|
|
|
62
|
+
get userAgent() {
|
|
63
|
+
return this.#userAgent
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
get [kAbortController]() {
|
|
61
67
|
return this.#ac
|
|
62
68
|
}
|
|
@@ -229,9 +235,13 @@ export async function request(ctx, next) {
|
|
|
229
235
|
}
|
|
230
236
|
|
|
231
237
|
ctx.id = req.id = res.id = req.headers['request-id'] || genReqId()
|
|
238
|
+
ctx.userAgent = req['user-agent'] || req['User-Agent'] || ''
|
|
232
239
|
ctx.method = req.method
|
|
233
240
|
ctx.query = ctx.url.search.length > 1 ? querystring.parse(ctx.url.search.slice(1)) : {}
|
|
234
|
-
ctx.logger =
|
|
241
|
+
ctx.logger =
|
|
242
|
+
req.log =
|
|
243
|
+
res.log =
|
|
244
|
+
logger.child({ req: { id: req.id, url: req.url, userAgent: ctx.userAgent } })
|
|
235
245
|
|
|
236
246
|
if (ac) {
|
|
237
247
|
ctx.signal = ac.signal
|
package/package.json
CHANGED
package/serializers.js
CHANGED
|
@@ -48,6 +48,7 @@ export default {
|
|
|
48
48
|
res: (res) =>
|
|
49
49
|
res && {
|
|
50
50
|
id: res.id || res.req?.id || getHeader(res, 'request-id') || getHeader(res.req, 'request-id'),
|
|
51
|
+
userAgent: res.userAgent ?? getHeader(res, 'user-agent'),
|
|
51
52
|
timing: getTiming(res),
|
|
52
53
|
statusCode: res.statusCode || res.status,
|
|
53
54
|
bytesWritten: res.bytesWritten,
|
|
@@ -62,6 +63,7 @@ export default {
|
|
|
62
63
|
req: (req) =>
|
|
63
64
|
req && {
|
|
64
65
|
id: req.id || getHeader(req, 'request-id'),
|
|
66
|
+
userAgent: req.userAgent ?? getHeader(req, 'user-agent'),
|
|
65
67
|
timing: getTiming(req),
|
|
66
68
|
method: req.method,
|
|
67
69
|
url: req.url,
|
|
@@ -83,6 +85,7 @@ export default {
|
|
|
83
85
|
ures: (ures) =>
|
|
84
86
|
ures && {
|
|
85
87
|
id: ures.id || getHeader(ures, 'request-id') || getHeader(ures.req, 'request-id'),
|
|
88
|
+
userAgent: ures.userAgent ?? getHeader(ures, 'user-agent'),
|
|
86
89
|
timing: getTiming(ures),
|
|
87
90
|
statusCode: ures.statusCode ?? ures.status,
|
|
88
91
|
bytesRead: ures.bytesRead,
|
|
@@ -113,6 +116,7 @@ export default {
|
|
|
113
116
|
|
|
114
117
|
return {
|
|
115
118
|
id: ureq.id || getHeader(ureq, 'request-id'),
|
|
119
|
+
userAgent: ureq.userAgent ?? getHeader(ureq, 'user-agent'),
|
|
116
120
|
timing: getTiming(ureq),
|
|
117
121
|
method: ureq.method,
|
|
118
122
|
url,
|