hono 3.11.6 → 3.11.8
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/helper/html/index.js +2 -0
- package/dist/cjs/router/trie-router/node.js +5 -7
- package/dist/cjs/utils/html.js +14 -2
- package/dist/helper/html/index.js +2 -0
- package/dist/router/trie-router/node.js +5 -7
- package/dist/types/adapter/aws-lambda/custom-context.d.ts +1 -1
- package/dist/types/adapter/aws-lambda/handler.d.ts +2 -2
- package/dist/types/adapter/aws-lambda/types.d.ts +2 -2
- package/dist/types/adapter/bun/serve-static.d.ts +1 -1
- package/dist/types/adapter/cloudflare-pages/handler.d.ts +2 -2
- package/dist/types/adapter/cloudflare-workers/serve-static.d.ts +1 -1
- package/dist/types/adapter/cloudflare-workers/server-static-module.d.ts +1 -1
- package/dist/types/adapter/deno/serve-static.d.ts +1 -1
- package/dist/types/adapter/lambda-edge/handler.d.ts +1 -1
- package/dist/types/adapter/netlify/handler.d.ts +1 -1
- package/dist/types/client/types.d.ts +12 -12
- package/dist/types/context.d.ts +4 -4
- package/dist/types/helper/adapter/index.d.ts +1 -1
- package/dist/types/helper/testing/index.d.ts +1 -1
- package/dist/types/hono-base.d.ts +2 -2
- package/dist/types/http-exception.d.ts +1 -1
- package/dist/types/jsx/components.d.ts +2 -2
- package/dist/types/jsx/index.d.ts +3 -3
- package/dist/types/middleware/cors/index.d.ts +1 -1
- package/dist/types/middleware/etag/index.d.ts +1 -1
- package/dist/types/middleware/jsx-renderer/index.d.ts +2 -2
- package/dist/types/middleware/logger/index.d.ts +1 -1
- package/dist/types/middleware/pretty-json/index.d.ts +1 -1
- package/dist/types/middleware/secure-headers/index.d.ts +1 -1
- package/dist/types/request.d.ts +2 -2
- package/dist/types/router/reg-exp-router/node.d.ts +1 -1
- package/dist/types/router/reg-exp-router/router.d.ts +1 -1
- package/dist/types/router/reg-exp-router/trie.d.ts +1 -1
- package/dist/types/router/trie-router/node.d.ts +1 -2
- package/dist/types/router.d.ts +4 -4
- package/dist/types/types.d.ts +60 -60
- package/dist/types/utils/body.d.ts +2 -2
- package/dist/types/utils/cloudflare.d.ts +1 -1
- package/dist/types/utils/cookie.d.ts +3 -3
- package/dist/types/utils/crypto.d.ts +2 -2
- package/dist/types/utils/filepath.d.ts +1 -1
- package/dist/types/utils/html.d.ts +19 -5
- package/dist/types/utils/http-status.d.ts +1 -1
- package/dist/types/utils/jwt/jwt.d.ts +1 -1
- package/dist/types/utils/types.d.ts +15 -15
- package/dist/types/utils/url.d.ts +1 -1
- package/dist/types/validator/validator.d.ts +3 -3
- package/dist/utils/html.js +14 -2
- package/package.json +10 -19
|
@@ -32,7 +32,7 @@ class Node {
|
|
|
32
32
|
this.name = "";
|
|
33
33
|
if (method && handler) {
|
|
34
34
|
const m = {};
|
|
35
|
-
m[method] = { handler,
|
|
35
|
+
m[method] = { handler, possibleKeys: [], score: 0, name: this.name };
|
|
36
36
|
this.methods = [m];
|
|
37
37
|
}
|
|
38
38
|
this.patterns = [];
|
|
@@ -70,7 +70,6 @@ class Node {
|
|
|
70
70
|
const m = {};
|
|
71
71
|
const handlerSet = {
|
|
72
72
|
handler,
|
|
73
|
-
params: {},
|
|
74
73
|
possibleKeys,
|
|
75
74
|
name: this.name,
|
|
76
75
|
score: this.order
|
|
@@ -85,6 +84,7 @@ class Node {
|
|
|
85
84
|
const m = node.methods[i];
|
|
86
85
|
const handlerSet = m[method] || m[import_router.METHOD_NAME_ALL];
|
|
87
86
|
if (handlerSet !== void 0) {
|
|
87
|
+
handlerSet.params = {};
|
|
88
88
|
handlerSet.possibleKeys.map((key) => {
|
|
89
89
|
handlerSet.params[key] = params[key];
|
|
90
90
|
});
|
|
@@ -110,11 +110,9 @@ class Node {
|
|
|
110
110
|
if (nextNode) {
|
|
111
111
|
if (isLast === true) {
|
|
112
112
|
if (nextNode.children["*"]) {
|
|
113
|
-
handlerSets.push(
|
|
114
|
-
...this.gHSets(nextNode.children["*"], method, { ...params, ...node.params })
|
|
115
|
-
);
|
|
113
|
+
handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params));
|
|
116
114
|
}
|
|
117
|
-
handlerSets.push(...this.gHSets(nextNode, method,
|
|
115
|
+
handlerSets.push(...this.gHSets(nextNode, method, node.params));
|
|
118
116
|
} else {
|
|
119
117
|
tempNodes.push(nextNode);
|
|
120
118
|
}
|
|
@@ -124,7 +122,7 @@ class Node {
|
|
|
124
122
|
if (pattern === "*") {
|
|
125
123
|
const astNode = node.children["*"];
|
|
126
124
|
if (astNode) {
|
|
127
|
-
handlerSets.push(...this.gHSets(astNode, method,
|
|
125
|
+
handlerSets.push(...this.gHSets(astNode, method, node.params));
|
|
128
126
|
tempNodes.push(astNode);
|
|
129
127
|
}
|
|
130
128
|
continue;
|
package/dist/cjs/utils/html.js
CHANGED
|
@@ -28,16 +28,28 @@ const escapeRe = /[&<>'"]/;
|
|
|
28
28
|
const stringBufferToString = async (buffer) => {
|
|
29
29
|
let str = "";
|
|
30
30
|
const callbacks = [];
|
|
31
|
-
for (let i = buffer.length - 1;
|
|
31
|
+
for (let i = buffer.length - 1; ; i--) {
|
|
32
|
+
str += buffer[i];
|
|
33
|
+
i--;
|
|
34
|
+
if (i < 0) {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
32
37
|
let r = await buffer[i];
|
|
33
38
|
if (typeof r === "object") {
|
|
34
39
|
callbacks.push(...r.callbacks || []);
|
|
35
40
|
}
|
|
41
|
+
const isEscaped = r.isEscaped;
|
|
36
42
|
r = await (typeof r === "object" ? r.toString() : r);
|
|
37
43
|
if (typeof r === "object") {
|
|
38
44
|
callbacks.push(...r.callbacks || []);
|
|
39
45
|
}
|
|
40
|
-
|
|
46
|
+
if (r.isEscaped ?? isEscaped) {
|
|
47
|
+
str += r;
|
|
48
|
+
} else {
|
|
49
|
+
const buf = [str];
|
|
50
|
+
escapeToBuffer(r, buf);
|
|
51
|
+
str = buf[0];
|
|
52
|
+
}
|
|
41
53
|
}
|
|
42
54
|
return (0, import_html.raw)(str, callbacks);
|
|
43
55
|
};
|
|
@@ -10,7 +10,7 @@ var Node = class {
|
|
|
10
10
|
this.name = "";
|
|
11
11
|
if (method && handler) {
|
|
12
12
|
const m = {};
|
|
13
|
-
m[method] = { handler,
|
|
13
|
+
m[method] = { handler, possibleKeys: [], score: 0, name: this.name };
|
|
14
14
|
this.methods = [m];
|
|
15
15
|
}
|
|
16
16
|
this.patterns = [];
|
|
@@ -48,7 +48,6 @@ var Node = class {
|
|
|
48
48
|
const m = {};
|
|
49
49
|
const handlerSet = {
|
|
50
50
|
handler,
|
|
51
|
-
params: {},
|
|
52
51
|
possibleKeys,
|
|
53
52
|
name: this.name,
|
|
54
53
|
score: this.order
|
|
@@ -63,6 +62,7 @@ var Node = class {
|
|
|
63
62
|
const m = node.methods[i];
|
|
64
63
|
const handlerSet = m[method] || m[METHOD_NAME_ALL];
|
|
65
64
|
if (handlerSet !== void 0) {
|
|
65
|
+
handlerSet.params = {};
|
|
66
66
|
handlerSet.possibleKeys.map((key) => {
|
|
67
67
|
handlerSet.params[key] = params[key];
|
|
68
68
|
});
|
|
@@ -88,11 +88,9 @@ var Node = class {
|
|
|
88
88
|
if (nextNode) {
|
|
89
89
|
if (isLast === true) {
|
|
90
90
|
if (nextNode.children["*"]) {
|
|
91
|
-
handlerSets.push(
|
|
92
|
-
...this.gHSets(nextNode.children["*"], method, { ...params, ...node.params })
|
|
93
|
-
);
|
|
91
|
+
handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params));
|
|
94
92
|
}
|
|
95
|
-
handlerSets.push(...this.gHSets(nextNode, method,
|
|
93
|
+
handlerSets.push(...this.gHSets(nextNode, method, node.params));
|
|
96
94
|
} else {
|
|
97
95
|
tempNodes.push(nextNode);
|
|
98
96
|
}
|
|
@@ -102,7 +100,7 @@ var Node = class {
|
|
|
102
100
|
if (pattern === "*") {
|
|
103
101
|
const astNode = node.children["*"];
|
|
104
102
|
if (astNode) {
|
|
105
|
-
handlerSets.push(...this.gHSets(astNode, method,
|
|
103
|
+
handlerSets.push(...this.gHSets(astNode, method, node.params));
|
|
106
104
|
tempNodes.push(astNode);
|
|
107
105
|
}
|
|
108
106
|
continue;
|
|
@@ -83,5 +83,5 @@ export interface ALBRequestContext {
|
|
|
83
83
|
/**
|
|
84
84
|
* @deprecated Use ApiGatewayRequestContextV2 instead.
|
|
85
85
|
*/
|
|
86
|
-
export
|
|
86
|
+
export type LambdaFunctionUrlRequestContext = ApiGatewayRequestContextV2;
|
|
87
87
|
export {};
|
|
@@ -2,7 +2,7 @@ import type { Hono } from '../../hono';
|
|
|
2
2
|
import type { Env, Schema } from '../../types';
|
|
3
3
|
import type { ApiGatewayRequestContext, ApiGatewayRequestContextV2, ALBRequestContext } from './custom-context';
|
|
4
4
|
import type { LambdaContext } from './types';
|
|
5
|
-
export
|
|
5
|
+
export type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent;
|
|
6
6
|
export interface APIGatewayProxyEventV2 {
|
|
7
7
|
version: string;
|
|
8
8
|
routeKey: string;
|
|
@@ -62,7 +62,7 @@ export interface APIGatewayProxyResult {
|
|
|
62
62
|
};
|
|
63
63
|
isBase64Encoded: boolean;
|
|
64
64
|
}
|
|
65
|
-
export declare const streamHandle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => import("./types").Handler
|
|
65
|
+
export declare const streamHandle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => import("./types").Handler;
|
|
66
66
|
/**
|
|
67
67
|
* Accepts events from API Gateway/ELB(`APIGatewayProxyEvent`) and directly through Function Url(`APIGatewayProxyEventV2`)
|
|
68
68
|
*/
|
|
@@ -38,6 +38,6 @@ export interface LambdaContext {
|
|
|
38
38
|
clientContext?: ClientContext | undefined;
|
|
39
39
|
getRemainingTimeInMillis(): number;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
export
|
|
41
|
+
type Callback<TResult = any> = (error?: Error | string | null, result?: TResult) => void;
|
|
42
|
+
export type Handler<TEvent = any, TResult = any> = (event: TEvent, context: LambdaContext, callback: Callback<TResult>) => void | Promise<TResult>;
|
|
43
43
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from '../../hono';
|
|
2
2
|
import type { Env, MiddlewareHandler } from '../../types';
|
|
3
|
-
|
|
4
|
-
export
|
|
3
|
+
type Params<P extends string = any> = Record<P, string | string[]>;
|
|
4
|
+
export type EventContext<Env = {}, P extends string = any, Data = {}> = {
|
|
5
5
|
request: Request;
|
|
6
6
|
functionPath: string;
|
|
7
7
|
waitUntil: (promise: Promise<unknown>) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ServeStaticOptions } from './serve-static';
|
|
2
|
-
declare const module: (options?: ServeStaticOptions) => import("../..").MiddlewareHandler
|
|
2
|
+
declare const module: (options?: ServeStaticOptions) => import("../..").MiddlewareHandler;
|
|
3
3
|
export { module as serveStatic };
|
|
@@ -53,7 +53,7 @@ interface CloudFrontEvent {
|
|
|
53
53
|
export interface CloudFrontEdgeEvent {
|
|
54
54
|
Records: CloudFrontEvent[];
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
type CloudFrontContext = {};
|
|
57
57
|
export interface Callback {
|
|
58
58
|
(err: Error | null, result?: CloudFrontRequest | CloudFrontResult): void;
|
|
59
59
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Hono } from '../hono';
|
|
2
2
|
import type { Schema } from '../types';
|
|
3
3
|
import type { HasRequiredKeys } from '../utils/types';
|
|
4
|
-
|
|
5
|
-
export
|
|
4
|
+
type HonoRequest = typeof Hono.prototype['request'];
|
|
5
|
+
export type ClientRequestOptions<T = unknown> = keyof T extends never ? {
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
7
|
fetch?: typeof fetch | HonoRequest;
|
|
8
8
|
} : {
|
|
9
9
|
headers: T;
|
|
10
10
|
fetch?: typeof fetch | HonoRequest;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
export type ClientRequest<S extends Schema> = {
|
|
13
13
|
[M in keyof S]: S[M] extends {
|
|
14
14
|
input: infer R;
|
|
15
15
|
output: infer O;
|
|
@@ -17,7 +17,7 @@ declare type ClientRequest<S extends Schema> = {
|
|
|
17
17
|
} & {
|
|
18
18
|
$url: () => URL;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type BlankRecordToNever<T> = T extends any ? (keyof T extends never ? never : T) : never;
|
|
21
21
|
export interface ClientResponse<T> {
|
|
22
22
|
ok: boolean;
|
|
23
23
|
status: number;
|
|
@@ -34,22 +34,22 @@ export interface ClientResponse<T> {
|
|
|
34
34
|
}
|
|
35
35
|
export interface Response extends ClientResponse<unknown> {
|
|
36
36
|
}
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
|
|
37
|
+
export type Fetch<T> = (args?: InferRequestType<T>, opt?: ClientRequestOptions) => Promise<ClientResponse<InferResponseType<T>>>;
|
|
38
|
+
export type InferResponseType<T> = T extends (args: any | undefined, options: any | undefined) => Promise<ClientResponse<infer O>> ? O : never;
|
|
39
|
+
export type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never;
|
|
40
|
+
export type InferRequestOptionsType<T> = T extends (args: any, options: infer R) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never;
|
|
41
|
+
type PathToChain<Path extends string, E extends Schema, Original extends string = ''> = Path extends `/${infer P}` ? PathToChain<P, E, Path> : Path extends `${infer P}/${infer R}` ? {
|
|
42
42
|
[K in P]: PathToChain<R, E, Original>;
|
|
43
43
|
} : {
|
|
44
44
|
[K in Path extends '' ? 'index' : Path]: ClientRequest<E extends Record<string, unknown> ? E[Original] : never>;
|
|
45
45
|
};
|
|
46
|
-
export
|
|
47
|
-
export
|
|
46
|
+
export type Client<T> = T extends Hono<any, infer S, any> ? S extends Record<infer K, Schema> ? K extends string ? PathToChain<K, S> : never : never : never;
|
|
47
|
+
export type Callback = (opts: CallbackOptions) => unknown;
|
|
48
48
|
interface CallbackOptions {
|
|
49
49
|
path: string[];
|
|
50
50
|
args: any[];
|
|
51
51
|
}
|
|
52
|
-
export
|
|
52
|
+
export type ObjectType<T = unknown> = {
|
|
53
53
|
[key: string]: T;
|
|
54
54
|
};
|
|
55
55
|
export {};
|
package/dist/types/context.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import type { CookieOptions } from './utils/cookie';
|
|
|
5
5
|
import type { StatusCode } from './utils/http-status';
|
|
6
6
|
import { StreamingApi } from './utils/stream';
|
|
7
7
|
import type { JSONValue, InterfaceToType, JSONParsed } from './utils/types';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type HeaderRecord = Record<string, string | string[]>;
|
|
9
|
+
type Data = string | ArrayBuffer | ReadableStream;
|
|
10
10
|
export interface ExecutionContext {
|
|
11
11
|
waitUntil(promise: Promise<unknown>): void;
|
|
12
12
|
passThroughOnException(): void;
|
|
@@ -18,7 +18,7 @@ export interface ContextRenderer {
|
|
|
18
18
|
interface DefaultRenderer {
|
|
19
19
|
(content: string | Promise<string>): Response | Promise<Response>;
|
|
20
20
|
}
|
|
21
|
-
export
|
|
21
|
+
export type Renderer = ContextRenderer extends Function ? ContextRenderer : DefaultRenderer;
|
|
22
22
|
interface Get<E extends Env> {
|
|
23
23
|
<Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key];
|
|
24
24
|
<Key extends keyof E['Variables']>(key: Key): E['Variables'][Key];
|
|
@@ -45,7 +45,7 @@ interface HTMLRespond {
|
|
|
45
45
|
(html: string | Promise<string>, status?: StatusCode, headers?: HeaderRecord): Response | Promise<Response>;
|
|
46
46
|
(html: string | Promise<string>, init?: ResponseInit): Response | Promise<Response>;
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
type ContextOptions<E extends Env> = {
|
|
49
49
|
env: E['Bindings'];
|
|
50
50
|
executionCtx?: FetchEventLike | ExecutionContext | undefined;
|
|
51
51
|
notFoundHandler?: NotFoundHandler<E>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Context } from '../../context';
|
|
2
|
-
export
|
|
2
|
+
export type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other';
|
|
3
3
|
export declare const env: <T extends Record<string, unknown>, C extends Context<any, any, {}> = Context<{}, any, {}>>(c: C, runtime?: Runtime) => T & C["env"];
|
|
4
4
|
export declare const getRuntimeKey: () => "other" | "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "lagon";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Hono } from '../../hono';
|
|
2
|
-
|
|
2
|
+
type ExtractEnv<T> = T extends Hono<infer E, any, any> ? E : never;
|
|
3
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
4
|
export {};
|
|
@@ -2,10 +2,10 @@ import { Context } from './context';
|
|
|
2
2
|
import type { ExecutionContext } from './context';
|
|
3
3
|
import type { Router } from './router';
|
|
4
4
|
import type { Env, ErrorHandler, H, HandlerInterface, MiddlewareHandlerInterface, NotFoundHandler, OnHandlerInterface, MergePath, MergeSchemaPath, FetchEventLike, Schema, RouterRoute } from './types';
|
|
5
|
-
|
|
5
|
+
type GetPath<E extends Env> = (request: Request, options?: {
|
|
6
6
|
env?: E['Bindings'];
|
|
7
7
|
}) => string;
|
|
8
|
-
export
|
|
8
|
+
export type HonoOptions<E extends Env> = {
|
|
9
9
|
strict?: boolean;
|
|
10
10
|
router?: Router<[H, RouterRoute]>;
|
|
11
11
|
getPath?: GetPath<E>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { HtmlEscapedString } from '../utils/html';
|
|
2
2
|
import type { FC, Child } from './index';
|
|
3
3
|
export declare const childrenToString: (children: Child[]) => Promise<HtmlEscapedString[]>;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type ErrorHandler = (error: Error) => void;
|
|
5
|
+
type FallbackRender = (error: Error) => Child;
|
|
6
6
|
/**
|
|
7
7
|
* @experimental
|
|
8
8
|
* `ErrorBoundary` is an experimental feature.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../utils/html';
|
|
2
2
|
import type { IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements';
|
|
3
3
|
export { ErrorBoundary } from './components';
|
|
4
|
-
|
|
4
|
+
type Props = Record<string, any>;
|
|
5
5
|
declare global {
|
|
6
6
|
namespace JSX {
|
|
7
7
|
type Element = HtmlEscapedString | Promise<HtmlEscapedString>;
|
|
@@ -13,7 +13,7 @@ declare global {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
export
|
|
16
|
+
export type Child = string | Promise<string> | number | JSXNode | Child[];
|
|
17
17
|
export declare class JSXNode implements HtmlEscaped {
|
|
18
18
|
tag: string | Function;
|
|
19
19
|
props: Props;
|
|
@@ -25,7 +25,7 @@ export declare class JSXNode implements HtmlEscaped {
|
|
|
25
25
|
}
|
|
26
26
|
export { jsxFn as jsx };
|
|
27
27
|
declare const jsxFn: (tag: string | Function, props: Props, ...children: (string | HtmlEscapedString)[]) => JSXNode;
|
|
28
|
-
export
|
|
28
|
+
export type FC<T = Props> = (props: T & {
|
|
29
29
|
children?: Child;
|
|
30
30
|
}) => HtmlEscapedString | Promise<HtmlEscapedString>;
|
|
31
31
|
export declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
|
|
@@ -2,8 +2,8 @@ import type { Context, Renderer } from '../../context';
|
|
|
2
2
|
import type { FC } from '../../jsx';
|
|
3
3
|
import type { Env, Input, MiddlewareHandler } from '../../types';
|
|
4
4
|
export declare const RequestContext: import("../../jsx").Context<Context<any, any, {}> | null>;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props] ? Props : unknown;
|
|
6
|
+
type RendererOptions = {
|
|
7
7
|
docType?: boolean | string;
|
|
8
8
|
stream?: boolean | Record<string, string>;
|
|
9
9
|
};
|
|
@@ -35,7 +35,7 @@ interface ReportingEndpointOptions {
|
|
|
35
35
|
name: string;
|
|
36
36
|
url: string;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
type overridableHeader = boolean | string;
|
|
39
39
|
interface SecureHeadersOptions {
|
|
40
40
|
contentSecurityPolicy?: ContentSecurityPolicyOptions;
|
|
41
41
|
crossOriginEmbedderPolicy?: overridableHeader;
|
package/dist/types/request.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import type { Input, InputToDataByTarget, ParamKeys, ParamKeyToRecord, RemoveQue
|
|
|
3
3
|
import type { BodyData, ParseBodyOptions } from './utils/body';
|
|
4
4
|
import type { Cookie } from './utils/cookie';
|
|
5
5
|
import type { UnionToIntersection } from './utils/types';
|
|
6
|
-
|
|
6
|
+
type Body = {
|
|
7
7
|
json: any;
|
|
8
8
|
text: string;
|
|
9
9
|
arrayBuffer: ArrayBuffer;
|
|
10
10
|
blob: Blob;
|
|
11
11
|
formData: FormData;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type BodyCache = Partial<Body & {
|
|
14
14
|
parsedBody: BodyData;
|
|
15
15
|
}>;
|
|
16
16
|
export declare class HonoRequest<P extends string = '/', I extends Input['out'] = {}> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Router, Result } from '../../router';
|
|
2
|
-
|
|
2
|
+
type HandlerWithMetadata<T> = [T, number];
|
|
3
3
|
export declare class RegExpRouter<T> implements Router<T> {
|
|
4
4
|
name: string;
|
|
5
5
|
middleware?: Record<string, Record<string, HandlerWithMetadata<T>[]>>;
|
package/dist/types/router.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ export interface Router<T> {
|
|
|
7
7
|
add(method: string, path: string, handler: T): void;
|
|
8
8
|
match(method: string, path: string): Result<T>;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
10
|
+
export type ParamIndexMap = Record<string, number>;
|
|
11
|
+
export type ParamStash = string[];
|
|
12
|
+
export type Params = Record<string, string>;
|
|
13
|
+
export type Result<T> = [[T, ParamIndexMap][], ParamStash] | [[T, Params][]];
|
|
14
14
|
export declare class UnsupportedPathError extends Error {
|
|
15
15
|
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Context } from './context';
|
|
2
2
|
import type { Hono } from './hono';
|
|
3
3
|
import type { IntersectNonAnyTypes, UnionToIntersection } from './utils/types';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
4
|
+
export type Bindings = Record<string, unknown>;
|
|
5
|
+
export type Variables = Record<string, unknown>;
|
|
6
|
+
export type Env = {
|
|
7
7
|
Bindings?: Bindings;
|
|
8
8
|
Variables?: Variables;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
11
|
-
export
|
|
10
|
+
export type Next = () => Promise<void>;
|
|
11
|
+
export type Input = {
|
|
12
12
|
in?: Partial<ValidationTargets>;
|
|
13
13
|
out?: Partial<{
|
|
14
14
|
[K in keyof ValidationTargets]: unknown;
|
|
@@ -19,12 +19,12 @@ export interface RouterRoute {
|
|
|
19
19
|
method: string;
|
|
20
20
|
handler: H;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
22
|
+
export type HandlerResponse<O> = Response | TypedResponse<O> | Promise<Response | TypedResponse<O>>;
|
|
23
|
+
export type Handler<E extends Env = any, P extends string = any, I extends Input = Input, R extends HandlerResponse<any> = any> = (c: Context<E, P, I>, next: Next) => R;
|
|
24
|
+
export type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void>;
|
|
25
|
+
export type H<E extends Env = any, P extends string = any, I extends Input = {}, R extends HandlerResponse<any> = any> = Handler<E, P, I, R> | MiddlewareHandler<E, P, I>;
|
|
26
|
+
export type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response>;
|
|
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 = {}, 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
30
|
<P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, I extends Input = {}, 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>;
|
|
@@ -83,22 +83,22 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
|
|
|
83
83
|
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<M, P, I10['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
84
84
|
<P extends string = ExtractKey<S> extends never ? BasePath : ExtractKey<S>, I extends Input = {}, R extends HandlerResponse<any> = any>(...handlers: H<E, P, I, R>[]): Hono<E, S & ToSchema<M, P, I['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
85
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 = {}, E2 extends Env = E>(path: P, handler: H<E2, MergedPath, I, R>): Hono<IntersectNonAnyTypes<[E, E2]>, S & ToSchema<M,
|
|
87
|
-
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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,
|
|
88
|
-
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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,
|
|
86
|
+
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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>;
|
|
87
|
+
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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>;
|
|
88
|
+
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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>;
|
|
89
89
|
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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
90
|
H<E2, MergedPath, I>,
|
|
91
91
|
H<E3, MergedPath, I2>,
|
|
92
92
|
H<E4, MergedPath, I3>,
|
|
93
93
|
H<E5, MergedPath, I4, R>
|
|
94
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S & ToSchema<M,
|
|
94
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S & ToSchema<M, MergePath<BasePath, P>, I4['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
95
95
|
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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
96
|
H<E2, MergedPath, I>,
|
|
97
97
|
H<E3, MergedPath, I2>,
|
|
98
98
|
H<E4, MergedPath, I3>,
|
|
99
99
|
H<E5, MergedPath, I4>,
|
|
100
100
|
H<E6, MergedPath, I5, R>
|
|
101
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S & ToSchema<M,
|
|
101
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S & ToSchema<M, MergePath<BasePath, P>, I5['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
102
102
|
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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
103
|
H<E2, MergedPath, I>,
|
|
104
104
|
H<E3, MergedPath, I2>,
|
|
@@ -106,7 +106,7 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
|
|
|
106
106
|
H<E5, MergedPath, I4>,
|
|
107
107
|
H<E6, MergedPath, I5>,
|
|
108
108
|
H<E7, MergedPath, I6, R>
|
|
109
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S & ToSchema<M,
|
|
109
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S & ToSchema<M, MergePath<BasePath, P>, I6['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
110
110
|
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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
111
|
H<E2, MergedPath, I>,
|
|
112
112
|
H<E3, MergedPath, I2>,
|
|
@@ -115,7 +115,7 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
|
|
|
115
115
|
H<E6, MergedPath, I5>,
|
|
116
116
|
H<E7, MergedPath, I6>,
|
|
117
117
|
H<E8, MergedPath, I7, R>
|
|
118
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S & ToSchema<M,
|
|
118
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S & ToSchema<M, MergePath<BasePath, P>, I7['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
119
119
|
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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
120
|
H<E2, MergedPath, I>,
|
|
121
121
|
H<E3, MergedPath, I2>,
|
|
@@ -125,7 +125,7 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
|
|
|
125
125
|
H<E7, MergedPath, I6>,
|
|
126
126
|
H<E8, MergedPath, I7>,
|
|
127
127
|
H<E9, MergedPath, I8, R>
|
|
128
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S & ToSchema<M,
|
|
128
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S & ToSchema<M, MergePath<BasePath, P>, I8['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
129
129
|
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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
130
|
H<E2, MergedPath, I>,
|
|
131
131
|
H<E3, MergedPath, I2>,
|
|
@@ -136,7 +136,7 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
|
|
|
136
136
|
H<E8, MergedPath, I7>,
|
|
137
137
|
H<E9, MergedPath, I8>,
|
|
138
138
|
H<E10, MergedPath, I9, R>
|
|
139
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S & ToSchema<M,
|
|
139
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S & ToSchema<M, MergePath<BasePath, P>, I9['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
140
140
|
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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
141
|
H<E2, MergedPath, I>,
|
|
142
142
|
H<E3, MergedPath, I2>,
|
|
@@ -148,7 +148,7 @@ export interface HandlerInterface<E extends Env = Env, M extends string = string
|
|
|
148
148
|
H<E9, MergedPath, I8>,
|
|
149
149
|
H<E10, MergedPath, I9>,
|
|
150
150
|
H<E11, MergedPath, I10, R>
|
|
151
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<M,
|
|
151
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<M, MergePath<BasePath, P>, I10['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
152
152
|
<P extends string, I extends Input = {}, 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>;
|
|
153
153
|
}
|
|
154
154
|
export interface MiddlewareHandlerInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
|
|
@@ -156,22 +156,22 @@ export interface MiddlewareHandlerInterface<E extends Env = Env, S extends Schem
|
|
|
156
156
|
<P extends string, E2 extends Env = E>(path: P, ...handlers: MiddlewareHandler<E2, MergePath<BasePath, P>>[]): Hono<E, S, BasePath>;
|
|
157
157
|
}
|
|
158
158
|
export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
|
|
159
|
-
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, E2 extends Env = E>(method: M, path: P, handler: H<E2, MergedPath, I, R>): Hono<IntersectNonAnyTypes<[E, E2]>, S & ToSchema<M,
|
|
160
|
-
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>>(method: M, path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3]>, S & ToSchema<M,
|
|
161
|
-
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>>(method: M, 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,
|
|
159
|
+
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, E2 extends Env = E>(method: M, path: P, handler: H<E2, MergedPath, I, R>): Hono<IntersectNonAnyTypes<[E, E2]>, S & ToSchema<M, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
160
|
+
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>>(method: M, 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>;
|
|
161
|
+
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>>(method: M, 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>;
|
|
162
162
|
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(method: M, path: P, ...handlers: [
|
|
163
163
|
H<E2, MergedPath, I>,
|
|
164
164
|
H<E3, MergedPath, I2>,
|
|
165
165
|
H<E4, MergedPath, I3>,
|
|
166
166
|
H<E5, MergedPath, I4, R>
|
|
167
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S & ToSchema<M,
|
|
167
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S & ToSchema<M, MergePath<BasePath, P>, I4['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
168
168
|
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(method: M, path: P, ...handlers: [
|
|
169
169
|
H<E2, MergedPath, I>,
|
|
170
170
|
H<E3, MergedPath, I2>,
|
|
171
171
|
H<E4, MergedPath, I3>,
|
|
172
172
|
H<E5, MergedPath, I4>,
|
|
173
173
|
H<E6, MergedPath, I5, R>
|
|
174
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S & ToSchema<M,
|
|
174
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S & ToSchema<M, MergePath<BasePath, P>, I5['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
175
175
|
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(method: M, path: P, ...handlers: [
|
|
176
176
|
H<E2, MergedPath, I>,
|
|
177
177
|
H<E3, MergedPath, I2>,
|
|
@@ -179,7 +179,7 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
179
179
|
H<E5, MergedPath, I4>,
|
|
180
180
|
H<E6, MergedPath, I5>,
|
|
181
181
|
H<E7, MergedPath, I6, R>
|
|
182
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S & ToSchema<M,
|
|
182
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S & ToSchema<M, MergePath<BasePath, P>, I6['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
183
183
|
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(method: M, path: P, ...handlers: [
|
|
184
184
|
H<E2, MergedPath, I>,
|
|
185
185
|
H<E3, MergedPath, I2>,
|
|
@@ -188,7 +188,7 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
188
188
|
H<E6, MergedPath, I5>,
|
|
189
189
|
H<E7, MergedPath, I6>,
|
|
190
190
|
H<E8, MergedPath, I7, R>
|
|
191
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S & ToSchema<M,
|
|
191
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S & ToSchema<M, MergePath<BasePath, P>, I7['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
192
192
|
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(method: M, path: P, ...handlers: [
|
|
193
193
|
H<E2, MergedPath, I>,
|
|
194
194
|
H<E3, MergedPath, I2>,
|
|
@@ -198,7 +198,7 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
198
198
|
H<E7, MergedPath, I6>,
|
|
199
199
|
H<E8, MergedPath, I7>,
|
|
200
200
|
H<E9, MergedPath, I8, R>
|
|
201
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S & ToSchema<M,
|
|
201
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S & ToSchema<M, MergePath<BasePath, P>, I8['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
202
202
|
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(method: M, path: P, ...handlers: [
|
|
203
203
|
H<E2, MergedPath, I>,
|
|
204
204
|
H<E3, MergedPath, I2>,
|
|
@@ -209,7 +209,7 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
209
209
|
H<E8, MergedPath, I7>,
|
|
210
210
|
H<E9, MergedPath, I8>,
|
|
211
211
|
H<E10, MergedPath, I9, R>
|
|
212
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S & ToSchema<M,
|
|
212
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S & ToSchema<M, MergePath<BasePath, P>, I9['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
213
213
|
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, I extends Input = {}, 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]>>(method: M, path: P, ...handlers: [
|
|
214
214
|
H<E2, MergedPath, I>,
|
|
215
215
|
H<E3, MergedPath, I2>,
|
|
@@ -221,24 +221,24 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
221
221
|
H<E9, MergedPath, I8>,
|
|
222
222
|
H<E10, MergedPath, I9>,
|
|
223
223
|
H<E11, MergedPath, I10>
|
|
224
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<M,
|
|
224
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<M, MergePath<BasePath, P>, I10['in'], MergeTypedResponseData<HandlerResponse<any>>>, BasePath>;
|
|
225
225
|
<M extends string, P extends string, R extends HandlerResponse<any> = any, I extends Input = {}>(method: M, path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): Hono<E, S & ToSchema<M, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
226
|
-
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, E2 extends Env = E>(methods: Ms, path: P, handler: H<E2, MergedPath, I, R>): Hono<IntersectNonAnyTypes<[E, E2]>, S & ToSchema<Ms[number],
|
|
227
|
-
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>>(methods: Ms, path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3]>, S & ToSchema<Ms[number],
|
|
228
|
-
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>>(methods: Ms, path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4]>, S & ToSchema<Ms[number],
|
|
226
|
+
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, E2 extends Env = E>(methods: Ms, path: P, handler: H<E2, MergedPath, I, R>): Hono<IntersectNonAnyTypes<[E, E2]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
227
|
+
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>>(methods: Ms, path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I2['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
228
|
+
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>>(methods: Ms, path: P, ...handlers: [H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3, R>]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I3['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
229
229
|
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(methods: Ms, path: P, ...handlers: [
|
|
230
230
|
H<E2, MergedPath, I>,
|
|
231
231
|
H<E3, MergedPath, I2>,
|
|
232
232
|
H<E4, MergedPath, I3>,
|
|
233
233
|
H<E5, MergedPath, I4, R>
|
|
234
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S & ToSchema<Ms[number],
|
|
234
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I4['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
235
235
|
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(methods: Ms, path: P, ...handlers: [
|
|
236
236
|
H<E2, MergedPath, I>,
|
|
237
237
|
H<E3, MergedPath, I2>,
|
|
238
238
|
H<E4, MergedPath, I3>,
|
|
239
239
|
H<E5, MergedPath, I4>,
|
|
240
240
|
H<E6, MergedPath, I5, R>
|
|
241
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S & ToSchema<Ms[number],
|
|
241
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I5['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
242
242
|
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(methods: Ms, path: P, ...handlers: [
|
|
243
243
|
H<E2, MergedPath, I>,
|
|
244
244
|
H<E3, MergedPath, I2>,
|
|
@@ -246,7 +246,7 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
246
246
|
H<E5, MergedPath, I4>,
|
|
247
247
|
H<E6, MergedPath, I5>,
|
|
248
248
|
H<E7, MergedPath, I6, R>
|
|
249
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S & ToSchema<Ms[number],
|
|
249
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I6['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
250
250
|
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(methods: Ms, path: P, ...handlers: [
|
|
251
251
|
H<E2, MergedPath, I>,
|
|
252
252
|
H<E3, MergedPath, I2>,
|
|
@@ -255,7 +255,7 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
255
255
|
H<E6, MergedPath, I5>,
|
|
256
256
|
H<E7, MergedPath, I6>,
|
|
257
257
|
H<E8, MergedPath, I7, R>
|
|
258
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S & ToSchema<Ms[number],
|
|
258
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I7['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
259
259
|
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = {}, 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]>>(methods: Ms, path: P, ...handlers: [
|
|
260
260
|
H<E2, MergedPath, I>,
|
|
261
261
|
H<E3, MergedPath, I2>,
|
|
@@ -265,7 +265,7 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
265
265
|
H<E7, MergedPath, I6>,
|
|
266
266
|
H<E8, MergedPath, I7>,
|
|
267
267
|
H<E9, MergedPath, I8, R>
|
|
268
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S & ToSchema<Ms[number],
|
|
268
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I8['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
269
269
|
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, I extends Input = {}, 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]>>(methods: Ms, path: P, ...handlers: [
|
|
270
270
|
H<E2, MergedPath, I>,
|
|
271
271
|
H<E3, MergedPath, I2>,
|
|
@@ -276,7 +276,7 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
276
276
|
H<E8, MergedPath, I7>,
|
|
277
277
|
H<E9, MergedPath, I8>,
|
|
278
278
|
H<E10, MergedPath, I9>
|
|
279
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S & ToSchema<Ms[number],
|
|
279
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I9['in'], MergeTypedResponseData<HandlerResponse<any>>>, BasePath>;
|
|
280
280
|
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, I extends Input = {}, 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]>>(methods: Ms, path: P, ...handlers: [
|
|
281
281
|
H<E2, MergedPath, I>,
|
|
282
282
|
H<E3, MergedPath, I2>,
|
|
@@ -288,11 +288,11 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
288
288
|
H<E9, MergedPath, I8>,
|
|
289
289
|
H<E10, MergedPath, I9>,
|
|
290
290
|
H<E11, MergedPath, I10>
|
|
291
|
-
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<Ms[number],
|
|
291
|
+
]): Hono<IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I10['in'], MergeTypedResponseData<HandlerResponse<any>>>, BasePath>;
|
|
292
292
|
<P extends string, R extends HandlerResponse<any> = any, I extends Input = {}>(methods: string[], path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): Hono<E, S & ToSchema<string, MergePath<BasePath, P>, I['in'], MergeTypedResponseData<R>>, BasePath>;
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
export
|
|
294
|
+
type ExtractKey<S> = S extends Record<infer Key, unknown> ? Key extends string ? Key : never : string;
|
|
295
|
+
export type ToSchema<M extends string, P extends string, I extends Input['in'], O> = {
|
|
296
296
|
[K in P]: {
|
|
297
297
|
[K2 in M as AddDollar<K2>]: {
|
|
298
298
|
input: unknown extends I ? AddParam<{}, P> : AddParam<I, P>;
|
|
@@ -300,7 +300,7 @@ export declare type ToSchema<M extends string, P extends string, I extends Input
|
|
|
300
300
|
};
|
|
301
301
|
};
|
|
302
302
|
};
|
|
303
|
-
export
|
|
303
|
+
export type Schema = {
|
|
304
304
|
[Path: string]: {
|
|
305
305
|
[Method: `$${Lowercase<string>}`]: {
|
|
306
306
|
input: Partial<ValidationTargets> & {
|
|
@@ -310,21 +310,21 @@ export declare type Schema = {
|
|
|
310
310
|
};
|
|
311
311
|
};
|
|
312
312
|
};
|
|
313
|
-
export
|
|
313
|
+
export type MergeSchemaPath<OrigSchema, SubPath extends string> = {
|
|
314
314
|
[K in keyof OrigSchema as `${MergePath<SubPath, K & string>}`]: OrigSchema[K];
|
|
315
315
|
};
|
|
316
|
-
export
|
|
316
|
+
export type AddParam<I, P extends string> = ParamKeys<P> extends never ? I : I & {
|
|
317
317
|
param: UnionToIntersection<ParamKeyToRecord<ParamKeys<P>>>;
|
|
318
318
|
};
|
|
319
|
-
|
|
320
|
-
export
|
|
321
|
-
export
|
|
319
|
+
type AddDollar<T extends string> = `$${Lowercase<T>}`;
|
|
320
|
+
export type MergePath<A extends string, B extends string> = A extends '' ? B : A extends '/' ? B : A extends `${infer P}/` ? B extends `/${infer Q}` ? `${P}/${Q}` : `${P}/${B}` : B extends `/${infer Q}` ? Q extends '' ? A : `${A}/${Q}` : `${A}/${B}`;
|
|
321
|
+
export type TypedResponse<T = unknown> = {
|
|
322
322
|
data: T;
|
|
323
323
|
format: 'json';
|
|
324
324
|
};
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
export
|
|
325
|
+
type ExtractResponseData<T> = T extends Promise<infer T2> ? T2 extends TypedResponse<infer U> ? U : {} : T extends TypedResponse<infer U> ? U : {};
|
|
326
|
+
type MergeTypedResponseData<T> = ExtractResponseData<T>;
|
|
327
|
+
export type ValidationTargets = {
|
|
328
328
|
json: any;
|
|
329
329
|
form: Record<string, string | File>;
|
|
330
330
|
query: Record<string, string | string[]>;
|
|
@@ -333,18 +333,18 @@ export declare type ValidationTargets = {
|
|
|
333
333
|
header: Record<string, string>;
|
|
334
334
|
cookie: Record<string, string>;
|
|
335
335
|
};
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
export
|
|
339
|
-
export
|
|
336
|
+
type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Name}{${infer Rest}` ? Rest extends `${infer _Pattern}?` ? `${Name}?` : Name : NameWithPattern;
|
|
337
|
+
type ParamKey<Component> = Component extends `:${infer NameWithPattern}` ? ParamKeyName<NameWithPattern> : never;
|
|
338
|
+
export type ParamKeys<Path> = Path extends `${infer Component}/${infer Rest}` ? ParamKey<Component> | ParamKeys<Rest> : ParamKey<Path>;
|
|
339
|
+
export type ParamKeyToRecord<T extends string> = T extends `${infer R}?` ? Record<R, string | undefined> : {
|
|
340
340
|
[K in T]: string;
|
|
341
341
|
};
|
|
342
|
-
export
|
|
342
|
+
export type InputToDataByTarget<T extends Input['out'], Target extends keyof ValidationTargets> = T extends {
|
|
343
343
|
[K in Target]: infer R;
|
|
344
344
|
} ? R : never;
|
|
345
|
-
export
|
|
346
|
-
export
|
|
347
|
-
export
|
|
345
|
+
export type RemoveQuestion<T> = T extends `${infer R}?` ? R : T;
|
|
346
|
+
export type UndefinedIfHavingQuestion<T> = T extends `${infer _}?` ? string | undefined : string;
|
|
347
|
+
export type ExtractSchema<T> = UnionToIntersection<T extends Hono<infer _, infer S, any> ? S : never>;
|
|
348
348
|
export declare abstract class FetchEventLike {
|
|
349
349
|
abstract readonly request: Request;
|
|
350
350
|
abstract respondWith(promise: Response | Promise<Response>): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HonoRequest } from '../request';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type BodyData = Record<string, string | File | (string | File)[]>;
|
|
3
|
+
export type ParseBodyOptions = {
|
|
4
4
|
/**
|
|
5
5
|
* Parse all fields with multiple values should be parsed as an array.
|
|
6
6
|
* @default false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export type Cookie = Record<string, string>;
|
|
2
|
+
export type SignedCookie = Record<string, string | false>;
|
|
3
|
+
export type CookieOptions = {
|
|
4
4
|
domain?: string;
|
|
5
5
|
expires?: Date;
|
|
6
6
|
httpOnly?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type Algorithm = {
|
|
2
2
|
name: string;
|
|
3
3
|
alias: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type Data = string | boolean | number | object | ArrayBufferView | ArrayBuffer | ReadableStream;
|
|
6
6
|
export declare const sha256: (data: Data) => Promise<string | null>;
|
|
7
7
|
export declare const sha1: (data: Data) => Promise<string | null>;
|
|
8
8
|
export declare const md5: (data: Data) => Promise<string | null>;
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
type HtmlEscapedCallbackOpts = {
|
|
2
2
|
error?: Error;
|
|
3
3
|
buffer?: [string];
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type HtmlEscapedCallback = (opts: HtmlEscapedCallbackOpts) => Promise<string>;
|
|
6
|
+
export type HtmlEscaped = {
|
|
7
7
|
isEscaped: true;
|
|
8
8
|
callbacks?: HtmlEscapedCallback[];
|
|
9
9
|
};
|
|
10
|
-
export
|
|
11
|
-
|
|
10
|
+
export type HtmlEscapedString = string & HtmlEscaped;
|
|
11
|
+
/**
|
|
12
|
+
* StringBuffer contains string and Promise<string> alternately
|
|
13
|
+
* The length of the array will be odd, the odd numbered element will be a string,
|
|
14
|
+
* and the even numbered element will be a Promise<string>.
|
|
15
|
+
* When concatenating into a single string, it must be processed from the tail.
|
|
16
|
+
* @example
|
|
17
|
+
* [
|
|
18
|
+
* 'framework.',
|
|
19
|
+
* Promise.resolve('ultra fast'),
|
|
20
|
+
* 'a ',
|
|
21
|
+
* Promise.resolve('is '),
|
|
22
|
+
* 'Hono',
|
|
23
|
+
* ]
|
|
24
|
+
*/
|
|
25
|
+
export type StringBuffer = (string | Promise<string>)[];
|
|
12
26
|
export declare const stringBufferToString: (buffer: StringBuffer) => Promise<HtmlEscapedString>;
|
|
13
27
|
export declare const escapeToBuffer: (str: string, buffer: StringBuffer) => void;
|
|
14
28
|
export declare const resolveStream: (str: string | HtmlEscapedString, buffer?: [string]) => Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type StatusCode = number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AlgorithmTypes } from './types';
|
|
2
|
-
|
|
2
|
+
type AlgorithmTypeName = keyof typeof AlgorithmTypes;
|
|
3
3
|
export declare const sign: (payload: unknown, secret: string, alg?: AlgorithmTypeName) => Promise<string>;
|
|
4
4
|
export declare const verify: (token: string, secret: string, alg?: AlgorithmTypeName) => Promise<any>;
|
|
5
5
|
export declare const decode: (token: string) => {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
1
|
+
export type Expect<T extends true> = T;
|
|
2
|
+
export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
3
|
+
export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
|
|
4
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
5
|
+
export type RemoveBlankRecord<T> = T extends Record<infer K, unknown> ? K extends string ? T : never : never;
|
|
6
|
+
export type IfAnyThenEmptyObject<T> = 0 extends 1 & T ? {} : T;
|
|
7
|
+
export type IntersectNonAnyTypes<T extends any[]> = T extends [infer Head, ...infer Rest] ? IfAnyThenEmptyObject<Head> & IntersectNonAnyTypes<Rest> : {};
|
|
8
|
+
export type JSONPrimitive = string | boolean | number | null | undefined;
|
|
9
|
+
export type JSONArray = (JSONPrimitive | JSONObject | JSONArray)[];
|
|
10
|
+
export type JSONObject = {
|
|
11
11
|
[key: string]: JSONPrimitive | JSONArray | JSONObject | object;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
14
|
-
export
|
|
13
|
+
export type JSONValue = JSONObject | JSONArray | JSONPrimitive;
|
|
14
|
+
export type JSONParsed<T> = {
|
|
15
15
|
[k in keyof T]: T[k] extends JSONValue ? T[k] : string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type InterfaceToType<T> = T extends Function ? T : {
|
|
18
18
|
[K in keyof T]: InterfaceToType<T[K]>;
|
|
19
19
|
};
|
|
20
|
-
export
|
|
20
|
+
export type RequiredKeysOf<BaseType extends object> = Exclude<{
|
|
21
21
|
[Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never;
|
|
22
22
|
}[keyof BaseType], undefined>;
|
|
23
|
-
export
|
|
23
|
+
export type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Pattern = readonly [string, string, RegExp | true] | '*';
|
|
2
2
|
export declare const splitPath: (path: string) => string[];
|
|
3
3
|
export declare const splitRoutingPath: (path: string) => string[];
|
|
4
4
|
export declare const getPattern: (label: string) => Pattern | null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Context } from '../context';
|
|
2
2
|
import type { Env, ValidationTargets, MiddlewareHandler } from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
type ValidationTargetKeysWithBody = 'form' | 'json';
|
|
4
|
+
type ValidationTargetByMethod<M> = M extends 'get' | 'head' ? Exclude<keyof ValidationTargets, ValidationTargetKeysWithBody> : keyof ValidationTargets;
|
|
5
|
+
export type ValidationFunction<InputType, OutputType, E extends Env = {}, P extends string = string> = (value: InputType, c: Context<E, P>) => OutputType | Response | Promise<OutputType> | Promise<Response>;
|
|
6
6
|
export declare const validator: <InputType, P extends string, M extends string, U extends ValidationTargetByMethod<M>, OutputType = ValidationTargets[U], P2 extends string = P, V extends {
|
|
7
7
|
in: { [K in U]: unknown extends InputType ? OutputType : InputType; };
|
|
8
8
|
out: { [K_1 in U]: OutputType; };
|
package/dist/utils/html.js
CHANGED
|
@@ -4,16 +4,28 @@ var escapeRe = /[&<>'"]/;
|
|
|
4
4
|
var stringBufferToString = async (buffer) => {
|
|
5
5
|
let str = "";
|
|
6
6
|
const callbacks = [];
|
|
7
|
-
for (let i = buffer.length - 1;
|
|
7
|
+
for (let i = buffer.length - 1; ; i--) {
|
|
8
|
+
str += buffer[i];
|
|
9
|
+
i--;
|
|
10
|
+
if (i < 0) {
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
8
13
|
let r = await buffer[i];
|
|
9
14
|
if (typeof r === "object") {
|
|
10
15
|
callbacks.push(...r.callbacks || []);
|
|
11
16
|
}
|
|
17
|
+
const isEscaped = r.isEscaped;
|
|
12
18
|
r = await (typeof r === "object" ? r.toString() : r);
|
|
13
19
|
if (typeof r === "object") {
|
|
14
20
|
callbacks.push(...r.callbacks || []);
|
|
15
21
|
}
|
|
16
|
-
|
|
22
|
+
if (r.isEscaped ?? isEscaped) {
|
|
23
|
+
str += r;
|
|
24
|
+
} else {
|
|
25
|
+
const buf = [str];
|
|
26
|
+
escapeToBuffer(r, buf);
|
|
27
|
+
str = buf[0];
|
|
28
|
+
}
|
|
17
29
|
}
|
|
18
30
|
return raw(str, callbacks);
|
|
19
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.8",
|
|
4
4
|
"description": "Ultrafast web framework for the Edges",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"test:lambda": "env NAME=Node vitest --run --config ./runtime_tests/lambda/vitest.config.ts",
|
|
21
21
|
"test:lambda-edge": "env NAME=Node vitest --run --config ./runtime_tests/lambda-edge/vitest.config.ts",
|
|
22
22
|
"test:all": "yarn test && yarn test:deno && yarn test:bun && yarn test:fastly && yarn test:lagon && yarn test:node && yarn test:wrangler && yarn test:lambda && yarn test:lambda-edge",
|
|
23
|
-
"lint": "eslint --ext js,ts src runtime_tests
|
|
24
|
-
"lint:fix": "eslint --ext js,ts src runtime_tests
|
|
23
|
+
"lint": "eslint --ext js,ts src runtime_tests",
|
|
24
|
+
"lint:fix": "eslint --ext js,ts src runtime_tests --fix",
|
|
25
25
|
"format": "prettier --check 'src/**/*.{js,ts}' 'runtime_tests/**/*.{js,ts}'",
|
|
26
26
|
"format:fix": "prettier --write 'src/**/*.{js,ts}' 'runtime_tests/**/*.{js,ts}'",
|
|
27
27
|
"denoify": "rimraf deno_dist && denoify && rimraf 'deno_dist/**/*.test.{ts,tsx}'",
|
|
@@ -441,8 +441,9 @@
|
|
|
441
441
|
"nodejs"
|
|
442
442
|
],
|
|
443
443
|
"devDependencies": {
|
|
444
|
-
"@cloudflare/workers-types": "^4.
|
|
445
|
-
"@hono/
|
|
444
|
+
"@cloudflare/workers-types": "^4.20231121.0",
|
|
445
|
+
"@hono/eslint-config": "^0.0.3",
|
|
446
|
+
"@hono/node-server": "^1.3.3",
|
|
446
447
|
"@types/crypto-js": "^4.1.1",
|
|
447
448
|
"@types/glob": "^8.0.0",
|
|
448
449
|
"@types/jest": "^29.4.0",
|
|
@@ -450,21 +451,12 @@
|
|
|
450
451
|
"@types/node": "^20.8.2",
|
|
451
452
|
"@types/node-fetch": "^2.6.2",
|
|
452
453
|
"@types/supertest": "^2.0.12",
|
|
453
|
-
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
|
454
|
-
"@typescript-eslint/parser": "^5.59.2",
|
|
455
454
|
"@vitest/coverage-v8": "^0.34.3",
|
|
456
455
|
"arg": "^5.0.2",
|
|
457
456
|
"crypto-js": "^4.1.1",
|
|
458
457
|
"denoify": "^1.6.6",
|
|
459
458
|
"esbuild": "^0.15.12",
|
|
460
|
-
"eslint": "^8.
|
|
461
|
-
"eslint-config-prettier": "^8.8.0",
|
|
462
|
-
"eslint-define-config": "^1.20.0",
|
|
463
|
-
"eslint-import-resolver-typescript": "^3.5.5",
|
|
464
|
-
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
465
|
-
"eslint-plugin-flowtype": "^8.0.3",
|
|
466
|
-
"eslint-plugin-import": "^2.27.5",
|
|
467
|
-
"eslint-plugin-node": "^11.1.0",
|
|
459
|
+
"eslint": "^8.55.0",
|
|
468
460
|
"form-data": "^4.0.0",
|
|
469
461
|
"jest": "^29.6.4",
|
|
470
462
|
"jest-preset-fastly-js-compute": "^1.3.0",
|
|
@@ -479,13 +471,12 @@
|
|
|
479
471
|
"supertest": "^6.3.3",
|
|
480
472
|
"ts-jest": "^29.1.1",
|
|
481
473
|
"tsx": "^3.11.0",
|
|
482
|
-
"typescript": "^
|
|
474
|
+
"typescript": "^5.3.3",
|
|
483
475
|
"vitest": "^0.34.3",
|
|
484
|
-
"wrangler": "
|
|
476
|
+
"wrangler": "3.17.1",
|
|
485
477
|
"zod": "^3.20.2"
|
|
486
478
|
},
|
|
487
479
|
"engines": {
|
|
488
480
|
"node": ">=16.0.0"
|
|
489
|
-
}
|
|
490
|
-
"dependencies": {}
|
|
481
|
+
}
|
|
491
482
|
}
|