hono 4.0.2 → 4.0.4
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/dist/cjs/context.js +1 -1
- package/dist/cjs/helper/html/index.js +12 -5
- package/dist/cjs/helper/ssg/index.js +4 -0
- package/dist/cjs/hono-base.js +1 -3
- package/dist/cjs/jsx/components.js +3 -3
- package/dist/cjs/jsx/dom/render.js +12 -10
- package/dist/cjs/jsx/hooks/index.js +12 -6
- package/dist/cjs/jsx/streaming.js +1 -1
- package/dist/cjs/middleware/jsx-renderer/index.js +7 -4
- package/dist/cjs/middleware/jwt/index.js +2 -2
- package/dist/cjs/validator/validator.js +8 -0
- package/dist/context.js +1 -1
- package/dist/helper/html/index.js +12 -5
- package/dist/helper/ssg/index.js +4 -0
- package/dist/hono-base.js +1 -3
- package/dist/jsx/components.js +3 -3
- package/dist/jsx/dom/render.js +12 -10
- package/dist/jsx/hooks/index.js +12 -6
- package/dist/jsx/streaming.js +1 -1
- package/dist/middleware/jsx-renderer/index.js +7 -4
- package/dist/middleware/jwt/index.js +1 -1
- package/dist/validator/validator.js +8 -0
- package/package.json +2 -2
- package/dist/types/helper.d.ts +0 -10
package/dist/cjs/context.js
CHANGED
|
@@ -124,7 +124,7 @@ class Context {
|
|
|
124
124
|
const headers2 = setHeaders(new Headers(arg.headers), __privateGet(this, _preparedHeaders));
|
|
125
125
|
return new Response(data, {
|
|
126
126
|
headers: headers2,
|
|
127
|
-
status: arg.status
|
|
127
|
+
status: arg.status ?? __privateGet(this, _status)
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
const status = typeof arg === "number" ? arg : __privateGet(this, _status);
|
|
@@ -32,14 +32,21 @@ const html = (strings, ...values) => {
|
|
|
32
32
|
const child = children[i2];
|
|
33
33
|
if (typeof child === "string") {
|
|
34
34
|
(0, import_html.escapeToBuffer)(child, buffer);
|
|
35
|
+
} else if (typeof child === "number") {
|
|
36
|
+
;
|
|
37
|
+
buffer[0] += child;
|
|
35
38
|
} else if (typeof child === "boolean" || child === null || child === void 0) {
|
|
36
39
|
continue;
|
|
37
|
-
} else if (typeof child === "object" && child.isEscaped
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
buffer.unshift("", tmp);
|
|
40
|
+
} else if (typeof child === "object" && child.isEscaped) {
|
|
41
|
+
if (child.callbacks) {
|
|
42
|
+
buffer.unshift("", child);
|
|
41
43
|
} else {
|
|
42
|
-
|
|
44
|
+
const tmp = child.toString();
|
|
45
|
+
if (tmp instanceof Promise) {
|
|
46
|
+
buffer.unshift("", tmp);
|
|
47
|
+
} else {
|
|
48
|
+
buffer[0] += tmp;
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
51
|
} else if (child instanceof Promise) {
|
|
45
52
|
buffer.unshift("", child);
|
|
@@ -35,6 +35,10 @@ var import_utils2 = require("./utils");
|
|
|
35
35
|
const SSG_CONTEXT = "HONO_SSG_CONTEXT";
|
|
36
36
|
const SSG_DISABLED_RESPONSE = new Response("SSG is disabled", { status: 404 });
|
|
37
37
|
const generateFilePath = (routePath, outDir, mimeType) => {
|
|
38
|
+
const hasExtension = /\.[^\/]+$/.test(routePath);
|
|
39
|
+
if (hasExtension) {
|
|
40
|
+
return (0, import_utils2.joinPaths)(outDir, routePath);
|
|
41
|
+
}
|
|
38
42
|
const extension = determineExtension(mimeType);
|
|
39
43
|
if (routePath === "/") {
|
|
40
44
|
return (0, import_utils2.joinPaths)(outDir, `index.${extension}`);
|
package/dist/cjs/hono-base.js
CHANGED
|
@@ -233,10 +233,8 @@ const _Hono = class extends defineDynamicClass() {
|
|
|
233
233
|
let res;
|
|
234
234
|
try {
|
|
235
235
|
res = matchResult[0][0][0][0](c, async () => {
|
|
236
|
+
c.res = await this.notFoundHandler(c);
|
|
236
237
|
});
|
|
237
|
-
if (!res) {
|
|
238
|
-
return this.notFoundHandler(c);
|
|
239
|
-
}
|
|
240
238
|
} catch (err) {
|
|
241
239
|
return this.handleError(err, c);
|
|
242
240
|
}
|
|
@@ -77,7 +77,7 @@ const ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) =>
|
|
|
77
77
|
if (buffer) {
|
|
78
78
|
buffer[0] = buffer[0].replace(replaceRe, fallbackResString);
|
|
79
79
|
}
|
|
80
|
-
return buffer ? "" : `<template>${fallbackResString}</template><script>
|
|
80
|
+
return buffer ? "" : `<template data-hono-target="E:${index}">${fallbackResString}</template><script>
|
|
81
81
|
((d,c,n) => {
|
|
82
82
|
c=d.currentScript.previousSibling
|
|
83
83
|
d=d.getElementById('E:${index}')
|
|
@@ -95,7 +95,7 @@ d.replaceWith(c.content)
|
|
|
95
95
|
return Promise.all(resArray).then(async (htmlArray) => {
|
|
96
96
|
htmlArray = htmlArray.flat();
|
|
97
97
|
const content = htmlArray.join("");
|
|
98
|
-
let html = buffer ? "" : `<template>${content}</template><script>
|
|
98
|
+
let html = buffer ? "" : `<template data-hono-target="E:${index}">${content}</template><script>
|
|
99
99
|
((d,c) => {
|
|
100
100
|
c=d.currentScript.previousSibling
|
|
101
101
|
d=d.getElementById('E:${index}')
|
|
@@ -141,7 +141,7 @@ d.parentElement.insertBefore(c.content,d.nextSibling)
|
|
|
141
141
|
d=d.getElementById('E:${index}')
|
|
142
142
|
if(!d)return
|
|
143
143
|
n=d.nextSibling
|
|
144
|
-
|
|
144
|
+
while(n.nodeType!=8||n.nodeValue!='E:${index}'){n=n.nextSibling}
|
|
145
145
|
n.remove()
|
|
146
146
|
d.remove()
|
|
147
147
|
})(document)
|
|
@@ -178,22 +178,24 @@ const applyNode = (node, container) => {
|
|
|
178
178
|
applyNodeObject(node, container);
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
|
+
const findChildNodeIndex = (childNodes, child) => {
|
|
182
|
+
if (!child) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
for (let i = 0, len = childNodes.length; i < len; i++) {
|
|
186
|
+
if (childNodes[i] === child) {
|
|
187
|
+
return i;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return;
|
|
191
|
+
};
|
|
181
192
|
const applyNodeObject = (node, container) => {
|
|
182
193
|
const next = [];
|
|
183
194
|
const remove = [];
|
|
184
195
|
const callbacks = [];
|
|
185
196
|
getNextChildren(node, container, next, remove, callbacks);
|
|
186
|
-
let offset = container.childNodes.length;
|
|
187
|
-
const insertBefore = findInsertBefore(node.nN) || next.find((n) => n.e)?.e;
|
|
188
|
-
if (insertBefore) {
|
|
189
|
-
for (let i = 0; i < offset; i++) {
|
|
190
|
-
if (container.childNodes[i] === insertBefore) {
|
|
191
|
-
offset = i;
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
197
|
const childNodes = container.childNodes;
|
|
198
|
+
let offset = findChildNodeIndex(childNodes, findInsertBefore(node.nN)) ?? findChildNodeIndex(childNodes, next.find((n) => n.e)?.e) ?? childNodes.length;
|
|
197
199
|
for (let i = 0, len = next.length; i < len; i++, offset++) {
|
|
198
200
|
const child = next[i];
|
|
199
201
|
let el;
|
|
@@ -237,7 +237,10 @@ const use = (promise) => {
|
|
|
237
237
|
}
|
|
238
238
|
return cachedRes[0];
|
|
239
239
|
}
|
|
240
|
-
promise.then(
|
|
240
|
+
promise.then(
|
|
241
|
+
(res2) => resolvedPromiseValueMap.set(promise, [res2]),
|
|
242
|
+
(e) => resolvedPromiseValueMap.set(promise, [void 0, e])
|
|
243
|
+
);
|
|
241
244
|
const buildData = import_render.buildDataStack.at(-1);
|
|
242
245
|
if (!buildData) {
|
|
243
246
|
throw promise;
|
|
@@ -245,11 +248,14 @@ const use = (promise) => {
|
|
|
245
248
|
const [, node] = buildData;
|
|
246
249
|
const promiseArray = (_a = node[import_constants.DOM_STASH][1])[STASH_USE] || (_a[STASH_USE] = []);
|
|
247
250
|
const hookIndex = node[import_constants.DOM_STASH][0]++;
|
|
248
|
-
promise.then(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
promise.then(
|
|
252
|
+
(res2) => {
|
|
253
|
+
promiseArray[hookIndex] = [res2];
|
|
254
|
+
},
|
|
255
|
+
(e) => {
|
|
256
|
+
promiseArray[hookIndex] = [void 0, e];
|
|
257
|
+
}
|
|
258
|
+
);
|
|
253
259
|
const res = promiseArray[hookIndex];
|
|
254
260
|
if (res) {
|
|
255
261
|
if (res.length === 2) {
|
|
@@ -82,7 +82,7 @@ const Suspense = async ({
|
|
|
82
82
|
content
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
|
-
let html = buffer ? "" : `<template>${content}</template><script>
|
|
85
|
+
let html = buffer ? "" : `<template data-hono-target="H:${index}">${content}</template><script>
|
|
86
86
|
((d,c,n) => {
|
|
87
87
|
c=d.currentScript.previousSibling
|
|
88
88
|
d=d.getElementById('H:${index}')
|
|
@@ -29,10 +29,13 @@ var import_streaming = require("../../jsx/streaming");
|
|
|
29
29
|
const RequestContext = (0, import_jsx.createContext)(null);
|
|
30
30
|
const createRenderer = (c, Layout, component, options) => (children, props) => {
|
|
31
31
|
const docType = typeof options?.docType === "string" ? options.docType : options?.docType === false ? "" : "<!DOCTYPE html>";
|
|
32
|
-
const currentLayout = component ?
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const currentLayout = component ? (0, import_jsx.jsx)(
|
|
33
|
+
component,
|
|
34
|
+
{
|
|
35
|
+
...{ Layout, ...props }
|
|
36
|
+
},
|
|
37
|
+
children
|
|
38
|
+
) : children;
|
|
36
39
|
const body = import_html.html`${(0, import_html.raw)(docType)}${(0, import_jsx.jsx)(
|
|
37
40
|
RequestContext.Provider,
|
|
38
41
|
{ value: c },
|
|
@@ -24,7 +24,7 @@ __export(jwt_exports, {
|
|
|
24
24
|
verify: () => verify
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(jwt_exports);
|
|
27
|
-
var
|
|
27
|
+
var import_cookie = require("../../helper/cookie");
|
|
28
28
|
var import_http_exception = require("../../http-exception");
|
|
29
29
|
var import_jwt = require("../../utils/jwt");
|
|
30
30
|
var import_context = require("../../context");
|
|
@@ -52,7 +52,7 @@ const jwt = (options) => {
|
|
|
52
52
|
token = parts[1];
|
|
53
53
|
}
|
|
54
54
|
} else if (options.cookie) {
|
|
55
|
-
token = (0,
|
|
55
|
+
token = (0, import_cookie.getCookie)(ctx)[options.cookie];
|
|
56
56
|
}
|
|
57
57
|
if (!token) {
|
|
58
58
|
throw new import_http_exception.HTTPException(401, {
|
|
@@ -34,6 +34,10 @@ const validator = (target, validationFunc) => {
|
|
|
34
34
|
const message = `Invalid HTTP header: Content-Type=${contentType}`;
|
|
35
35
|
throw new import_http_exception.HTTPException(400, { message });
|
|
36
36
|
}
|
|
37
|
+
if (c.req.bodyCache.json) {
|
|
38
|
+
value = await c.req.bodyCache.json;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
37
41
|
try {
|
|
38
42
|
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
|
|
39
43
|
value = await new Response(arrayBuffer).json();
|
|
@@ -45,6 +49,10 @@ const validator = (target, validationFunc) => {
|
|
|
45
49
|
}
|
|
46
50
|
break;
|
|
47
51
|
case "form": {
|
|
52
|
+
if (c.req.bodyCache.formData) {
|
|
53
|
+
value = c.req.bodyCache.formData;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
48
56
|
try {
|
|
49
57
|
const contentType2 = c.req.header("Content-Type");
|
|
50
58
|
if (contentType2) {
|
package/dist/context.js
CHANGED
|
@@ -102,7 +102,7 @@ var Context = class {
|
|
|
102
102
|
const headers2 = setHeaders(new Headers(arg.headers), __privateGet(this, _preparedHeaders));
|
|
103
103
|
return new Response(data, {
|
|
104
104
|
headers: headers2,
|
|
105
|
-
status: arg.status
|
|
105
|
+
status: arg.status ?? __privateGet(this, _status)
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
const status = typeof arg === "number" ? arg : __privateGet(this, _status);
|
|
@@ -9,14 +9,21 @@ var html = (strings, ...values) => {
|
|
|
9
9
|
const child = children[i2];
|
|
10
10
|
if (typeof child === "string") {
|
|
11
11
|
escapeToBuffer(child, buffer);
|
|
12
|
+
} else if (typeof child === "number") {
|
|
13
|
+
;
|
|
14
|
+
buffer[0] += child;
|
|
12
15
|
} else if (typeof child === "boolean" || child === null || child === void 0) {
|
|
13
16
|
continue;
|
|
14
|
-
} else if (typeof child === "object" && child.isEscaped
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
buffer.unshift("", tmp);
|
|
17
|
+
} else if (typeof child === "object" && child.isEscaped) {
|
|
18
|
+
if (child.callbacks) {
|
|
19
|
+
buffer.unshift("", child);
|
|
18
20
|
} else {
|
|
19
|
-
|
|
21
|
+
const tmp = child.toString();
|
|
22
|
+
if (tmp instanceof Promise) {
|
|
23
|
+
buffer.unshift("", tmp);
|
|
24
|
+
} else {
|
|
25
|
+
buffer[0] += tmp;
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
} else if (child instanceof Promise) {
|
|
22
29
|
buffer.unshift("", child);
|
package/dist/helper/ssg/index.js
CHANGED
|
@@ -6,6 +6,10 @@ import { joinPaths, dirname, filterStaticGenerateRoutes } from "./utils.js";
|
|
|
6
6
|
var SSG_CONTEXT = "HONO_SSG_CONTEXT";
|
|
7
7
|
var SSG_DISABLED_RESPONSE = new Response("SSG is disabled", { status: 404 });
|
|
8
8
|
var generateFilePath = (routePath, outDir, mimeType) => {
|
|
9
|
+
const hasExtension = /\.[^\/]+$/.test(routePath);
|
|
10
|
+
if (hasExtension) {
|
|
11
|
+
return joinPaths(outDir, routePath);
|
|
12
|
+
}
|
|
9
13
|
const extension = determineExtension(mimeType);
|
|
10
14
|
if (routePath === "/") {
|
|
11
15
|
return joinPaths(outDir, `index.${extension}`);
|
package/dist/hono-base.js
CHANGED
|
@@ -211,10 +211,8 @@ var _Hono = class extends defineDynamicClass() {
|
|
|
211
211
|
let res;
|
|
212
212
|
try {
|
|
213
213
|
res = matchResult[0][0][0][0](c, async () => {
|
|
214
|
+
c.res = await this.notFoundHandler(c);
|
|
214
215
|
});
|
|
215
|
-
if (!res) {
|
|
216
|
-
return this.notFoundHandler(c);
|
|
217
|
-
}
|
|
218
216
|
} catch (err) {
|
|
219
217
|
return this.handleError(err, c);
|
|
220
218
|
}
|
package/dist/jsx/components.js
CHANGED
|
@@ -54,7 +54,7 @@ var ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) => {
|
|
|
54
54
|
if (buffer) {
|
|
55
55
|
buffer[0] = buffer[0].replace(replaceRe, fallbackResString);
|
|
56
56
|
}
|
|
57
|
-
return buffer ? "" : `<template>${fallbackResString}</template><script>
|
|
57
|
+
return buffer ? "" : `<template data-hono-target="E:${index}">${fallbackResString}</template><script>
|
|
58
58
|
((d,c,n) => {
|
|
59
59
|
c=d.currentScript.previousSibling
|
|
60
60
|
d=d.getElementById('E:${index}')
|
|
@@ -72,7 +72,7 @@ d.replaceWith(c.content)
|
|
|
72
72
|
return Promise.all(resArray).then(async (htmlArray) => {
|
|
73
73
|
htmlArray = htmlArray.flat();
|
|
74
74
|
const content = htmlArray.join("");
|
|
75
|
-
let html = buffer ? "" : `<template>${content}</template><script>
|
|
75
|
+
let html = buffer ? "" : `<template data-hono-target="E:${index}">${content}</template><script>
|
|
76
76
|
((d,c) => {
|
|
77
77
|
c=d.currentScript.previousSibling
|
|
78
78
|
d=d.getElementById('E:${index}')
|
|
@@ -118,7 +118,7 @@ d.parentElement.insertBefore(c.content,d.nextSibling)
|
|
|
118
118
|
d=d.getElementById('E:${index}')
|
|
119
119
|
if(!d)return
|
|
120
120
|
n=d.nextSibling
|
|
121
|
-
|
|
121
|
+
while(n.nodeType!=8||n.nodeValue!='E:${index}'){n=n.nextSibling}
|
|
122
122
|
n.remove()
|
|
123
123
|
d.remove()
|
|
124
124
|
})(document)
|
package/dist/jsx/dom/render.js
CHANGED
|
@@ -153,22 +153,24 @@ var applyNode = (node, container) => {
|
|
|
153
153
|
applyNodeObject(node, container);
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
|
+
var findChildNodeIndex = (childNodes, child) => {
|
|
157
|
+
if (!child) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
for (let i = 0, len = childNodes.length; i < len; i++) {
|
|
161
|
+
if (childNodes[i] === child) {
|
|
162
|
+
return i;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
};
|
|
156
167
|
var applyNodeObject = (node, container) => {
|
|
157
168
|
const next = [];
|
|
158
169
|
const remove = [];
|
|
159
170
|
const callbacks = [];
|
|
160
171
|
getNextChildren(node, container, next, remove, callbacks);
|
|
161
|
-
let offset = container.childNodes.length;
|
|
162
|
-
const insertBefore = findInsertBefore(node.nN) || next.find((n) => n.e)?.e;
|
|
163
|
-
if (insertBefore) {
|
|
164
|
-
for (let i = 0; i < offset; i++) {
|
|
165
|
-
if (container.childNodes[i] === insertBefore) {
|
|
166
|
-
offset = i;
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
172
|
const childNodes = container.childNodes;
|
|
173
|
+
let offset = findChildNodeIndex(childNodes, findInsertBefore(node.nN)) ?? findChildNodeIndex(childNodes, next.find((n) => n.e)?.e) ?? childNodes.length;
|
|
172
174
|
for (let i = 0, len = next.length; i < len; i++, offset++) {
|
|
173
175
|
const child = next[i];
|
|
174
176
|
let el;
|
package/dist/jsx/hooks/index.js
CHANGED
|
@@ -203,7 +203,10 @@ var use = (promise) => {
|
|
|
203
203
|
}
|
|
204
204
|
return cachedRes[0];
|
|
205
205
|
}
|
|
206
|
-
promise.then(
|
|
206
|
+
promise.then(
|
|
207
|
+
(res2) => resolvedPromiseValueMap.set(promise, [res2]),
|
|
208
|
+
(e) => resolvedPromiseValueMap.set(promise, [void 0, e])
|
|
209
|
+
);
|
|
207
210
|
const buildData = buildDataStack.at(-1);
|
|
208
211
|
if (!buildData) {
|
|
209
212
|
throw promise;
|
|
@@ -211,11 +214,14 @@ var use = (promise) => {
|
|
|
211
214
|
const [, node] = buildData;
|
|
212
215
|
const promiseArray = (_a = node[DOM_STASH][1])[STASH_USE] || (_a[STASH_USE] = []);
|
|
213
216
|
const hookIndex = node[DOM_STASH][0]++;
|
|
214
|
-
promise.then(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
promise.then(
|
|
218
|
+
(res2) => {
|
|
219
|
+
promiseArray[hookIndex] = [res2];
|
|
220
|
+
},
|
|
221
|
+
(e) => {
|
|
222
|
+
promiseArray[hookIndex] = [void 0, e];
|
|
223
|
+
}
|
|
224
|
+
);
|
|
219
225
|
const res = promiseArray[hookIndex];
|
|
220
226
|
if (res) {
|
|
221
227
|
if (res.length === 2) {
|
package/dist/jsx/streaming.js
CHANGED
|
@@ -59,7 +59,7 @@ var Suspense = async ({
|
|
|
59
59
|
content
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
-
let html = buffer ? "" : `<template>${content}</template><script>
|
|
62
|
+
let html = buffer ? "" : `<template data-hono-target="H:${index}">${content}</template><script>
|
|
63
63
|
((d,c,n) => {
|
|
64
64
|
c=d.currentScript.previousSibling
|
|
65
65
|
d=d.getElementById('H:${index}')
|
|
@@ -5,10 +5,13 @@ import { renderToReadableStream } from "../../jsx/streaming.js";
|
|
|
5
5
|
var RequestContext = createContext(null);
|
|
6
6
|
var createRenderer = (c, Layout, component, options) => (children, props) => {
|
|
7
7
|
const docType = typeof options?.docType === "string" ? options.docType : options?.docType === false ? "" : "<!DOCTYPE html>";
|
|
8
|
-
const currentLayout = component ?
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const currentLayout = component ? jsx(
|
|
9
|
+
component,
|
|
10
|
+
{
|
|
11
|
+
...{ Layout, ...props }
|
|
12
|
+
},
|
|
13
|
+
children
|
|
14
|
+
) : children;
|
|
12
15
|
const body = html`${raw(docType)}${jsx(
|
|
13
16
|
RequestContext.Provider,
|
|
14
17
|
{ value: c },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/middleware/jwt/index.ts
|
|
2
|
-
import { getCookie } from "../../helper.js";
|
|
2
|
+
import { getCookie } from "../../helper/cookie/index.js";
|
|
3
3
|
import { HTTPException } from "../../http-exception.js";
|
|
4
4
|
import { Jwt } from "../../utils/jwt/index.js";
|
|
5
5
|
import "../../context.js";
|
|
@@ -12,6 +12,10 @@ var validator = (target, validationFunc) => {
|
|
|
12
12
|
const message = `Invalid HTTP header: Content-Type=${contentType}`;
|
|
13
13
|
throw new HTTPException(400, { message });
|
|
14
14
|
}
|
|
15
|
+
if (c.req.bodyCache.json) {
|
|
16
|
+
value = await c.req.bodyCache.json;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
15
19
|
try {
|
|
16
20
|
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
|
|
17
21
|
value = await new Response(arrayBuffer).json();
|
|
@@ -23,6 +27,10 @@ var validator = (target, validationFunc) => {
|
|
|
23
27
|
}
|
|
24
28
|
break;
|
|
25
29
|
case "form": {
|
|
30
|
+
if (c.req.bodyCache.formData) {
|
|
31
|
+
value = c.req.bodyCache.formData;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
26
34
|
try {
|
|
27
35
|
const contentType2 = c.req.header("Content-Type");
|
|
28
36
|
if (contentType2) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Ultrafast web framework for the Edges",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -499,7 +499,7 @@
|
|
|
499
499
|
"cloudflare",
|
|
500
500
|
"workers",
|
|
501
501
|
"fastly",
|
|
502
|
-
"compute
|
|
502
|
+
"compute",
|
|
503
503
|
"deno",
|
|
504
504
|
"bun",
|
|
505
505
|
"lambda",
|
package/dist/types/helper.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './helper/accepts';
|
|
2
|
-
export * from './helper/adapter';
|
|
3
|
-
export * from './helper/cookie';
|
|
4
|
-
export * from './helper/css';
|
|
5
|
-
export * from './helper/factory';
|
|
6
|
-
export * from './helper/html';
|
|
7
|
-
export * from './helper/streaming';
|
|
8
|
-
export * from './helper/testing';
|
|
9
|
-
export * from './helper/dev';
|
|
10
|
-
export * from './adapter/deno/ssg';
|