@zuplo/cli 6.74.8 → 6.74.12
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/node_modules/@hono/node-server/README.md +47 -1
- package/node_modules/@hono/node-server/dist/early-hints.cjs +35 -0
- package/node_modules/@hono/node-server/dist/early-hints.d.cts +16 -0
- package/node_modules/@hono/node-server/dist/early-hints.d.mts +16 -0
- package/node_modules/@hono/node-server/dist/early-hints.mjs +33 -0
- package/node_modules/@hono/node-server/dist/index.cjs +4 -1
- package/node_modules/@hono/node-server/dist/index.mjs +4 -1
- package/node_modules/@hono/node-server/package.json +14 -1
- package/node_modules/@zuplo/core/customer.cli.minified.js +245 -245
- package/node_modules/@zuplo/core/index.minified.js +234 -234
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/out/esm/index.js +12 -12
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +2 -2
- package/node_modules/@zuplo/otel/out/esm/chunk-AHNBOCFU.js +26 -0
- package/node_modules/@zuplo/otel/out/esm/chunk-AHNBOCFU.js.map +1 -0
- package/node_modules/@zuplo/otel/out/esm/index.js +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-AVDTZRWM.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-AVDTZRWM.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-3E6DNHTO.js → chunk-VVVYHDCV.js} +94 -92
- package/node_modules/@zuplo/runtime/out/esm/chunk-VVVYHDCV.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +231 -0
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/hono/dist/cjs/context.js +28 -13
- package/node_modules/hono/dist/cjs/hono-base.js +3 -2
- package/node_modules/hono/dist/cjs/jsx/base.js +26 -14
- package/node_modules/hono/dist/cjs/jsx/hooks/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +90 -0
- package/node_modules/hono/dist/cjs/request.js +6 -8
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/cjs/router.js +1 -1
- package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
- package/node_modules/hono/dist/cjs/utils/url.js +7 -7
- package/node_modules/hono/dist/context.js +28 -13
- package/node_modules/hono/dist/hono-base.js +3 -2
- package/node_modules/hono/dist/jsx/base.js +26 -14
- package/node_modules/hono/dist/jsx/hooks/index.js +2 -2
- package/node_modules/hono/dist/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/middleware/cors/index.js +1 -1
- package/node_modules/hono/dist/middleware/etag/index.js +1 -1
- package/node_modules/hono/dist/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/middleware/method-not-allowed/index.js +68 -0
- package/node_modules/hono/dist/request.js +7 -9
- package/node_modules/hono/dist/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/router.js +1 -1
- package/node_modules/hono/dist/types/client/types.d.ts +1 -1
- package/node_modules/hono/dist/types/hono-base.d.ts +4 -3
- package/node_modules/hono/dist/types/jsx/base.d.ts +4 -2
- package/node_modules/hono/dist/types/jsx/dom/index.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/server.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +8 -6
- package/node_modules/hono/dist/types/jsx/index.d.ts +5 -5
- package/node_modules/hono/dist/types/middleware/cache/index.d.ts +6 -4
- package/node_modules/hono/dist/types/middleware/cors/index.d.ts +1 -1
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +2 -2
- package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +49 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +1 -1
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +2 -1
- package/node_modules/hono/dist/types/router.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/headers.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
- package/node_modules/hono/dist/utils/cookie.js +2 -2
- package/node_modules/hono/dist/utils/url.js +5 -6
- package/node_modules/hono/package.json +9 -1
- package/package.json +6 -6
- package/node_modules/@zuplo/otel/out/esm/chunk-6UX7NFNJ.js +0 -26
- package/node_modules/@zuplo/otel/out/esm/chunk-6UX7NFNJ.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-3E6DNHTO.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-ZB7PAWBM.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-ZB7PAWBM.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-3E6DNHTO.js.LEGAL.txt → chunk-VVVYHDCV.js.LEGAL.txt} +0 -0
|
@@ -12,7 +12,7 @@ function compareKey(a, b) {
|
|
|
12
12
|
return 1;
|
|
13
13
|
}
|
|
14
14
|
if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {
|
|
15
|
-
return 1;
|
|
15
|
+
return b === TAIL_WILDCARD_REG_EXP_STR ? -1 : 1;
|
|
16
16
|
} else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {
|
|
17
17
|
return -1;
|
|
18
18
|
}
|
|
@@ -24,76 +24,75 @@ function compareKey(a, b) {
|
|
|
24
24
|
return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
|
|
25
25
|
}
|
|
26
26
|
var Node = class _Node {
|
|
27
|
+
// handler index of a dynamic path, or -1 for a static path terminal
|
|
27
28
|
#index;
|
|
28
29
|
#varIndex;
|
|
29
30
|
#children = /* @__PURE__ */ Object.create(null);
|
|
30
|
-
insert(tokens, index, paramMap, context,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
52
|
-
if (/\((?!\?:)/.test(regexpStr)) {
|
|
53
|
-
throw PATH_ERROR;
|
|
31
|
+
insert(tokens, index, paramMap, context, isStatic) {
|
|
32
|
+
let node = this;
|
|
33
|
+
for (let i = 0, len = tokens.length; i < len; i++) {
|
|
34
|
+
const token = tokens[i];
|
|
35
|
+
const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? ["", "", ONLY_WILDCARD_REG_EXP_STR] : ["", "", LABEL_REG_EXP_STR] : null : token === "/*" ? ["", "", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
36
|
+
let nextNode;
|
|
37
|
+
if (pattern) {
|
|
38
|
+
const name = pattern[1];
|
|
39
|
+
let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
|
|
40
|
+
if (name && pattern[2]) {
|
|
41
|
+
if (regexpStr === ".*") {
|
|
42
|
+
throw PATH_ERROR;
|
|
43
|
+
}
|
|
44
|
+
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
45
|
+
if (/\((?!\?:)/.test(regexpStr)) {
|
|
46
|
+
throw PATH_ERROR;
|
|
47
|
+
}
|
|
48
|
+
if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) {
|
|
49
|
+
throw PATH_ERROR;
|
|
50
|
+
}
|
|
54
51
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
nextNode = node.#children[regexpStr];
|
|
53
|
+
if (!nextNode) {
|
|
54
|
+
if (regexpStr !== ONLY_WILDCARD_REG_EXP_STR && regexpStr !== TAIL_WILDCARD_REG_EXP_STR) {
|
|
55
|
+
for (const k in node.#children) {
|
|
56
|
+
if (
|
|
57
|
+
// a single-char pattern coexists with single-char literals as a literal does
|
|
58
|
+
(regexpStr.length > 1 || k.length > 1) && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
|
|
59
|
+
) {
|
|
60
|
+
throw PATH_ERROR;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
nextNode = node.#children[regexpStr] = new _Node();
|
|
62
65
|
}
|
|
63
|
-
if (pathErrorCheckOnly) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
node = this.#children[regexpStr] = new _Node();
|
|
67
66
|
if (name !== "") {
|
|
68
|
-
|
|
67
|
+
nextNode.#varIndex ??= context.varIndex++;
|
|
68
|
+
paramMap.push([name, nextNode.#varIndex]);
|
|
69
69
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)) {
|
|
80
|
-
throw PATH_ERROR;
|
|
70
|
+
} else {
|
|
71
|
+
nextNode = node.#children[token];
|
|
72
|
+
if (!nextNode) {
|
|
73
|
+
for (const k in node.#children) {
|
|
74
|
+
if (k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR) {
|
|
75
|
+
throw PATH_ERROR;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
nextNode = node.#children[token] = new _Node();
|
|
81
79
|
}
|
|
82
|
-
if (pathErrorCheckOnly) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
node = this.#children[token] = new _Node();
|
|
86
80
|
}
|
|
81
|
+
node = nextNode;
|
|
82
|
+
}
|
|
83
|
+
if (node.#index !== void 0) {
|
|
84
|
+
throw PATH_ERROR;
|
|
87
85
|
}
|
|
88
|
-
node
|
|
86
|
+
node.#index = isStatic ? -1 : index;
|
|
89
87
|
}
|
|
90
88
|
buildRegExpStr() {
|
|
91
89
|
const childKeys = Object.keys(this.#children).sort(compareKey);
|
|
92
90
|
const strList = childKeys.map((k) => {
|
|
93
91
|
const c = this.#children[k];
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
const childStr = c.buildRegExpStr();
|
|
93
|
+
return childStr === "" ? "" : (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + childStr;
|
|
94
|
+
}).filter(Boolean);
|
|
95
|
+
if (typeof this.#index === "number" && this.#index !== -1) {
|
|
97
96
|
strList.unshift(`#${this.#index}`);
|
|
98
97
|
}
|
|
99
98
|
if (strList.length === 0) {
|
|
@@ -8,7 +8,6 @@ import { checkOptionalParameter } from "../../utils/url.js";
|
|
|
8
8
|
import { match, emptyParam } from "./matcher.js";
|
|
9
9
|
import { PATH_ERROR } from "./node.js";
|
|
10
10
|
import { Trie } from "./trie.js";
|
|
11
|
-
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
12
11
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
13
12
|
function buildWildcardRegExp(path) {
|
|
14
13
|
return wildcardRegExpCache[path] ??= new RegExp(
|
|
@@ -21,63 +20,6 @@ function buildWildcardRegExp(path) {
|
|
|
21
20
|
function clearWildcardRegExpCache() {
|
|
22
21
|
wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
23
22
|
}
|
|
24
|
-
function buildMatcherFromPreprocessedRoutes(routes) {
|
|
25
|
-
const trie = new Trie();
|
|
26
|
-
const handlerData = [];
|
|
27
|
-
if (routes.length === 0) {
|
|
28
|
-
return nullMatcher;
|
|
29
|
-
}
|
|
30
|
-
const routesWithStaticPathFlag = routes.map(
|
|
31
|
-
(route) => [!/\*|\/:/.test(route[0]), ...route]
|
|
32
|
-
).sort(
|
|
33
|
-
([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length
|
|
34
|
-
);
|
|
35
|
-
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
36
|
-
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
|
|
37
|
-
const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
|
|
38
|
-
if (pathErrorCheckOnly) {
|
|
39
|
-
staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
40
|
-
} else {
|
|
41
|
-
j++;
|
|
42
|
-
}
|
|
43
|
-
let paramAssoc;
|
|
44
|
-
try {
|
|
45
|
-
paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
|
|
46
|
-
} catch (e) {
|
|
47
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
|
|
48
|
-
}
|
|
49
|
-
if (pathErrorCheckOnly) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
handlerData[j] = handlers.map(([h, paramCount]) => {
|
|
53
|
-
const paramIndexMap = /* @__PURE__ */ Object.create(null);
|
|
54
|
-
paramCount -= 1;
|
|
55
|
-
for (; paramCount >= 0; paramCount--) {
|
|
56
|
-
const [key, value] = paramAssoc[paramCount];
|
|
57
|
-
paramIndexMap[key] = value;
|
|
58
|
-
}
|
|
59
|
-
return [h, paramIndexMap];
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
63
|
-
for (let i = 0, len = handlerData.length; i < len; i++) {
|
|
64
|
-
for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
|
|
65
|
-
const map = handlerData[i][j]?.[1];
|
|
66
|
-
if (!map) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
const keys = Object.keys(map);
|
|
70
|
-
for (let k = 0, len3 = keys.length; k < len3; k++) {
|
|
71
|
-
map[keys[k]] = paramReplacementMap[map[keys[k]]];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const handlerMap = [];
|
|
76
|
-
for (const i in indexReplacementMap) {
|
|
77
|
-
handlerMap[i] = handlerData[indexReplacementMap[i]];
|
|
78
|
-
}
|
|
79
|
-
return [regexp, handlerMap, staticMap];
|
|
80
|
-
}
|
|
81
23
|
function findMiddleware(middleware, path) {
|
|
82
24
|
if (!middleware) {
|
|
83
25
|
return void 0;
|
|
@@ -93,9 +35,18 @@ var RegExpRouter = class {
|
|
|
93
35
|
name = "RegExpRouter";
|
|
94
36
|
#middleware;
|
|
95
37
|
#routes;
|
|
38
|
+
#tries;
|
|
96
39
|
constructor() {
|
|
97
40
|
this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
98
41
|
this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
42
|
+
this.#tries = { [METHOD_NAME_ALL]: new Trie() };
|
|
43
|
+
}
|
|
44
|
+
#insertPath(method, path) {
|
|
45
|
+
try {
|
|
46
|
+
this.#tries[method].insert(path, !/\*|\/:/.test(path));
|
|
47
|
+
} catch (e) {
|
|
48
|
+
throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
|
|
49
|
+
}
|
|
99
50
|
}
|
|
100
51
|
add(method, path, handler) {
|
|
101
52
|
const middleware = this.#middleware;
|
|
@@ -104,11 +55,12 @@ var RegExpRouter = class {
|
|
|
104
55
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
105
56
|
}
|
|
106
57
|
if (!middleware[method]) {
|
|
107
|
-
;
|
|
58
|
+
this.#tries[method] = new Trie();
|
|
108
59
|
[middleware, routes].forEach((handlerMap) => {
|
|
109
60
|
handlerMap[method] = /* @__PURE__ */ Object.create(null);
|
|
110
61
|
Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {
|
|
111
62
|
handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
|
|
63
|
+
this.#insertPath(method, p);
|
|
112
64
|
});
|
|
113
65
|
});
|
|
114
66
|
}
|
|
@@ -118,13 +70,12 @@ var RegExpRouter = class {
|
|
|
118
70
|
const paramCount = (path.match(/\/:/g) || []).length;
|
|
119
71
|
if (/\*$/.test(path)) {
|
|
120
72
|
const re = buildWildcardRegExp(path);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
73
|
+
Object.keys(middleware).forEach((m) => {
|
|
74
|
+
if ((method === METHOD_NAME_ALL || method === m) && !middleware[m][path]) {
|
|
75
|
+
this.#insertPath(m, path);
|
|
76
|
+
middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
128
79
|
Object.keys(middleware).forEach((m) => {
|
|
129
80
|
if (method === METHOD_NAME_ALL || method === m) {
|
|
130
81
|
Object.keys(middleware[m]).forEach((p) => {
|
|
@@ -146,9 +97,12 @@ var RegExpRouter = class {
|
|
|
146
97
|
const path2 = paths[i];
|
|
147
98
|
Object.keys(routes).forEach((m) => {
|
|
148
99
|
if (method === METHOD_NAME_ALL || method === m) {
|
|
149
|
-
routes[m][path2]
|
|
150
|
-
|
|
151
|
-
|
|
100
|
+
if (!routes[m][path2]) {
|
|
101
|
+
this.#insertPath(m, path2);
|
|
102
|
+
routes[m][path2] = [
|
|
103
|
+
...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
|
|
104
|
+
];
|
|
105
|
+
}
|
|
152
106
|
routes[m][path2].push([handler, paramCount - len + i + 1]);
|
|
153
107
|
}
|
|
154
108
|
});
|
|
@@ -160,29 +114,54 @@ var RegExpRouter = class {
|
|
|
160
114
|
Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach((method) => {
|
|
161
115
|
matchers[method] ||= this.#buildMatcher(method);
|
|
162
116
|
});
|
|
163
|
-
this.#middleware = this.#routes = void 0;
|
|
117
|
+
this.#middleware = this.#routes = this.#tries = void 0;
|
|
164
118
|
clearWildcardRegExpCache();
|
|
165
119
|
return matchers;
|
|
166
120
|
}
|
|
167
121
|
#buildMatcher(method) {
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
122
|
+
const middleware = this.#middleware[method];
|
|
123
|
+
const routes = this.#routes[method];
|
|
124
|
+
const trie = this.#tries[method];
|
|
125
|
+
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
126
|
+
const handlerData = [];
|
|
127
|
+
[middleware, routes].forEach((r) => {
|
|
128
|
+
for (const path in r) {
|
|
129
|
+
const handlers = r[path];
|
|
130
|
+
const pathData = trie.paths[path];
|
|
131
|
+
if (!pathData) {
|
|
132
|
+
staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const paramAssoc = pathData[1];
|
|
136
|
+
handlerData[pathData[0]] = handlers.map(([h, paramCount]) => {
|
|
137
|
+
const paramIndexMap = /* @__PURE__ */ Object.create(null);
|
|
138
|
+
paramCount -= 1;
|
|
139
|
+
for (; paramCount >= 0; paramCount--) {
|
|
140
|
+
const [key, value] = paramAssoc[paramCount];
|
|
141
|
+
paramIndexMap[key] = value;
|
|
142
|
+
}
|
|
143
|
+
return [h, paramIndexMap];
|
|
144
|
+
});
|
|
179
145
|
}
|
|
180
146
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
147
|
+
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
148
|
+
for (let i = 0, len = handlerData.length; i < len; i++) {
|
|
149
|
+
for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
|
|
150
|
+
const map = handlerData[i][j]?.[1];
|
|
151
|
+
if (!map) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const keys = Object.keys(map);
|
|
155
|
+
for (let k = 0, len3 = keys.length; k < len3; k++) {
|
|
156
|
+
map[keys[k]] = paramReplacementMap[map[keys[k]]];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const handlerMap = [];
|
|
161
|
+
for (const i in indexReplacementMap) {
|
|
162
|
+
handlerMap[i] = handlerData[indexReplacementMap[i]];
|
|
185
163
|
}
|
|
164
|
+
return [regexp, handlerMap, staticMap];
|
|
186
165
|
}
|
|
187
166
|
};
|
|
188
167
|
export {
|
|
@@ -3,12 +3,20 @@ import { Node } from "./node.js";
|
|
|
3
3
|
var Trie = class {
|
|
4
4
|
#context = { varIndex: 0 };
|
|
5
5
|
#root = new Node();
|
|
6
|
-
|
|
6
|
+
#index = 0;
|
|
7
|
+
// dynamic path -> [handler index, param assoc]; static paths are not registered
|
|
8
|
+
paths = /* @__PURE__ */ Object.create(null);
|
|
9
|
+
insert(path, isStatic) {
|
|
10
|
+
if (isStatic) {
|
|
11
|
+
this.#root.insert(path.split(""), 0, [], this.#context, true);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
7
14
|
const paramAssoc = [];
|
|
8
15
|
const groups = [];
|
|
16
|
+
let markedPath = path;
|
|
9
17
|
for (let i = 0; ; ) {
|
|
10
18
|
let replaced = false;
|
|
11
|
-
|
|
19
|
+
markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
|
|
12
20
|
const mark = `@\\${i}`;
|
|
13
21
|
groups[i] = [mark, m];
|
|
14
22
|
i++;
|
|
@@ -19,7 +27,7 @@ var Trie = class {
|
|
|
19
27
|
break;
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
|
-
const tokens =
|
|
30
|
+
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
23
31
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
24
32
|
const [mark] = groups[i];
|
|
25
33
|
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
@@ -29,8 +37,8 @@ var Trie = class {
|
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
|
-
this.#root.insert(tokens, index, paramAssoc, this.#context,
|
|
33
|
-
|
|
40
|
+
this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
|
|
41
|
+
this.paths[path] = [this.#index++, paramAssoc];
|
|
34
42
|
}
|
|
35
43
|
buildRegExp() {
|
|
36
44
|
let regexp = this.#root.buildRegExpStr();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/router.ts
|
|
2
2
|
var METHOD_NAME_ALL = "ALL";
|
|
3
3
|
var METHOD_NAME_ALL_LOWERCASE = "all";
|
|
4
|
-
var METHODS = ["get", "post", "put", "delete", "options", "patch"];
|
|
4
|
+
var METHODS = ["get", "post", "put", "delete", "options", "patch", "query"];
|
|
5
5
|
var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
6
6
|
var UnsupportedPathError = class extends Error {
|
|
7
7
|
};
|
|
@@ -10,7 +10,7 @@ import type { HasRequiredKeys } from '../utils/types';
|
|
|
10
10
|
type MethodNameAll = `$${typeof METHOD_NAME_ALL_LOWERCASE}`;
|
|
11
11
|
/**
|
|
12
12
|
* Type representing all standard HTTP methods prefixed with '$'
|
|
13
|
-
* e.g., '$get' | '$post' | '$put' | '$delete' | '$options' | '$patch'
|
|
13
|
+
* e.g., '$get' | '$post' | '$put' | '$delete' | '$options' | '$patch' | '$query'
|
|
14
14
|
*/
|
|
15
15
|
type StandardMethods = `$${(typeof METHODS)[number]}`;
|
|
16
16
|
/**
|
|
@@ -65,6 +65,7 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
|
|
|
65
65
|
delete: HandlerInterface<E, 'delete', S, BasePath, CurrentPath>;
|
|
66
66
|
options: HandlerInterface<E, 'options', S, BasePath, CurrentPath>;
|
|
67
67
|
patch: HandlerInterface<E, 'patch', S, BasePath, CurrentPath>;
|
|
68
|
+
query: HandlerInterface<E, 'query', S, BasePath, CurrentPath>;
|
|
68
69
|
all: HandlerInterface<E, 'all', S, BasePath, CurrentPath>;
|
|
69
70
|
on: OnHandlerInterface<E, S, BasePath>;
|
|
70
71
|
use: MiddlewareHandlerInterface<E, S, BasePath>;
|
|
@@ -179,12 +180,12 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
|
|
|
179
180
|
* @see {@link https://hono.dev/docs/api/hono#fetch}
|
|
180
181
|
*
|
|
181
182
|
* @param {Request} request - request Object of request
|
|
182
|
-
* @param {Env}
|
|
183
|
-
* @param {ExecutionContext} - context of execution
|
|
183
|
+
* @param {Env} env - env Object
|
|
184
|
+
* @param {ExecutionContext} executionCtx - context of execution
|
|
184
185
|
* @returns {Response | Promise<Response>} response of request
|
|
185
186
|
*
|
|
186
187
|
*/
|
|
187
|
-
fetch: (request: Request,
|
|
188
|
+
fetch: (request: Request, env?: E['Bindings'] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
|
|
188
189
|
/**
|
|
189
190
|
* `.request()` is a useful method for testing.
|
|
190
191
|
* You can pass a URL or pathname to send a GET request.
|
|
@@ -3,14 +3,16 @@ import { DOM_MEMO } from './constants';
|
|
|
3
3
|
import type { Context } from './context';
|
|
4
4
|
import type { JSX as HonoJSX, IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements';
|
|
5
5
|
export type Props = Record<string, any>;
|
|
6
|
+
type FunctionComponentResult = HtmlEscapedString | Child[] | Promise<HtmlEscapedString | Child[]> | null;
|
|
6
7
|
export type FC<P = Props> = {
|
|
7
|
-
(props: P):
|
|
8
|
+
(props: P): FunctionComponentResult;
|
|
8
9
|
defaultProps?: Partial<P> | undefined;
|
|
9
10
|
displayName?: string | undefined;
|
|
10
11
|
};
|
|
11
12
|
export type DOMAttributes = HonoJSX.HTMLAttributes;
|
|
12
13
|
export declare namespace JSX {
|
|
13
14
|
type Element = HtmlEscapedString | Promise<HtmlEscapedString>;
|
|
15
|
+
type ElementType = string | ((props: never) => FunctionComponentResult);
|
|
14
16
|
interface ElementChildrenAttribute {
|
|
15
17
|
children: Child;
|
|
16
18
|
}
|
|
@@ -30,7 +32,6 @@ export declare class JSXNode implements HtmlEscaped {
|
|
|
30
32
|
key?: string;
|
|
31
33
|
children: Child[];
|
|
32
34
|
isEscaped: true;
|
|
33
|
-
suspendedContext?: <T>(callback: () => T) => T;
|
|
34
35
|
constructor(tag: string | Function, props: Props, children: Child[]);
|
|
35
36
|
get type(): string | Function;
|
|
36
37
|
get ref(): any;
|
|
@@ -54,3 +55,4 @@ export declare const Fragment: ({ children, }: {
|
|
|
54
55
|
export declare const isValidElement: (element: unknown) => element is JSXNode;
|
|
55
56
|
export declare const cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Partial<Props>, ...children: Child[]) => T;
|
|
56
57
|
export declare const reactAPICompatVersion = "19.0.0-hono-jsx";
|
|
58
|
+
export {};
|
|
@@ -24,7 +24,7 @@ declare const _default: {
|
|
|
24
24
|
<T = undefined>(): [T | undefined, (newState: T | ((currentState: T | undefined) => T | undefined) | undefined) => void];
|
|
25
25
|
};
|
|
26
26
|
useEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
|
|
27
|
-
useRef:
|
|
27
|
+
useRef: typeof useRef;
|
|
28
28
|
useCallback: <T extends Function>(callback: T, deps: readonly unknown[]) => T;
|
|
29
29
|
use: <T>(promise: Promise<T>) => T;
|
|
30
30
|
startTransition: (callback: () => void) => void;
|
|
@@ -38,11 +38,11 @@ declare const _default: {
|
|
|
38
38
|
useReducer: <T, A>(reducer: (state: T, action: A) => T, initialArg: T, init?: (initialState: T) => T) => [T, (action: A) => void];
|
|
39
39
|
useId: () => string;
|
|
40
40
|
useDebugValue: (_value: unknown, _formatter?: (value: unknown) => string) => void;
|
|
41
|
-
createRef: <T>() => import("..").RefObject<T>;
|
|
42
|
-
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("..").RefObject<T>) => JSX.Element) => ((props: P & {
|
|
43
|
-
ref?: import("..").RefObject<T>;
|
|
41
|
+
createRef: <T>() => import("..").RefObject<T | null>;
|
|
42
|
+
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("..").RefObject<T | null>) => JSX.Element) => ((props: P & {
|
|
43
|
+
ref?: import("..").RefObject<T | null>;
|
|
44
44
|
}) => JSX.Element);
|
|
45
|
-
useImperativeHandle: <T>(ref: import("..").RefObject<T>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
45
|
+
useImperativeHandle: <T>(ref: import("..").RefObject<T | null>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
46
46
|
useSyncExternalStore: <T>(subscribe: (callback: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T) => T;
|
|
47
47
|
useFormStatus: () => {
|
|
48
48
|
pending: false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IntrinsicElements } from '../../intrinsic-elements';
|
|
2
2
|
import type { FC, PropsWithChildren, RefObject } from '../../types';
|
|
3
3
|
export declare const clearCache: () => void;
|
|
4
|
-
export declare const composeRef: <T>(ref: RefObject<T> | Function | undefined, cb: (e: T) => void | (() => void)) => ((e: T) => () => void);
|
|
4
|
+
export declare const composeRef: <T>(ref: RefObject<T | null> | Function | undefined, cb: (e: T) => void | (() => void)) => ((e: T) => () => void);
|
|
5
5
|
export declare const title: FC<PropsWithChildren>;
|
|
6
6
|
export declare const script: FC<PropsWithChildren<IntrinsicElements['script']>>;
|
|
7
7
|
export declare const style: FC<PropsWithChildren<IntrinsicElements['style']>>;
|
|
@@ -10,7 +10,7 @@ export declare const meta: FC<PropsWithChildren>;
|
|
|
10
10
|
export declare const form: FC<PropsWithChildren<{
|
|
11
11
|
action?: Function | string;
|
|
12
12
|
method?: 'get' | 'post';
|
|
13
|
-
ref?: RefObject<HTMLFormElement> | ((e: HTMLFormElement | null) => void | (() => void));
|
|
13
|
+
ref?: RefObject<HTMLFormElement | null> | ((e: HTMLFormElement | null) => void | (() => void));
|
|
14
14
|
}>>;
|
|
15
15
|
export declare const input: FC<PropsWithChildren<IntrinsicElements['input']>>;
|
|
16
16
|
export declare const button: FC<PropsWithChildren<IntrinsicElements['button']>>;
|
|
@@ -43,7 +43,7 @@ declare const _default: {
|
|
|
43
43
|
<T = undefined>(): [T | undefined, (newState: T | ((currentState: T | undefined) => T | undefined) | undefined) => void];
|
|
44
44
|
};
|
|
45
45
|
useEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
|
|
46
|
-
useRef:
|
|
46
|
+
useRef: typeof import("..").useRef;
|
|
47
47
|
useCallback: <T extends Function>(callback: T, deps: readonly unknown[]) => T;
|
|
48
48
|
use: <T>(promise: Promise<T>) => T;
|
|
49
49
|
startTransition: (callback: () => void) => void;
|
|
@@ -57,11 +57,11 @@ declare const _default: {
|
|
|
57
57
|
useReducer: <T, A>(reducer: (state: T, action: A) => T, initialArg: T, init?: (initialState: T) => T) => [T, (action: A) => void];
|
|
58
58
|
useId: () => string;
|
|
59
59
|
useDebugValue: (_value: unknown, _formatter?: (value: unknown) => string) => void;
|
|
60
|
-
createRef: <T>() => import("..").RefObject<T>;
|
|
61
|
-
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("..").RefObject<T>) => import("./jsx-dev-runtime").JSX.Element) => ((props: P & {
|
|
62
|
-
ref?: import("..").RefObject<T>;
|
|
60
|
+
createRef: <T>() => import("..").RefObject<T | null>;
|
|
61
|
+
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("..").RefObject<T | null>) => import("./jsx-dev-runtime").JSX.Element) => ((props: P & {
|
|
62
|
+
ref?: import("..").RefObject<T | null>;
|
|
63
63
|
}) => import("./jsx-dev-runtime").JSX.Element);
|
|
64
|
-
useImperativeHandle: <T>(ref: import("..").RefObject<T>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
64
|
+
useImperativeHandle: <T>(ref: import("..").RefObject<T | null>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
65
65
|
useSyncExternalStore: <T>(subscribe: (callback: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T) => T;
|
|
66
66
|
useFormStatus: () => {
|
|
67
67
|
pending: false;
|
|
@@ -29,17 +29,19 @@ export declare const useLayoutEffect: (effect: () => void | (() => void), deps?:
|
|
|
29
29
|
export declare const useInsertionEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
|
|
30
30
|
export declare const useCallback: <T extends Function>(callback: T, deps: readonly unknown[]) => T;
|
|
31
31
|
export type RefObject<T> = {
|
|
32
|
-
current: T
|
|
32
|
+
current: T;
|
|
33
33
|
};
|
|
34
|
-
export declare
|
|
34
|
+
export declare function useRef<T>(initialValue: T): RefObject<T>;
|
|
35
|
+
export declare function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
|
36
|
+
export declare function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
|
|
35
37
|
export declare const use: <T>(promise: Promise<T>) => T;
|
|
36
38
|
export declare const useMemo: <T>(factory: () => T, deps: readonly unknown[]) => T;
|
|
37
39
|
export declare const useId: () => string;
|
|
38
40
|
export declare const useDebugValue: (_value: unknown, _formatter?: (value: unknown) => string) => void;
|
|
39
|
-
export declare const createRef: <T>() => RefObject<T>;
|
|
40
|
-
export declare const forwardRef: <T, P = {}>(Component: (props: P, ref?: RefObject<T>) => JSX.Element) => ((props: P & {
|
|
41
|
-
ref?: RefObject<T>;
|
|
41
|
+
export declare const createRef: <T>() => RefObject<T | null>;
|
|
42
|
+
export declare const forwardRef: <T, P = {}>(Component: (props: P, ref?: RefObject<T | null>) => JSX.Element) => ((props: P & {
|
|
43
|
+
ref?: RefObject<T | null>;
|
|
42
44
|
}) => JSX.Element);
|
|
43
|
-
export declare const useImperativeHandle: <T>(ref: RefObject<T>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
45
|
+
export declare const useImperativeHandle: <T>(ref: RefObject<T | null>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
44
46
|
export declare const useSyncExternalStore: <T>(subscribe: (callback: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T) => T;
|
|
45
47
|
export {};
|
|
@@ -37,7 +37,7 @@ declare const _default: {
|
|
|
37
37
|
<T = undefined>(): [T | undefined, (newState: T | ((currentState: T | undefined) => T | undefined) | undefined) => void];
|
|
38
38
|
};
|
|
39
39
|
useEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
|
|
40
|
-
useRef:
|
|
40
|
+
useRef: typeof useRef;
|
|
41
41
|
useCallback: <T extends Function>(callback: T, deps: readonly unknown[]) => T;
|
|
42
42
|
useReducer: <T, A>(reducer: (state: T, action: A) => T, initialArg: T, init?: (initialState: T) => T) => [T, (action: A) => void];
|
|
43
43
|
useId: () => string;
|
|
@@ -51,11 +51,11 @@ declare const _default: {
|
|
|
51
51
|
useMemo: <T>(factory: () => T, deps: readonly unknown[]) => T;
|
|
52
52
|
useLayoutEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
|
|
53
53
|
useInsertionEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
|
|
54
|
-
createRef: <T>() => import("./hooks").RefObject<T>;
|
|
55
|
-
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("./hooks").RefObject<T>) => import("./base").JSX.Element) => ((props: P & {
|
|
56
|
-
ref?: import("./hooks").RefObject<T>;
|
|
54
|
+
createRef: <T>() => import("./hooks").RefObject<T | null>;
|
|
55
|
+
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("./hooks").RefObject<T | null>) => import("./base").JSX.Element) => ((props: P & {
|
|
56
|
+
ref?: import("./hooks").RefObject<T | null>;
|
|
57
57
|
}) => import("./base").JSX.Element);
|
|
58
|
-
useImperativeHandle: <T>(ref: import("./hooks").RefObject<T>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
58
|
+
useImperativeHandle: <T>(ref: import("./hooks").RefObject<T | null>, createHandle: () => T, deps: readonly unknown[]) => void;
|
|
59
59
|
useSyncExternalStore: <T>(subscribe: (callback: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T) => T;
|
|
60
60
|
useActionState: <T>(fn: Function, initialState: T, permalink?: string) => [T, Function];
|
|
61
61
|
useOptimistic: <T, N>(state: T, updateState: (currentState: T, action: N) => T) => [T, (action: N) => void];
|
|
@@ -15,15 +15,16 @@ import type { StatusCode } from '../../utils/http-status';
|
|
|
15
15
|
* @param {boolean} [options.wait=false] - A boolean indicating if Hono should wait for the Promise of the `cache.put` function to resolve before continuing with the request. Required to be true for the Deno environment.
|
|
16
16
|
* @param {string} [options.cacheControl] - A string of directives for the `Cache-Control` header.
|
|
17
17
|
* @param {string | string[]} [options.vary] - Adds the configured request headers to the cache key variants and sets the `Vary` header in the response. If the original response header already contains a `Vary` header, the values are merged, removing any duplicates.
|
|
18
|
-
* @param {Function} [options.keyGenerator] - Generates keys for every request in the `cacheName` store. This can be used to cache data based on request parameters or context parameters.
|
|
18
|
+
* @param {Function} [options.keyGenerator] - Generates keys for every request in the `cacheName` store. This can be used to cache data based on request parameters or context parameters. QUERY keys additionally include a digest of the request content and its representation metadata.
|
|
19
|
+
* @param {number} [options.maxQueryBodySize=65536] - The maximum QUERY request body size in bytes that can be cached. Larger QUERY requests bypass the cache.
|
|
19
20
|
* @param {number[]} [options.cacheableStatusCodes=[200]] - An array of status codes that can be cached.
|
|
20
|
-
* @param {Function | false} [options.onCacheNotAvailable] - A callback invoked when `globalThis.caches` is not available. By default,
|
|
21
|
+
* @param {Function | false} [options.onCacheNotAvailable] - A callback invoked with the reason when `globalThis.caches` is not available or QUERY caching cannot use Web Crypto. By default, the reason is logged to the console. Set to `false` to suppress the log, or provide a custom function.
|
|
21
22
|
* @returns {MiddlewareHandler} The middleware handler function.
|
|
22
23
|
* @throws {Error} If the `vary` option includes "*".
|
|
23
24
|
*
|
|
24
25
|
* @example
|
|
25
26
|
* ```ts
|
|
26
|
-
* app.
|
|
27
|
+
* app.use(
|
|
27
28
|
* '*',
|
|
28
29
|
* cache({
|
|
29
30
|
* cacheName: 'my-app',
|
|
@@ -38,6 +39,7 @@ export declare const cache: (options: {
|
|
|
38
39
|
cacheControl?: string;
|
|
39
40
|
vary?: string | string[];
|
|
40
41
|
keyGenerator?: (c: Context) => Promise<string> | string;
|
|
42
|
+
maxQueryBodySize?: number;
|
|
41
43
|
cacheableStatusCodes?: StatusCode[];
|
|
42
|
-
onCacheNotAvailable?: (() => void) | false;
|
|
44
|
+
onCacheNotAvailable?: ((reason: string) => void) | false;
|
|
43
45
|
}) => MiddlewareHandler;
|
|
@@ -19,7 +19,7 @@ type CORSOptions = {
|
|
|
19
19
|
*
|
|
20
20
|
* @param {CORSOptions} [options] - The options for the CORS middleware.
|
|
21
21
|
* @param {string | string[] | ((origin: string, c: Context) => Promise<string | undefined | null> | string | undefined | null)} [options.origin='*'] - The value of "Access-Control-Allow-Origin" CORS header.
|
|
22
|
-
* @param {string[] | ((origin: string, c: Context) => Promise<string[]> | string[])} [options.allowMethods=['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH']] - The value of "Access-Control-Allow-Methods" CORS header.
|
|
22
|
+
* @param {string[] | ((origin: string, c: Context) => Promise<string[]> | string[])} [options.allowMethods=['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY']] - The value of "Access-Control-Allow-Methods" CORS header.
|
|
23
23
|
* @param {string[]} [options.allowHeaders=[]] - The value of "Access-Control-Allow-Headers" CORS header.
|
|
24
24
|
* @param {number} [options.maxAge] - The value of "Access-Control-Max-Age" CORS header.
|
|
25
25
|
* @param {boolean} [options.credentials] - The value of "Access-Control-Allow-Credentials" CORS header.
|