@nxtedition/lib 21.2.1 → 21.2.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/http.js +9 -26
- package/package.json +1 -2
package/http.js
CHANGED
|
@@ -7,10 +7,9 @@ import querystring from 'fast-querystring'
|
|
|
7
7
|
import compose from 'koa-compose'
|
|
8
8
|
import http from 'http'
|
|
9
9
|
import fp from 'lodash/fp.js'
|
|
10
|
-
import cookie from 'cookie'
|
|
11
10
|
import tp from 'timers/promises'
|
|
12
11
|
|
|
13
|
-
const kAbortController = Symbol('abortController')
|
|
12
|
+
export const kAbortController = Symbol('abortController')
|
|
14
13
|
|
|
15
14
|
const ERR_HEADER_EXPR =
|
|
16
15
|
/^(content-length|content-type|te|host|upgrade|trailers|connection|keep-alive|http2-settings|transfer-encoding|proxy-connection|proxy-authenticate|proxy-authorization)$/i
|
|
@@ -41,9 +40,7 @@ export class Context {
|
|
|
41
40
|
#ac
|
|
42
41
|
#url
|
|
43
42
|
#logger
|
|
44
|
-
#headers
|
|
45
43
|
#query
|
|
46
|
-
#cookies
|
|
47
44
|
|
|
48
45
|
constructor(req, res, logger) {
|
|
49
46
|
assert(req)
|
|
@@ -54,17 +51,10 @@ export class Context {
|
|
|
54
51
|
this.#req = req
|
|
55
52
|
this.#res = res
|
|
56
53
|
this.#logger = logger.child({ reqId: this.#id, url: req.url })
|
|
57
|
-
this.#headers = {
|
|
58
|
-
'request-id': this.#id,
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
setHeader(name, value) {
|
|
63
|
-
this.#headers[name.toLowerCase()] = value
|
|
64
54
|
}
|
|
65
55
|
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
get id() {
|
|
57
|
+
return this.#id
|
|
68
58
|
}
|
|
69
59
|
|
|
70
60
|
get [kAbortController]() {
|
|
@@ -82,8 +72,13 @@ export class Context {
|
|
|
82
72
|
}
|
|
83
73
|
|
|
84
74
|
set url(value) {
|
|
75
|
+
if (typeof value !== 'string') {
|
|
76
|
+
throw new Error('url must be a string')
|
|
77
|
+
}
|
|
78
|
+
|
|
85
79
|
this.#req.url = value
|
|
86
|
-
this.#url =
|
|
80
|
+
this.#url = undefined
|
|
81
|
+
this.#query = undefined
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
get query() {
|
|
@@ -108,18 +103,6 @@ export class Context {
|
|
|
108
103
|
get method() {
|
|
109
104
|
return this.#req.method
|
|
110
105
|
}
|
|
111
|
-
|
|
112
|
-
get headers() {
|
|
113
|
-
return this.#headers
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
get cookies() {
|
|
117
|
-
if (this.#cookies === undefined) {
|
|
118
|
-
this.#cookies = this.req.headers.cookie ? cookie.parse(this.req.headers.cookie) : null
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return this.#cookies
|
|
122
|
-
}
|
|
123
106
|
}
|
|
124
107
|
|
|
125
108
|
export async function request2(ctx, next) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "21.2.
|
|
3
|
+
"version": "21.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
"@elastic/transport": "^8.7.1",
|
|
60
60
|
"@nxtedition/nxt-undici": "^4.2.13",
|
|
61
61
|
"content-type": "^1.0.5",
|
|
62
|
-
"cookie": "^0.7.2",
|
|
63
62
|
"date-fns": "^3.6.0",
|
|
64
63
|
"fast-querystring": "^1.1.1",
|
|
65
64
|
"hasha": "^6.0.0",
|