hono 4.1.2 → 4.1.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.
@@ -74,15 +74,16 @@ const fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook,
74
74
  for (const route of (0, import_utils2.filterStaticGenerateRoutes)(app)) {
75
75
  const thisRouteBaseURL = new URL(route.path, baseURL).toString();
76
76
  let forGetInfoURLRequest = new Request(thisRouteBaseURL);
77
- if (beforeRequestHook) {
78
- const maybeRequest = beforeRequestHook(forGetInfoURLRequest);
79
- if (!maybeRequest) {
80
- continue;
81
- }
82
- forGetInfoURLRequest = maybeRequest;
83
- }
84
77
  yield new Promise(async (resolveGetInfo, rejectGetInfo) => {
85
78
  try {
79
+ if (beforeRequestHook) {
80
+ const maybeRequest = await beforeRequestHook(forGetInfoURLRequest);
81
+ if (!maybeRequest) {
82
+ resolveGetInfo(void 0);
83
+ return;
84
+ }
85
+ forGetInfoURLRequest = maybeRequest;
86
+ }
86
87
  await pool.run(() => app.fetch(forGetInfoURLRequest));
87
88
  if (!forGetInfoURLRequest.ssgParams) {
88
89
  if (isDynamicRoute(route.path)) {
@@ -111,7 +112,7 @@ const fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook,
111
112
  return;
112
113
  }
113
114
  if (afterResponseHook) {
114
- const maybeResponse = afterResponseHook(response);
115
+ const maybeResponse = await afterResponseHook(response);
115
116
  if (!maybeResponse) {
116
117
  resolveReq(void 0);
117
118
  return;
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
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
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -14,6 +18,11 @@ var __copyProps = (to, from, except, desc) => {
14
18
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
20
  var helper_exports = {};
21
+ __export(helper_exports, {
22
+ jwtDecode: () => import_jwt.decode,
23
+ jwtSign: () => import_jwt.sign,
24
+ jwtVerify: () => import_jwt.verify
25
+ });
17
26
  module.exports = __toCommonJS(helper_exports);
18
27
  __reExport(helper_exports, require("./helper/accepts"), module.exports);
19
28
  __reExport(helper_exports, require("./helper/adapter"), module.exports);
@@ -26,3 +35,10 @@ __reExport(helper_exports, require("./helper/testing"), module.exports);
26
35
  __reExport(helper_exports, require("./helper/dev"), module.exports);
27
36
  __reExport(helper_exports, require("./adapter/deno/ssg"), module.exports);
28
37
  __reExport(helper_exports, require("./adapter/deno/websocket"), module.exports);
38
+ var import_jwt = require("./middleware/jwt");
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ jwtDecode,
42
+ jwtSign,
43
+ jwtVerify
44
+ });
@@ -135,7 +135,9 @@ class JSXNode {
135
135
  const property = k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
136
136
  return `${property}:${v[k]}`;
137
137
  }).join(";");
138
- buffer[0] += ` style="${styles}"`;
138
+ buffer[0] += ' style="';
139
+ (0, import_html2.escapeToBuffer)(styles, buffer);
140
+ buffer[0] += '"';
139
141
  } else if (typeof v === "string") {
140
142
  buffer[0] += ` ${key}="`;
141
143
  (0, import_html2.escapeToBuffer)(v, buffer);
@@ -165,7 +167,7 @@ class JSXNode {
165
167
  buffer[0] += '"';
166
168
  }
167
169
  }
168
- if (emptyTags.includes(tag)) {
170
+ if (emptyTags.includes(tag) && children.length === 0) {
169
171
  buffer[0] += "/>";
170
172
  return;
171
173
  }
@@ -29,7 +29,7 @@ var import_components = require("./dom/components");
29
29
  let errorBoundaryCounter = 0;
30
30
  const childrenToString = async (children) => {
31
31
  try {
32
- return children.map((c) => c.toString());
32
+ return children.flat().map((c) => c == null || typeof c === "boolean" ? "" : c.toString());
33
33
  } catch (e) {
34
34
  if (e instanceof Promise) {
35
35
  await e;
@@ -53,7 +53,9 @@ const ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) =>
53
53
  };
54
54
  let resArray = [];
55
55
  try {
56
- resArray = children.map((c) => c.toString());
56
+ resArray = children.map(
57
+ (c) => c == null || typeof c === "boolean" ? "" : c.toString()
58
+ );
57
59
  } catch (e) {
58
60
  fallbackStr = await fallback?.toString();
59
61
  if (e instanceof Promise) {
@@ -294,7 +294,7 @@ const useMemo = (factory, deps) => {
294
294
  }
295
295
  return memoArray[hookIndex][0];
296
296
  };
297
- const useDebugValue = (value, formatter) => {
297
+ const useDebugValue = (_value, _formatter) => {
298
298
  };
299
299
  // Annotate the CommonJS export names for ESM import in node:
300
300
  0 && (module.exports = {
@@ -48,7 +48,9 @@ const Suspense = async ({
48
48
  try {
49
49
  stackNode[import_constants.DOM_STASH][0] = 0;
50
50
  import_render.buildDataStack.push([[], stackNode]);
51
- resArray = children.map((c) => c.toString());
51
+ resArray = children.map(
52
+ (c) => c == null || typeof c === "boolean" ? "" : c.toString()
53
+ );
52
54
  } catch (e) {
53
55
  if (e instanceof Promise) {
54
56
  resArray = [
@@ -30,7 +30,10 @@ const nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
30
30
  let wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
31
31
  function buildWildcardRegExp(path) {
32
32
  return wildcardRegExpCache[path] ??= new RegExp(
33
- path === "*" ? "" : `^${path.replace(/\/\*/, "(?:|/.*)")}$`
33
+ path === "*" ? "" : `^${path.replace(
34
+ /\/\*$|([.\\+*[^\]$()])/g,
35
+ (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
36
+ )}$`
34
37
  );
35
38
  }
36
39
  function clearWildcardRegExpCache() {
@@ -28,6 +28,7 @@ const validator = (target, validationFunc) => {
28
28
  return async (c, next) => {
29
29
  let value = {};
30
30
  const contentType = c.req.header("Content-Type");
31
+ const bodyTypes = ["text", "arrayBuffer", "blob"];
31
32
  switch (target) {
32
33
  case "json":
33
34
  if (!contentType || !contentType.startsWith("application/json")) {
@@ -35,11 +36,19 @@ const validator = (target, validationFunc) => {
35
36
  throw new import_http_exception.HTTPException(400, { message });
36
37
  }
37
38
  if (c.req.bodyCache.json) {
38
- value = await c.req.bodyCache.json;
39
+ value = c.req.bodyCache.json;
39
40
  break;
40
41
  }
41
42
  try {
42
- const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
43
+ let arrayBuffer = void 0;
44
+ for (const type of bodyTypes) {
45
+ const body = c.req.bodyCache[type];
46
+ if (body) {
47
+ arrayBuffer = await new Response(await body).arrayBuffer();
48
+ break;
49
+ }
50
+ }
51
+ arrayBuffer ??= await c.req.raw.arrayBuffer();
43
52
  value = await new Response(arrayBuffer).json();
44
53
  c.req.bodyCache.json = value;
45
54
  c.req.bodyCache.arrayBuffer = arrayBuffer;
@@ -49,23 +58,31 @@ const validator = (target, validationFunc) => {
49
58
  }
50
59
  break;
51
60
  case "form": {
61
+ if (!contentType) {
62
+ break;
63
+ }
52
64
  if (c.req.bodyCache.formData) {
53
65
  value = c.req.bodyCache.formData;
54
66
  break;
55
67
  }
56
68
  try {
57
- const contentType2 = c.req.header("Content-Type");
58
- if (contentType2) {
59
- const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
60
- const formData = await (0, import_buffer.bufferToFormData)(arrayBuffer, contentType2);
61
- const form = {};
62
- formData.forEach((value2, key) => {
63
- form[key] = value2;
64
- });
65
- value = form;
66
- c.req.bodyCache.formData = formData;
67
- c.req.bodyCache.arrayBuffer = arrayBuffer;
69
+ let arrayBuffer = void 0;
70
+ for (const type of bodyTypes) {
71
+ const body = c.req.bodyCache[type];
72
+ if (body) {
73
+ arrayBuffer = await new Response(await body).arrayBuffer();
74
+ break;
75
+ }
68
76
  }
77
+ arrayBuffer ??= await c.req.arrayBuffer();
78
+ const formData = await (0, import_buffer.bufferToFormData)(arrayBuffer, contentType);
79
+ const form = {};
80
+ formData.forEach((value2, key) => {
81
+ form[key] = value2;
82
+ });
83
+ value = form;
84
+ c.req.bodyCache.formData = formData;
85
+ c.req.bodyCache.arrayBuffer = arrayBuffer;
69
86
  } catch (e) {
70
87
  let message = "Malformed FormData request.";
71
88
  message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
@@ -50,15 +50,16 @@ var fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, c
50
50
  for (const route of filterStaticGenerateRoutes(app)) {
51
51
  const thisRouteBaseURL = new URL(route.path, baseURL).toString();
52
52
  let forGetInfoURLRequest = new Request(thisRouteBaseURL);
53
- if (beforeRequestHook) {
54
- const maybeRequest = beforeRequestHook(forGetInfoURLRequest);
55
- if (!maybeRequest) {
56
- continue;
57
- }
58
- forGetInfoURLRequest = maybeRequest;
59
- }
60
53
  yield new Promise(async (resolveGetInfo, rejectGetInfo) => {
61
54
  try {
55
+ if (beforeRequestHook) {
56
+ const maybeRequest = await beforeRequestHook(forGetInfoURLRequest);
57
+ if (!maybeRequest) {
58
+ resolveGetInfo(void 0);
59
+ return;
60
+ }
61
+ forGetInfoURLRequest = maybeRequest;
62
+ }
62
63
  await pool.run(() => app.fetch(forGetInfoURLRequest));
63
64
  if (!forGetInfoURLRequest.ssgParams) {
64
65
  if (isDynamicRoute(route.path)) {
@@ -87,7 +88,7 @@ var fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, c
87
88
  return;
88
89
  }
89
90
  if (afterResponseHook) {
90
- const maybeResponse = afterResponseHook(response);
91
+ const maybeResponse = await afterResponseHook(response);
91
92
  if (!maybeResponse) {
92
93
  resolveReq(void 0);
93
94
  return;
package/dist/helper.js CHANGED
@@ -10,3 +10,9 @@ export * from "./helper/testing/index.js";
10
10
  export * from "./helper/dev/index.js";
11
11
  export * from "./adapter/deno/ssg.js";
12
12
  export * from "./adapter/deno/websocket.js";
13
+ import { decode, sign, verify } from "./middleware/jwt/index.js";
14
+ export {
15
+ decode as jwtDecode,
16
+ sign as jwtSign,
17
+ verify as jwtVerify
18
+ };
package/dist/jsx/base.js CHANGED
@@ -106,7 +106,9 @@ var JSXNode = class {
106
106
  const property = k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
107
107
  return `${property}:${v[k]}`;
108
108
  }).join(";");
109
- buffer[0] += ` style="${styles}"`;
109
+ buffer[0] += ' style="';
110
+ escapeToBuffer(styles, buffer);
111
+ buffer[0] += '"';
110
112
  } else if (typeof v === "string") {
111
113
  buffer[0] += ` ${key}="`;
112
114
  escapeToBuffer(v, buffer);
@@ -136,7 +138,7 @@ var JSXNode = class {
136
138
  buffer[0] += '"';
137
139
  }
138
140
  }
139
- if (emptyTags.includes(tag)) {
141
+ if (emptyTags.includes(tag) && children.length === 0) {
140
142
  buffer[0] += "/>";
141
143
  return;
142
144
  }
@@ -6,7 +6,7 @@ import { ErrorBoundary as ErrorBoundaryDomRenderer } from "./dom/components.js";
6
6
  var errorBoundaryCounter = 0;
7
7
  var childrenToString = async (children) => {
8
8
  try {
9
- return children.map((c) => c.toString());
9
+ return children.flat().map((c) => c == null || typeof c === "boolean" ? "" : c.toString());
10
10
  } catch (e) {
11
11
  if (e instanceof Promise) {
12
12
  await e;
@@ -30,7 +30,9 @@ var ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) => {
30
30
  };
31
31
  let resArray = [];
32
32
  try {
33
- resArray = children.map((c) => c.toString());
33
+ resArray = children.map(
34
+ (c) => c == null || typeof c === "boolean" ? "" : c.toString()
35
+ );
34
36
  } catch (e) {
35
37
  fallbackStr = await fallback?.toString();
36
38
  if (e instanceof Promise) {
@@ -258,7 +258,7 @@ var useMemo = (factory, deps) => {
258
258
  }
259
259
  return memoArray[hookIndex][0];
260
260
  };
261
- var useDebugValue = (value, formatter) => {
261
+ var useDebugValue = (_value, _formatter) => {
262
262
  };
263
263
  export {
264
264
  STASH_EFFECT,
@@ -25,7 +25,9 @@ var Suspense = async ({
25
25
  try {
26
26
  stackNode[DOM_STASH][0] = 0;
27
27
  buildDataStack.push([[], stackNode]);
28
- resArray = children.map((c) => c.toString());
28
+ resArray = children.map(
29
+ (c) => c == null || typeof c === "boolean" ? "" : c.toString()
30
+ );
29
31
  } catch (e) {
30
32
  if (e instanceof Promise) {
31
33
  resArray = [
@@ -12,7 +12,10 @@ var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
12
12
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
13
13
  function buildWildcardRegExp(path) {
14
14
  return wildcardRegExpCache[path] ??= new RegExp(
15
- path === "*" ? "" : `^${path.replace(/\/\*/, "(?:|/.*)")}$`
15
+ path === "*" ? "" : `^${path.replace(
16
+ /\/\*$|([.\\+*[^\]$()])/g,
17
+ (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
18
+ )}$`
16
19
  );
17
20
  }
18
21
  function clearWildcardRegExpCache() {
@@ -21,8 +21,8 @@ export interface ToSSGResult {
21
21
  files: string[];
22
22
  error?: Error;
23
23
  }
24
- export type BeforeRequestHook = (req: Request) => Request | false;
25
- export type AfterResponseHook = (res: Response) => Response | false;
24
+ export type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>;
25
+ export type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>;
26
26
  export type AfterGenerateHook = (result: ToSSGResult) => void | Promise<void>;
27
27
  export interface ToSSGOptions {
28
28
  dir?: string;
@@ -1,4 +1,5 @@
1
+ import type { ExecutionContext } from '../../context';
1
2
  import type { Hono } from '../../hono';
2
3
  type ExtractEnv<T> = T extends Hono<infer E, any, any> ? E : never;
3
- export declare const testClient: <T extends Hono<any, any, any>>(app: T, Env?: {} | ExtractEnv<T>["Bindings"] | undefined, executionCtx?: any) => import("../../utils/types").UnionToIntersection<import("../../client/types").Client<T>>;
4
+ export declare const testClient: <T extends Hono<any, any, any>>(app: T, Env?: {} | ExtractEnv<T>["Bindings"] | undefined, executionCtx?: ExecutionContext) => import("../../utils/types").UnionToIntersection<import("../../client/types").Client<T>>;
4
5
  export {};
@@ -15,7 +15,7 @@ declare global {
15
15
  }
16
16
  }
17
17
  type LocalContexts = [Context<unknown>, unknown][];
18
- export type Child = string | Promise<string> | number | JSXNode | Child[];
18
+ export type Child = string | Promise<string> | number | JSXNode | null | undefined | boolean | Child[];
19
19
  export declare class JSXNode implements HtmlEscaped {
20
20
  tag: string | Function;
21
21
  props: Props;
@@ -35,7 +35,7 @@ export declare const jsxFn: (tag: string | Function, props: Props, children: (st
35
35
  export declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
36
36
  export declare const Fragment: ({ children, }: {
37
37
  key?: string | undefined;
38
- children?: HtmlEscapedString | Child | undefined;
38
+ children?: Child | HtmlEscapedString;
39
39
  }) => HtmlEscapedString;
40
40
  export declare const isValidElement: (element: unknown) => element is JSXNode;
41
41
  export declare const cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Partial<Props>, ...children: Child[]) => T;
@@ -22,12 +22,12 @@ declare const _default: {
22
22
  useMemo: <T_5>(factory: () => T_5, deps: readonly unknown[]) => T_5;
23
23
  useLayoutEffect: (effect: () => void | (() => void), deps?: readonly unknown[] | undefined) => void;
24
24
  useReducer: <T_6, A>(reducer: (state: T_6, action: A) => T_6, initialArg: T_6, init?: ((initialState: T_6) => T_6) | undefined) => [T_6, (action: A) => void];
25
- useDebugValue: (value: unknown, formatter?: ((value: unknown) => string) | undefined) => void;
25
+ useDebugValue: (_value: unknown, _formatter?: ((value: unknown) => string) | undefined) => void;
26
26
  Suspense: import("../base").FC<import("..").PropsWithChildren<{
27
27
  fallback: any;
28
28
  }>>;
29
29
  ErrorBoundary: import("../base").FC<import("..").PropsWithChildren<{
30
- fallback?: Child | undefined;
30
+ fallback?: Child;
31
31
  fallbackRender?: import("../components").FallbackRender | undefined;
32
32
  onError?: import("../components").ErrorHandler | undefined;
33
33
  }>>;
@@ -25,5 +25,5 @@ export type RefObject<T> = {
25
25
  export declare const useRef: <T>(initialValue: T | null) => RefObject<T>;
26
26
  export declare const use: <T>(promise: Promise<T>) => T;
27
27
  export declare const useMemo: <T>(factory: () => T, deps: readonly unknown[]) => T;
28
- export declare const useDebugValue: (value: unknown, formatter?: ((value: unknown) => string) | undefined) => void;
28
+ export declare const useDebugValue: (_value: unknown, _formatter?: ((value: unknown) => string) | undefined) => void;
29
29
  export {};
@@ -8,13 +8,13 @@ declare const _default: {
8
8
  memo: <T>(component: import("./base").FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => import("./base").FC<T>;
9
9
  Fragment: ({ children, }: {
10
10
  key?: string | undefined;
11
- children?: import("../utils/html").HtmlEscapedString | import("./base").Child | undefined;
11
+ children?: import("../utils/html").HtmlEscapedString | import("./base").Child;
12
12
  }) => import("../utils/html").HtmlEscapedString;
13
13
  isValidElement: (element: unknown) => element is import("./base").JSXNode;
14
14
  createElement: (tag: string | Function, props: import("./base").Props, ...children: (string | import("../utils/html").HtmlEscapedString)[]) => import("./base").JSXNode;
15
15
  cloneElement: <T_1 extends import("./base").JSXNode | JSX.Element>(element: T_1, props: Partial<import("./base").Props>, ...children: import("./base").Child[]) => T_1;
16
16
  ErrorBoundary: import("./base").FC<import("./types").PropsWithChildren<{
17
- fallback?: import("./base").Child | undefined;
17
+ fallback?: import("./base").Child;
18
18
  fallbackRender?: import("./components").FallbackRender | undefined;
19
19
  onError?: import("./components").ErrorHandler | undefined;
20
20
  }>>;
@@ -25,7 +25,7 @@ declare const _default: {
25
25
  useRef: <T_5>(initialValue: T_5 | null) => import("./hooks").RefObject<T_5>;
26
26
  useCallback: <T_6 extends (...args: unknown[]) => unknown>(callback: T_6, deps: readonly unknown[]) => T_6;
27
27
  useReducer: <T_7, A>(reducer: (state: T_7, action: A) => T_7, initialArg: T_7, init?: ((initialState: T_7) => T_7) | undefined) => [T_7, (action: A) => void];
28
- useDebugValue: (value: unknown, formatter?: ((value: unknown) => string) | undefined) => void;
28
+ useDebugValue: (_value: unknown, _formatter?: ((value: unknown) => string) | undefined) => void;
29
29
  use: <T_8>(promise: Promise<T_8>) => T_8;
30
30
  startTransition: (callback: () => void) => void;
31
31
  useTransition: () => [boolean, (callback: () => void) => void];
@@ -1,6 +1,6 @@
1
1
  import type { Context } from './context';
2
2
  import type { Hono } from './hono';
3
- import type { IfAnyThenEmptyObject, RemoveBlankRecord, UnionToIntersection } from './utils/types';
3
+ import type { IfAnyThenEmptyObject, Prettify, RemoveBlankRecord, UnionToIntersection } from './utils/types';
4
4
  export type Bindings = Record<string, unknown>;
5
5
  export type Variables = Record<string, unknown>;
6
6
  export type Env = {
@@ -27,10 +27,26 @@ export type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response |
27
27
  export type ErrorHandler<E extends Env = any> = (err: Error, c: Context<E>) => Response | Promise<Response>;
28
28
  export interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = {}, BasePath extends string = '/'> {
29
29
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, I extends Input = BlankInput, R extends HandlerResponse<any> = any, E2 extends Env = E>(handler: H<E2, P, I, R>): Hono<IntersectNonAnyTypes<[E, E2]>, S & ToSchema<M, P, I['in'], MergeTypedResponseData<R>>, BasePath>;
30
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, E2 extends Env = E>(path: P, handler: H<E2, MergedPath, I, R>): Hono<IntersectNonAnyTypes<[E, E2]>, S & ToSchema<M, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
30
31
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, I extends Input = BlankInput, I2 extends Input = I, R extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>>(...handlers: [H<E2, P, I>, H<E3, P, I2, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3]>, S & ToSchema<M, P, I2['in'], MergeTypedResponseData<R>>, BasePath>;
32
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>>(path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3]>, S & ToSchema<M, MergePath<BasePath, P>, I2['in'], MergeTypedResponseData<R>>, BasePath>;
31
33
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>>(...handlers: [H<E2, P, I>, H<E3, P, I2>, H<E4, P, I3, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4]>, S & ToSchema<M, P, I3['in'], MergeTypedResponseData<R>>, BasePath>;
34
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>>(path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4]>, S & ToSchema<M, MergePath<BasePath, P>, I3['in'], MergeTypedResponseData<R>>, BasePath>;
32
35
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>>(...handlers: [H<E2, P, I>, H<E3, P, I2>, H<E4, P, I3>, H<E5, P, I4, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S & ToSchema<M, P, I4['in'], MergeTypedResponseData<R>>, BasePath>;
36
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>>(path: P, ...handlers: [
37
+ H<E2, MergedPath, I>,
38
+ H<E3, MergedPath, I2>,
39
+ H<E4, MergedPath, I3>,
40
+ H<E5, MergedPath, I4, R>
41
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S & ToSchema<M, MergePath<BasePath, P>, I4['in'], MergeTypedResponseData<R>>, BasePath>;
33
42
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>>(...handlers: [H<E2, P, I>, H<E3, P, I2>, H<E4, P, I3>, H<E5, P, I4>, H<E6, P, I5, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S & ToSchema<M, P, I5['in'], MergeTypedResponseData<R>>, BasePath>;
43
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>>(path: P, ...handlers: [
44
+ H<E2, MergedPath, I>,
45
+ H<E3, MergedPath, I2>,
46
+ H<E4, MergedPath, I3>,
47
+ H<E5, MergedPath, I4>,
48
+ H<E6, MergedPath, I5, R>
49
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S & ToSchema<M, MergePath<BasePath, P>, I5['in'], MergeTypedResponseData<R>>, BasePath>;
34
50
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>>(...handlers: [
35
51
  H<E2, P, I>,
36
52
  H<E3, P, I2>,
@@ -39,6 +55,14 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
39
55
  H<E6, P, I5>,
40
56
  H<E7, P, I6, R>
41
57
  ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S & ToSchema<M, P, I6['in'], MergeTypedResponseData<R>>, BasePath>;
58
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>>(path: P, ...handlers: [
59
+ H<E2, MergedPath, I>,
60
+ H<E3, MergedPath, I2>,
61
+ H<E4, MergedPath, I3>,
62
+ H<E5, MergedPath, I4>,
63
+ H<E6, MergedPath, I5>,
64
+ H<E7, MergedPath, I6, R>
65
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S & ToSchema<M, MergePath<BasePath, P>, I6['in'], MergeTypedResponseData<R>>, BasePath>;
42
66
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>>(...handlers: [
43
67
  H<E2, P, I>,
44
68
  H<E3, P, I2>,
@@ -48,6 +72,15 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
48
72
  H<E7, P, I6>,
49
73
  H<E8, P, I7, R>
50
74
  ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S & ToSchema<M, P, I7['in'], MergeTypedResponseData<R>>, BasePath>;
75
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>>(path: P, ...handlers: [
76
+ H<E2, MergedPath, I>,
77
+ H<E3, MergedPath, I2>,
78
+ H<E4, MergedPath, I3>,
79
+ H<E5, MergedPath, I4>,
80
+ H<E6, MergedPath, I5>,
81
+ H<E7, MergedPath, I6>,
82
+ H<E8, MergedPath, I7, R>
83
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S & ToSchema<M, MergePath<BasePath, P>, I7['in'], MergeTypedResponseData<R>>, BasePath>;
51
84
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>>(...handlers: [
52
85
  H<E2, P, I>,
53
86
  H<E3, P, I2>,
@@ -58,6 +91,16 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
58
91
  H<E8, P, I7>,
59
92
  H<E9, P, I8, R>
60
93
  ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S & ToSchema<M, P, I8['in'], MergeTypedResponseData<R>>, BasePath>;
94
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>>(path: P, ...handlers: [
95
+ H<E2, MergedPath, I>,
96
+ H<E3, MergedPath, I2>,
97
+ H<E4, MergedPath, I3>,
98
+ H<E5, MergedPath, I4>,
99
+ H<E6, MergedPath, I5>,
100
+ H<E7, MergedPath, I6>,
101
+ H<E8, MergedPath, I7>,
102
+ H<E9, MergedPath, I8, R>
103
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S & ToSchema<M, MergePath<BasePath, P>, I8['in'], MergeTypedResponseData<R>>, BasePath>;
61
104
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = E, E10 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>>(...handlers: [
62
105
  H<E2, P, I>,
63
106
  H<E3, P, I2>,
@@ -69,6 +112,17 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
69
112
  H<E9, P, I8>,
70
113
  H<E10, P, I9, R>
71
114
  ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S & ToSchema<M, P, I9['in'], MergeTypedResponseData<R>>, BasePath>;
115
+ <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = E, E10 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>>(path: P, ...handlers: [
116
+ H<E2, MergedPath, I>,
117
+ H<E3, MergedPath, I2>,
118
+ H<E4, MergedPath, I3>,
119
+ H<E5, MergedPath, I4>,
120
+ H<E6, MergedPath, I5>,
121
+ H<E7, MergedPath, I6>,
122
+ H<E8, MergedPath, I7>,
123
+ H<E9, MergedPath, I8>,
124
+ H<E10, MergedPath, I9, R>
125
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S & ToSchema<M, MergePath<BasePath, P>, I9['in'], MergeTypedResponseData<R>>, BasePath>;
72
126
  <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8, I10 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = E, E10 extends Env = E, E11 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>>(...handlers: [
73
127
  H<E2, P, I>,
74
128
  H<E3, P, I2>,
@@ -81,62 +135,6 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
81
135
  H<E10, P, I9>,
82
136
  H<E11, P, I10, R>
83
137
  ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<M, P, I10['in'], MergeTypedResponseData<R>>, BasePath>;
84
- <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, I extends Input = BlankInput, R extends HandlerResponse<any> = any>(...handlers: H<E, P, I, R>[]): Hono<E, S & ToSchema<M, P, I['in'], MergeTypedResponseData<R>>, BasePath>;
85
- <P extends string, R extends HandlerResponse<any> = any, I extends Input = {}>(path: P): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
86
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, E2 extends Env = E>(path: P, handler: H<E2, MergedPath, I, R>): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
87
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>>(path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2, R>]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I2['in'], MergeTypedResponseData<R>>, BasePath>;
88
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>>(path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3, R>]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I3['in'], MergeTypedResponseData<R>>, BasePath>;
89
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>>(path: P, ...handlers: [
90
- H<E2, MergedPath, I>,
91
- H<E3, MergedPath, I2>,
92
- H<E4, MergedPath, I3>,
93
- H<E5, MergedPath, I4, R>
94
- ]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I4['in'], MergeTypedResponseData<R>>, BasePath>;
95
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>>(path: P, ...handlers: [
96
- H<E2, MergedPath, I>,
97
- H<E3, MergedPath, I2>,
98
- H<E4, MergedPath, I3>,
99
- H<E5, MergedPath, I4>,
100
- H<E6, MergedPath, I5, R>
101
- ]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I5['in'], MergeTypedResponseData<R>>, BasePath>;
102
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>>(path: P, ...handlers: [
103
- H<E2, MergedPath, I>,
104
- H<E3, MergedPath, I2>,
105
- H<E4, MergedPath, I3>,
106
- H<E5, MergedPath, I4>,
107
- H<E6, MergedPath, I5>,
108
- H<E7, MergedPath, I6, R>
109
- ]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I6['in'], MergeTypedResponseData<R>>, BasePath>;
110
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>>(path: P, ...handlers: [
111
- H<E2, MergedPath, I>,
112
- H<E3, MergedPath, I2>,
113
- H<E4, MergedPath, I3>,
114
- H<E5, MergedPath, I4>,
115
- H<E6, MergedPath, I5>,
116
- H<E7, MergedPath, I6>,
117
- H<E8, MergedPath, I7, R>
118
- ]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I7['in'], MergeTypedResponseData<R>>, BasePath>;
119
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>>(path: P, ...handlers: [
120
- H<E2, MergedPath, I>,
121
- H<E3, MergedPath, I2>,
122
- H<E4, MergedPath, I3>,
123
- H<E5, MergedPath, I4>,
124
- H<E6, MergedPath, I5>,
125
- H<E7, MergedPath, I6>,
126
- H<E8, MergedPath, I7>,
127
- H<E9, MergedPath, I8, R>
128
- ]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I8['in'], MergeTypedResponseData<R>>, BasePath>;
129
- <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = E, E10 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>>(path: P, ...handlers: [
130
- H<E2, MergedPath, I>,
131
- H<E3, MergedPath, I2>,
132
- H<E4, MergedPath, I3>,
133
- H<E5, MergedPath, I4>,
134
- H<E6, MergedPath, I5>,
135
- H<E7, MergedPath, I6>,
136
- H<E8, MergedPath, I7>,
137
- H<E9, MergedPath, I8>,
138
- H<E10, MergedPath, I9, R>
139
- ]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I9['in'], MergeTypedResponseData<R>>, BasePath>;
140
138
  <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8, I10 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = E, E6 extends Env = E, E7 extends Env = E, E8 extends Env = E, E9 extends Env = E, E10 extends Env = E, E11 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>>(path: P, ...handlers: [
141
139
  H<E2, MergedPath, I>,
142
140
  H<E3, MergedPath, I2>,
@@ -148,8 +146,10 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
148
146
  H<E9, MergedPath, I8>,
149
147
  H<E10, MergedPath, I9>,
150
148
  H<E11, MergedPath, I10, R>
151
- ]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I10['in'], MergeTypedResponseData<R>>, BasePath>;
149
+ ]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<M, MergePath<BasePath, P>, I10['in'], MergeTypedResponseData<R>>, BasePath>;
150
+ <P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, I extends Input = BlankInput, R extends HandlerResponse<any> = any>(...handlers: H<E, P, I, R>[]): Hono<E, S & ToSchema<M, P, I['in'], MergeTypedResponseData<R>>, BasePath>;
152
151
  <P extends string, I extends Input = BlankInput, R extends HandlerResponse<any> = any>(path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
152
+ <P extends string, R extends HandlerResponse<any> = any, I extends Input = {}>(path: P): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
153
153
  }
154
154
  export interface MiddlewareHandlerInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
155
155
  <E2 extends Env = E>(...handlers: MiddlewareHandler<E2, MergePath<BasePath, ExtractKey<S>>>[]): Hono<IntersectNonAnyTypes<[E, E2]>, S, BasePath>;
@@ -359,14 +359,14 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
359
359
  <I extends Input = BlankInput, R extends HandlerResponse<any> = any>(methods: string | string[], paths: string[], ...handlers: H<E, any, I, R>[]): Hono<E, S & ToSchema<string, string, I['in'], MergeTypedResponseData<R>>, BasePath>;
360
360
  }
361
361
  type ExtractKey<S> = S extends Record<infer Key, unknown> ? Key extends string ? Key : never : string;
362
- export type ToSchema<M extends string, P extends string, I extends Input['in'], O> = {
362
+ export type ToSchema<M extends string, P extends string, I extends Input['in'], O> = Prettify<{
363
363
  [K in P]: {
364
364
  [K2 in M as AddDollar<K2>]: {
365
365
  input: unknown extends I ? AddParam<{}, P> : AddParam<I, P>;
366
366
  output: unknown extends O ? {} : O;
367
367
  };
368
368
  };
369
- };
369
+ }>;
370
370
  export type Schema = {
371
371
  [Path: string]: {
372
372
  [Method: `$${Lowercase<string>}`]: {
@@ -377,15 +377,15 @@ export type Schema = {
377
377
  };
378
378
  };
379
379
  };
380
- type ExtractParams<Path extends string> = string extends Path ? Record<string, string> : Path extends `${infer Start}:${infer Param}/${infer Rest}` ? {
380
+ type ExtractParams<Path extends string> = string extends Path ? Record<string, string> : Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
381
381
  [K in Param | keyof ExtractParams<`/${Rest}`>]: string;
382
- } : Path extends `${infer Start}:${infer Param}` ? {
382
+ } : Path extends `${infer _Start}:${infer Param}` ? {
383
383
  [K in Param]: string;
384
384
  } : never;
385
385
  type FlattenIfIntersect<T> = T extends infer O ? {
386
386
  [K in keyof O]: O[K];
387
387
  } : never;
388
- export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> = {
388
+ export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> = Prettify<{
389
389
  [P in keyof OrigSchema as MergePath<SubPath, P & string>]: {
390
390
  [M in keyof OrigSchema[P]]: OrigSchema[P][M] extends {
391
391
  input: infer Input;
@@ -405,7 +405,7 @@ export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> =
405
405
  output: Output;
406
406
  } : never;
407
407
  };
408
- };
408
+ }>;
409
409
  export type AddParam<I, P extends string> = ParamKeys<P> extends never ? I : I extends {
410
410
  param: infer _;
411
411
  } ? I : I & {
@@ -417,8 +417,7 @@ export type TypedResponse<T = unknown> = {
417
417
  data: T;
418
418
  format: 'json';
419
419
  };
420
- type ExtractResponseData<T> = T extends Promise<infer T2> ? T2 extends TypedResponse<infer U> ? U : {} : T extends TypedResponse<infer U> ? U : {};
421
- type MergeTypedResponseData<T> = ExtractResponseData<T>;
420
+ type MergeTypedResponseData<T> = T extends Promise<infer T2> ? T2 extends TypedResponse<infer U> ? U : {} : T extends TypedResponse<infer U> ? U : {};
422
421
  export type ValidationTargets = {
423
422
  json: any;
424
423
  form: Record<string, string | File>;
@@ -23,3 +23,6 @@ export type RequiredKeysOf<BaseType extends object> = Exclude<{
23
23
  }[keyof BaseType], undefined>;
24
24
  export type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
25
25
  export type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
26
+ export type Prettify<T> = {
27
+ [K in keyof T]: T[K];
28
+ } & {};
@@ -6,6 +6,7 @@ var validator = (target, validationFunc) => {
6
6
  return async (c, next) => {
7
7
  let value = {};
8
8
  const contentType = c.req.header("Content-Type");
9
+ const bodyTypes = ["text", "arrayBuffer", "blob"];
9
10
  switch (target) {
10
11
  case "json":
11
12
  if (!contentType || !contentType.startsWith("application/json")) {
@@ -13,11 +14,19 @@ var validator = (target, validationFunc) => {
13
14
  throw new HTTPException(400, { message });
14
15
  }
15
16
  if (c.req.bodyCache.json) {
16
- value = await c.req.bodyCache.json;
17
+ value = c.req.bodyCache.json;
17
18
  break;
18
19
  }
19
20
  try {
20
- const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
21
+ let arrayBuffer = void 0;
22
+ for (const type of bodyTypes) {
23
+ const body = c.req.bodyCache[type];
24
+ if (body) {
25
+ arrayBuffer = await new Response(await body).arrayBuffer();
26
+ break;
27
+ }
28
+ }
29
+ arrayBuffer ??= await c.req.raw.arrayBuffer();
21
30
  value = await new Response(arrayBuffer).json();
22
31
  c.req.bodyCache.json = value;
23
32
  c.req.bodyCache.arrayBuffer = arrayBuffer;
@@ -27,23 +36,31 @@ var validator = (target, validationFunc) => {
27
36
  }
28
37
  break;
29
38
  case "form": {
39
+ if (!contentType) {
40
+ break;
41
+ }
30
42
  if (c.req.bodyCache.formData) {
31
43
  value = c.req.bodyCache.formData;
32
44
  break;
33
45
  }
34
46
  try {
35
- const contentType2 = c.req.header("Content-Type");
36
- if (contentType2) {
37
- const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
38
- const formData = await bufferToFormData(arrayBuffer, contentType2);
39
- const form = {};
40
- formData.forEach((value2, key) => {
41
- form[key] = value2;
42
- });
43
- value = form;
44
- c.req.bodyCache.formData = formData;
45
- c.req.bodyCache.arrayBuffer = arrayBuffer;
47
+ let arrayBuffer = void 0;
48
+ for (const type of bodyTypes) {
49
+ const body = c.req.bodyCache[type];
50
+ if (body) {
51
+ arrayBuffer = await new Response(await body).arrayBuffer();
52
+ break;
53
+ }
46
54
  }
55
+ arrayBuffer ??= await c.req.arrayBuffer();
56
+ const formData = await bufferToFormData(arrayBuffer, contentType);
57
+ const form = {};
58
+ formData.forEach((value2, key) => {
59
+ form[key] = value2;
60
+ });
61
+ value = form;
62
+ c.req.bodyCache.formData = formData;
63
+ c.req.bodyCache.arrayBuffer = arrayBuffer;
47
64
  } catch (e) {
48
65
  let message = "Malformed FormData request.";
49
66
  message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.1.2",
3
+ "version": "4.1.4",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",