h3 1.6.2 → 1.6.3
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/README.md +2 -2
- package/dist/index.cjs +4 -6
- package/dist/index.mjs +4 -6
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ Routes are internally stored in a [Radix Tree](https://en.wikipedia.org/wiki/Rad
|
|
|
98
98
|
|
|
99
99
|
```js
|
|
100
100
|
// Handle can directly return object or Promise<object> for JSON response
|
|
101
|
-
app.use('/api', eventHandler((event) => ({ url: event.node.req.url }))
|
|
101
|
+
app.use('/api', eventHandler((event) => ({ url: event.node.req.url })))
|
|
102
102
|
|
|
103
103
|
// We can have better matching other than quick prefix match
|
|
104
104
|
app.use('/odd', eventHandler(() => 'Is odd!'), { match: url => url.substr(1) % 2 })
|
|
@@ -121,7 +121,7 @@ app.use('/api', eventHandler((event) => proxyRequest('https://example.com', {
|
|
|
121
121
|
cookiePathRewrite: {
|
|
122
122
|
"/": "/api"
|
|
123
123
|
},
|
|
124
|
-
}))
|
|
124
|
+
})))
|
|
125
125
|
|
|
126
126
|
// Legacy middleware with 3rd argument are automatically promisified
|
|
127
127
|
app.use(fromNodeMiddleware((req, res, next) => { req.setHeader('x-foo', 'bar'); next() }))
|
package/dist/index.cjs
CHANGED
|
@@ -276,13 +276,11 @@ const ParsedBodySymbol = Symbol.for("h3ParsedBody");
|
|
|
276
276
|
const PayloadMethods$1 = ["PATCH", "POST", "PUT", "DELETE"];
|
|
277
277
|
function readRawBody(event, encoding = "utf8") {
|
|
278
278
|
assertMethod(event, PayloadMethods$1);
|
|
279
|
-
|
|
280
|
-
|
|
279
|
+
const _rawBody = event.node.req[RawBodySymbol] || event.node.req.body;
|
|
280
|
+
if (_rawBody) {
|
|
281
|
+
const promise2 = Promise.resolve(_rawBody);
|
|
281
282
|
return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;
|
|
282
283
|
}
|
|
283
|
-
if ("body" in event.node.req) {
|
|
284
|
-
return Promise.resolve(event.node.req.body);
|
|
285
|
-
}
|
|
286
284
|
if (!Number.parseInt(event.node.req.headers["content-length"] || "")) {
|
|
287
285
|
return Promise.resolve(void 0);
|
|
288
286
|
}
|
|
@@ -305,7 +303,7 @@ async function readBody(event) {
|
|
|
305
303
|
if (ParsedBodySymbol in event.node.req) {
|
|
306
304
|
return event.node.req[ParsedBodySymbol];
|
|
307
305
|
}
|
|
308
|
-
const body = await readRawBody(event);
|
|
306
|
+
const body = await readRawBody(event, "utf8");
|
|
309
307
|
if (event.node.req.headers["content-type"] === "application/x-www-form-urlencoded") {
|
|
310
308
|
const form = new URLSearchParams(body);
|
|
311
309
|
const parsedForm = /* @__PURE__ */ Object.create(null);
|
package/dist/index.mjs
CHANGED
|
@@ -274,13 +274,11 @@ const ParsedBodySymbol = Symbol.for("h3ParsedBody");
|
|
|
274
274
|
const PayloadMethods$1 = ["PATCH", "POST", "PUT", "DELETE"];
|
|
275
275
|
function readRawBody(event, encoding = "utf8") {
|
|
276
276
|
assertMethod(event, PayloadMethods$1);
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
const _rawBody = event.node.req[RawBodySymbol] || event.node.req.body;
|
|
278
|
+
if (_rawBody) {
|
|
279
|
+
const promise2 = Promise.resolve(_rawBody);
|
|
279
280
|
return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;
|
|
280
281
|
}
|
|
281
|
-
if ("body" in event.node.req) {
|
|
282
|
-
return Promise.resolve(event.node.req.body);
|
|
283
|
-
}
|
|
284
282
|
if (!Number.parseInt(event.node.req.headers["content-length"] || "")) {
|
|
285
283
|
return Promise.resolve(void 0);
|
|
286
284
|
}
|
|
@@ -303,7 +301,7 @@ async function readBody(event) {
|
|
|
303
301
|
if (ParsedBodySymbol in event.node.req) {
|
|
304
302
|
return event.node.req[ParsedBodySymbol];
|
|
305
303
|
}
|
|
306
|
-
const body = await readRawBody(event);
|
|
304
|
+
const body = await readRawBody(event, "utf8");
|
|
307
305
|
if (event.node.req.headers["content-type"] === "application/x-www-form-urlencoded") {
|
|
308
306
|
const form = new URLSearchParams(body);
|
|
309
307
|
const parsedForm = /* @__PURE__ */ Object.create(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "h3",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "Tiny JavaScript Server",
|
|
5
5
|
"repository": "unjs/h3",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"defu": "^6.1.2",
|
|
25
25
|
"destr": "^1.2.2",
|
|
26
26
|
"iron-webcrypto": "^0.6.0",
|
|
27
|
-
"radix3": "^1.0.
|
|
27
|
+
"radix3": "^1.0.1",
|
|
28
28
|
"ufo": "^1.1.1",
|
|
29
29
|
"uncrypto": "^0.1.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"0x": "^5.5.0",
|
|
33
33
|
"@types/express": "^4.17.17",
|
|
34
|
-
"@types/node": "^18.15.
|
|
34
|
+
"@types/node": "^18.15.10",
|
|
35
35
|
"@types/supertest": "^2.0.12",
|
|
36
|
-
"@vitest/coverage-c8": "^0.29.
|
|
36
|
+
"@vitest/coverage-c8": "^0.29.7",
|
|
37
37
|
"autocannon": "^7.10.0",
|
|
38
38
|
"changelogen": "^0.5.1",
|
|
39
39
|
"connect": "^3.7.0",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"jiti": "^1.18.2",
|
|
45
45
|
"listhen": "^1.0.4",
|
|
46
46
|
"node-fetch-native": "^1.0.2",
|
|
47
|
-
"prettier": "^2.8.
|
|
47
|
+
"prettier": "^2.8.7",
|
|
48
48
|
"supertest": "^6.3.3",
|
|
49
|
-
"typescript": "^
|
|
49
|
+
"typescript": "^5.0.2",
|
|
50
50
|
"unbuild": "^1.1.2",
|
|
51
|
-
"vitest": "^0.29.
|
|
51
|
+
"vitest": "^0.29.7"
|
|
52
52
|
},
|
|
53
|
-
"packageManager": "pnpm@
|
|
53
|
+
"packageManager": "pnpm@8.0.0",
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "unbuild",
|
|
56
56
|
"dev": "vitest",
|