hono 2.3.1 → 2.4.0
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/compose.js +82 -66
- package/dist/cjs/context.js +159 -144
- package/dist/cjs/hono.js +173 -150
- package/dist/cjs/index.js +31 -11
- package/dist/cjs/middleware/basic-auth/index.js +70 -39
- package/dist/cjs/middleware/bearer-auth/index.js +69 -51
- package/dist/cjs/middleware/cache/index.js +49 -28
- package/dist/cjs/middleware/compress/index.js +39 -16
- package/dist/cjs/middleware/cors/index.js +89 -71
- package/dist/cjs/middleware/etag/index.js +46 -24
- package/dist/cjs/middleware/html/index.js +50 -30
- package/dist/cjs/middleware/jsx/index.js +178 -166
- package/dist/cjs/middleware/jsx/jsx-dev-runtime.js +30 -7
- package/dist/cjs/middleware/jsx/jsx-runtime.js +30 -6
- package/dist/cjs/middleware/jwt/index.js +74 -54
- package/dist/cjs/middleware/logger/index.js +59 -38
- package/dist/cjs/middleware/powered-by/index.js +30 -7
- package/dist/cjs/middleware/pretty-json/index.js +31 -8
- package/dist/cjs/middleware/serve-static/bun.js +56 -38
- package/dist/cjs/middleware/serve-static/index.js +27 -4
- package/dist/cjs/middleware/serve-static/module.js +42 -0
- package/dist/cjs/middleware/serve-static/serve-static.js +58 -39
- package/dist/cjs/middleware/validator/index.js +27 -4
- package/dist/cjs/middleware/validator/middleware.js +125 -91
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/request.js +129 -116
- package/dist/cjs/router/reg-exp-router/index.js +27 -4
- package/dist/cjs/router/reg-exp-router/node.js +108 -97
- package/dist/cjs/router/reg-exp-router/router.js +158 -141
- package/dist/cjs/router/reg-exp-router/trie.js +55 -39
- package/dist/cjs/router/smart-router/index.js +27 -4
- package/dist/cjs/router/smart-router/router.js +70 -49
- package/dist/cjs/router/static-router/index.js +27 -4
- package/dist/cjs/router/static-router/router.js +78 -64
- package/dist/cjs/router/trie-router/index.js +27 -4
- package/dist/cjs/router/trie-router/node.js +167 -159
- package/dist/cjs/router/trie-router/router.js +43 -20
- package/dist/cjs/router.js +35 -6
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/utils/body.js +36 -15
- package/dist/cjs/utils/buffer.js +56 -31
- package/dist/cjs/utils/cloudflare.js +53 -34
- package/dist/cjs/utils/cookie.js +59 -35
- package/dist/cjs/utils/crypto.js +69 -43
- package/dist/cjs/utils/encode.js +92 -65
- package/dist/cjs/utils/filepath.js +39 -22
- package/dist/cjs/utils/html.js +54 -33
- package/dist/cjs/utils/http-status.js +68 -45
- package/dist/cjs/utils/json.js +91 -76
- package/dist/cjs/utils/jwt/index.js +32 -25
- package/dist/cjs/utils/jwt/jwt.js +124 -93
- package/dist/cjs/utils/jwt/types.js +65 -38
- package/dist/cjs/utils/mime.js +110 -87
- package/dist/cjs/utils/object.js +53 -35
- package/dist/cjs/utils/types.js +16 -0
- package/dist/cjs/utils/url.js +89 -78
- package/dist/cjs/validator/rule.js +80 -0
- package/dist/cjs/validator/sanitizer.js +30 -0
- package/dist/cjs/validator/schema.js +16 -0
- package/dist/cjs/validator/validator.js +439 -0
- package/dist/compose.d.ts +4 -3
- package/dist/compose.js +61 -64
- package/dist/context.d.ts +10 -9
- package/dist/context.js +139 -143
- package/dist/hono.d.ts +27 -42
- package/dist/hono.js +153 -149
- package/dist/index.d.ts +4 -1
- package/dist/index.js +9 -9
- package/dist/middleware/basic-auth/index.d.ts +1 -1
- package/dist/middleware/basic-auth/index.js +52 -40
- package/dist/middleware/bearer-auth/index.d.ts +1 -1
- package/dist/middleware/bearer-auth/index.js +48 -49
- package/dist/middleware/cache/index.d.ts +1 -1
- package/dist/middleware/cache/index.js +28 -26
- package/dist/middleware/compress/index.d.ts +1 -1
- package/dist/middleware/compress/index.js +18 -14
- package/dist/middleware/cors/index.d.ts +1 -1
- package/dist/middleware/cors/index.js +68 -69
- package/dist/middleware/etag/index.d.ts +1 -1
- package/dist/middleware/etag/index.js +25 -22
- package/dist/middleware/html/index.js +29 -28
- package/dist/middleware/jsx/index.js +164 -172
- package/dist/middleware/jsx/jsx-dev-runtime.js +9 -5
- package/dist/middleware/jsx/jsx-runtime.js +7 -2
- package/dist/middleware/jwt/index.d.ts +1 -1
- package/dist/middleware/jwt/index.js +53 -52
- package/dist/middleware/logger/index.d.ts +1 -1
- package/dist/middleware/logger/index.js +35 -39
- package/dist/middleware/powered-by/index.d.ts +1 -1
- package/dist/middleware/powered-by/index.js +9 -5
- package/dist/middleware/pretty-json/index.d.ts +1 -1
- package/dist/middleware/pretty-json/index.js +10 -6
- package/dist/middleware/serve-static/bun.d.ts +1 -1
- package/dist/middleware/serve-static/bun.js +35 -36
- package/dist/middleware/serve-static/index.js +5 -1
- package/dist/middleware/serve-static/module.d.ts +3 -0
- package/dist/middleware/serve-static/module.js +13 -0
- package/dist/middleware/serve-static/serve-static.d.ts +2 -3
- package/dist/middleware/serve-static/serve-static.js +36 -36
- package/dist/middleware/validator/index.js +5 -2
- package/dist/middleware/validator/middleware.d.ts +9 -15
- package/dist/middleware/validator/middleware.js +104 -89
- package/dist/request.d.ts +2 -2
- package/dist/request.js +108 -114
- package/dist/router/reg-exp-router/index.js +5 -1
- package/dist/router/reg-exp-router/node.js +87 -96
- package/dist/router/reg-exp-router/router.js +140 -142
- package/dist/router/reg-exp-router/trie.js +35 -38
- package/dist/router/smart-router/index.js +5 -1
- package/dist/router/smart-router/router.js +50 -48
- package/dist/router/static-router/index.js +5 -1
- package/dist/router/static-router/router.js +58 -63
- package/dist/router/trie-router/index.js +5 -1
- package/dist/router/trie-router/node.js +147 -158
- package/dist/router/trie-router/router.js +23 -19
- package/dist/router.js +12 -5
- package/dist/types.d.ts +22 -0
- package/dist/types.js +0 -0
- package/dist/utils/body.js +15 -13
- package/dist/utils/buffer.js +35 -29
- package/dist/utils/cloudflare.js +32 -32
- package/dist/utils/cookie.js +38 -33
- package/dist/utils/crypto.js +48 -41
- package/dist/utils/encode.js +70 -62
- package/dist/utils/filepath.js +18 -20
- package/dist/utils/html.js +34 -32
- package/dist/utils/http-status.js +48 -44
- package/dist/utils/json.js +71 -75
- package/dist/utils/jwt/index.js +5 -1
- package/dist/utils/jwt/jwt.js +95 -90
- package/dist/utils/jwt/types.js +47 -41
- package/dist/utils/mime.js +90 -86
- package/dist/utils/object.js +31 -32
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/types.js +0 -0
- package/dist/utils/url.js +69 -77
- package/dist/{middleware/validator → validator}/rule.d.ts +0 -0
- package/dist/validator/rule.js +57 -0
- package/dist/{middleware/validator → validator}/sanitizer.d.ts +0 -0
- package/dist/validator/sanitizer.js +7 -0
- package/dist/validator/schema.d.ts +7 -0
- package/dist/validator/schema.js +0 -0
- package/dist/{middleware/validator → validator}/validator.d.ts +10 -7
- package/dist/validator/validator.js +406 -0
- package/package.json +14 -8
- package/dist/cjs/middleware/validator/rule.js +0 -66
- package/dist/cjs/middleware/validator/sanitizer.js +0 -6
- package/dist/cjs/middleware/validator/validator.js +0 -417
- package/dist/middleware/serve-static/module.d.mts +0 -3
- package/dist/middleware/serve-static/module.mjs +0 -13
- package/dist/middleware/validator/rule.js +0 -63
- package/dist/middleware/validator/sanitizer.js +0 -3
- package/dist/middleware/validator/validator.js +0 -403
package/dist/cjs/compose.js
CHANGED
|
@@ -1,70 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var compose_exports = {};
|
|
20
|
+
__export(compose_exports, {
|
|
21
|
+
compose: () => compose
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(compose_exports);
|
|
24
|
+
var import_context = require("./context");
|
|
6
25
|
const compose = (middleware, onNotFound, onError) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!(res instanceof Promise)) {
|
|
45
|
-
if (res && (context.finalized === false || isError)) {
|
|
46
|
-
context.res = res;
|
|
47
|
-
}
|
|
48
|
-
return context;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return res
|
|
52
|
-
.then((res) => {
|
|
53
|
-
if (res && context.finalized === false) {
|
|
54
|
-
context.res = res;
|
|
55
|
-
}
|
|
56
|
-
return context;
|
|
57
|
-
})
|
|
58
|
-
.catch((err) => {
|
|
59
|
-
if (err instanceof Error && context instanceof context_1.HonoContext && onError) {
|
|
60
|
-
context.error = err;
|
|
61
|
-
context.res = onError(err, context);
|
|
62
|
-
return context;
|
|
63
|
-
}
|
|
64
|
-
throw err;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
26
|
+
const middlewareLength = middleware.length;
|
|
27
|
+
return (context, next) => {
|
|
28
|
+
let index = -1;
|
|
29
|
+
return dispatch(0);
|
|
30
|
+
function dispatch(i) {
|
|
31
|
+
if (i <= index) {
|
|
32
|
+
throw new Error("next() called multiple times");
|
|
33
|
+
}
|
|
34
|
+
let handler = middleware[i];
|
|
35
|
+
index = i;
|
|
36
|
+
if (i === middlewareLength && next)
|
|
37
|
+
handler = next;
|
|
38
|
+
let res;
|
|
39
|
+
let isError = false;
|
|
40
|
+
if (!handler) {
|
|
41
|
+
if (context instanceof import_context.HonoContext && context.finalized === false && onNotFound) {
|
|
42
|
+
res = onNotFound(context);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
try {
|
|
46
|
+
res = handler(context, () => {
|
|
47
|
+
const dispatchRes = dispatch(i + 1);
|
|
48
|
+
return dispatchRes instanceof Promise ? dispatchRes : Promise.resolve(dispatchRes);
|
|
49
|
+
});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
if (err instanceof Error && context instanceof import_context.HonoContext && onError) {
|
|
52
|
+
context.error = err;
|
|
53
|
+
res = onError(err, context);
|
|
54
|
+
isError = true;
|
|
55
|
+
} else {
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!(res instanceof Promise)) {
|
|
61
|
+
if (res && (context.finalized === false || isError)) {
|
|
62
|
+
context.res = res;
|
|
67
63
|
}
|
|
68
|
-
|
|
64
|
+
return context;
|
|
65
|
+
} else {
|
|
66
|
+
return res.then((res2) => {
|
|
67
|
+
if (res2 && context.finalized === false) {
|
|
68
|
+
context.res = res2;
|
|
69
|
+
}
|
|
70
|
+
return context;
|
|
71
|
+
}).catch((err) => {
|
|
72
|
+
if (err instanceof Error && context instanceof import_context.HonoContext && onError) {
|
|
73
|
+
context.error = err;
|
|
74
|
+
context.res = onError(err, context);
|
|
75
|
+
return context;
|
|
76
|
+
}
|
|
77
|
+
throw err;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
69
82
|
};
|
|
70
|
-
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
compose
|
|
86
|
+
});
|
package/dist/cjs/context.js
CHANGED
|
@@ -1,148 +1,163 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var context_exports = {};
|
|
20
|
+
__export(context_exports, {
|
|
21
|
+
HonoContext: () => HonoContext
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(context_exports);
|
|
24
|
+
var import_cookie = require("./utils/cookie");
|
|
5
25
|
class HonoContext {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
for (const
|
|
98
|
-
|
|
99
|
-
if (typeof value === 'string') {
|
|
100
|
-
finalizedHeaders.push([key, value]);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
for (const v of value) {
|
|
104
|
-
finalizedHeaders.push([key, v]);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
delete headersKv[key];
|
|
26
|
+
constructor(req, env = {}, executionCtx = void 0, notFoundHandler = () => new Response()) {
|
|
27
|
+
this.error = void 0;
|
|
28
|
+
this._status = 200;
|
|
29
|
+
this._pretty = false;
|
|
30
|
+
this._prettySpace = 2;
|
|
31
|
+
this._executionCtx = executionCtx;
|
|
32
|
+
this.req = req;
|
|
33
|
+
this.env = env || {};
|
|
34
|
+
this.notFoundHandler = notFoundHandler;
|
|
35
|
+
this.finalized = false;
|
|
36
|
+
}
|
|
37
|
+
get event() {
|
|
38
|
+
if (this._executionCtx instanceof FetchEvent) {
|
|
39
|
+
return this._executionCtx;
|
|
40
|
+
} else {
|
|
41
|
+
throw Error("This context has no FetchEvent");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
get executionCtx() {
|
|
45
|
+
if (this._executionCtx) {
|
|
46
|
+
return this._executionCtx;
|
|
47
|
+
} else {
|
|
48
|
+
throw Error("This context has no ExecutionContext");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
get res() {
|
|
52
|
+
return this._res || (this._res = new Response("404 Not Found", { status: 404 }));
|
|
53
|
+
}
|
|
54
|
+
set res(_res) {
|
|
55
|
+
this._res = _res;
|
|
56
|
+
this.finalized = true;
|
|
57
|
+
}
|
|
58
|
+
header(name, value, options) {
|
|
59
|
+
this._headers || (this._headers = {});
|
|
60
|
+
const key = name.toLowerCase();
|
|
61
|
+
let shouldAppend = false;
|
|
62
|
+
if (options && options.append) {
|
|
63
|
+
const vAlreadySet = this._headers[key];
|
|
64
|
+
if (vAlreadySet && vAlreadySet.length) {
|
|
65
|
+
shouldAppend = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (shouldAppend) {
|
|
69
|
+
this._headers[key].push(value);
|
|
70
|
+
} else {
|
|
71
|
+
this._headers[key] = [value];
|
|
72
|
+
}
|
|
73
|
+
if (this.finalized) {
|
|
74
|
+
if (shouldAppend) {
|
|
75
|
+
this.res.headers.append(name, value);
|
|
76
|
+
} else {
|
|
77
|
+
this.res.headers.set(name, value);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
status(status) {
|
|
82
|
+
this._status = status;
|
|
83
|
+
}
|
|
84
|
+
set(key, value) {
|
|
85
|
+
this._map || (this._map = {});
|
|
86
|
+
this._map[key] = value;
|
|
87
|
+
}
|
|
88
|
+
get(key) {
|
|
89
|
+
if (!this._map) {
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
return this._map[key];
|
|
93
|
+
}
|
|
94
|
+
pretty(prettyJSON, space = 2) {
|
|
95
|
+
this._pretty = prettyJSON;
|
|
96
|
+
this._prettySpace = space;
|
|
97
|
+
}
|
|
98
|
+
newResponse(data, status, headers = {}) {
|
|
99
|
+
return new Response(data, {
|
|
100
|
+
status: status || this._status || 200,
|
|
101
|
+
headers: this._finalizeHeaders(headers)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
_finalizeHeaders(incomingHeaders) {
|
|
105
|
+
const finalizedHeaders = [];
|
|
106
|
+
const headersKv = this._headers || {};
|
|
107
|
+
if (this._res) {
|
|
108
|
+
this._res.headers.forEach((v, k) => {
|
|
109
|
+
headersKv[k] = [v];
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
for (const key of Object.keys(incomingHeaders)) {
|
|
113
|
+
const value = incomingHeaders[key];
|
|
114
|
+
if (typeof value === "string") {
|
|
115
|
+
finalizedHeaders.push([key, value]);
|
|
116
|
+
} else {
|
|
117
|
+
for (const v of value) {
|
|
118
|
+
finalizedHeaders.push([key, v]);
|
|
108
119
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
120
|
+
}
|
|
121
|
+
delete headersKv[key];
|
|
122
|
+
}
|
|
123
|
+
for (const key of Object.keys(headersKv)) {
|
|
124
|
+
for (const value of headersKv[key]) {
|
|
125
|
+
const kv = [key, value];
|
|
126
|
+
finalizedHeaders.push(kv);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return finalizedHeaders;
|
|
130
|
+
}
|
|
131
|
+
body(data, status = this._status, headers = {}) {
|
|
132
|
+
return this.newResponse(data, status, headers);
|
|
133
|
+
}
|
|
134
|
+
text(text, status = this._status, headers = {}) {
|
|
135
|
+
headers["content-type"] = "text/plain; charset=UTF-8";
|
|
136
|
+
return this.body(text, status, headers);
|
|
137
|
+
}
|
|
138
|
+
json(object, status = this._status, headers = {}) {
|
|
139
|
+
const body = this._pretty ? JSON.stringify(object, null, this._prettySpace) : JSON.stringify(object);
|
|
140
|
+
headers["content-type"] = "application/json; charset=UTF-8";
|
|
141
|
+
return this.body(body, status, headers);
|
|
142
|
+
}
|
|
143
|
+
html(html, status = this._status, headers = {}) {
|
|
144
|
+
headers["content-type"] = "text/html; charset=UTF-8";
|
|
145
|
+
return this.body(html, status, headers);
|
|
146
|
+
}
|
|
147
|
+
redirect(location, status = 302) {
|
|
148
|
+
return this.newResponse(null, status, {
|
|
149
|
+
Location: location
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
cookie(name, value, opt) {
|
|
153
|
+
const cookie = (0, import_cookie.serialize)(name, value, opt);
|
|
154
|
+
this.header("set-cookie", cookie, { append: true });
|
|
155
|
+
}
|
|
156
|
+
notFound() {
|
|
157
|
+
return this.notFoundHandler(this);
|
|
158
|
+
}
|
|
147
159
|
}
|
|
148
|
-
|
|
160
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
161
|
+
0 && (module.exports = {
|
|
162
|
+
HonoContext
|
|
163
|
+
});
|