Types
GetPath
type GetPath<E extends Env> = (request: Request, options?: { env?: E["Bindings"]; }) => string;
HonoOptions
export type HonoOptions<E extends Env> = { /** * `strict` option specifies whether to distinguish whether the last path is a directory or not. * * @see {@link https://hono.dev/docs/api/hono#strict-mode} * * @default true */ strict?: boolean; /** * `router` option specifies which router to use. * * @see {@link https://hono.dev/docs/api/hono#router-option} * * @example * ```ts * const app = new Hono({ router: new RegExpRouter() }) * ``` */ router?: Router<[ H, RouterRoute ]>; /** * `getPath` can handle the host header value. * * @see {@link https://hono.dev/docs/api/routing#routing-with-host-header-value} * * @example * ```ts * const app = new Hono({ * getPath: (req) => * '/' + req.headers.get('host') + req.url.replace(/^https?:\/\/[^/]+(\/[^?]*)/, '$1'), * }) * * app.get('/www1.example.com/hello', () => c.text('hello www1')) * * // A following request will match the route: * // new Request('http://www1.example.com/hello', { * // headers: { host: 'www1.example.com' }, * // }) * ``` */ getPath?: GetPath<E>; };
MountOptionHandler
type MountOptionHandler = (c: Context) => unknown;
MountReplaceRequest
type MountReplaceRequest = (originalRequest: Request) => Request;
MountOptions
type MountOptions = MountOptionHandler | { optionHandler?: MountOptionHandler; replaceRequest?: MountReplaceRequest; };
All
/**
* @module
* This module is the base module for the Hono object.
*/
import { Context } from './context';
import type { ExecutionContext } from './context';
import type { Router } from './router';
import type { Env, ErrorHandler, H, HandlerInterface, MergePath, MergeSchemaPath, MiddlewareHandlerInterface, NotFoundHandler, OnHandlerInterface, RouterRoute, Schema } from './types';
/**
* Symbol used to mark a composed handler.
*/
export declare const COMPOSED_HANDLER: unique symbol;
type GetPath<E extends Env> = (request: Request, options?: {
env?: E["Bindings"];
}) => string;
export type HonoOptions<E extends Env> = {
/**
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
*
* @see {@link https://hono.dev/docs/api/hono#strict-mode}
*
* @default true
*/
strict?: boolean;
/**
* `router` option specifies which router to use.
*
* @see {@link https://hono.dev/docs/api/hono#router-option}
*
* @example
* ```ts
* const app = new Hono({ router: new RegExpRouter() })
* ```
*/
router?: Router<[
H,
RouterRoute
]>;
/**
* `getPath` can handle the host header value.
*
* @see {@link https://hono.dev/docs/api/routing#routing-with-host-header-value}
*
* @example
* ```ts
* const app = new Hono({
* getPath: (req) =>
* '/' + req.headers.get('host') + req.url.replace(/^https?:\/\/[^/]+(\/[^?]*)/, '$1'),
* })
*
* app.get('/www1.example.com/hello', () => c.text('hello www1'))
*
* // A following request will match the route:
* // new Request('http://www1.example.com/hello', {
* // headers: { host: 'www1.example.com' },
* // })
* ```
*/
getPath?: GetPath<E>;
};
type MountOptionHandler = (c: Context) => unknown;
type MountReplaceRequest = (originalRequest: Request) => Request;
type MountOptions = MountOptionHandler | {
optionHandler?: MountOptionHandler;
replaceRequest?: MountReplaceRequest;
};
declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/"> {
get: HandlerInterface<E, "get", S, BasePath>;
post: HandlerInterface<E, "post", S, BasePath>;
put: HandlerInterface<E, "put", S, BasePath>;
delete: HandlerInterface<E, "delete", S, BasePath>;
options: HandlerInterface<E, "options", S, BasePath>;
patch: HandlerInterface<E, "patch", S, BasePath>;
all: HandlerInterface<E, "all", S, BasePath>;
on: OnHandlerInterface<E, S, BasePath>;
use: MiddlewareHandlerInterface<E, S, BasePath>;
router: Router<[
H,
RouterRoute
]>;
readonly getPath: GetPath<E>;
routes: RouterRoute[];
constructor(options?: HonoOptions<E>);
/**
* `.route()` allows grouping other Hono instance in routes.
*
* @see {@link https://hono.dev/docs/api/routing#grouping}
*
* @param {string} path - base Path
* @param {Hono} app - other Hono instance
* @returns {Hono} routed Hono instance
*
* @example
* ```ts
* const app = new Hono()
* const app2 = new Hono()
*
* app2.get("/user", (c) => c.text("user"))
* app.route("/api", app2) // GET /api/user
* ```
*/
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app: Hono<SubEnv, SubSchema, SubBasePath>): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> | S, BasePath>;
/**
* `.basePath()` allows base paths to be specified.
*
* @see {@link https://hono.dev/docs/api/routing#base-path}
*
* @param {string} path - base Path
* @returns {Hono} changed Hono instance
*
* @example
* ```ts
* const api = new Hono().basePath('/api')
* ```
*/
basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>>;
/**
* `.onError()` handles an error and returns a customized Response.
*
* @see {@link https://hono.dev/docs/api/hono#error-handling}
*
* @param {ErrorHandler} handler - request Handler for error
* @returns {Hono} changed Hono instance
*
* @example
* ```ts
* app.onError((err, c) => {
* console.error(`${err}`)
* return c.text('Custom Error Message', 500)
* })
* ```
*/
onError: (handler: ErrorHandler<E>) => Hono<E, S, BasePath>;
/**
* `.notFound()` allows you to customize a Not Found Response.
*
* @see {@link https://hono.dev/docs/api/hono#not-found}
*
* @param {NotFoundHandler} handler - request handler for not-found
* @returns {Hono} changed Hono instance
*
* @example
* ```ts
* app.notFound((c) => {
* return c.text('Custom 404 Message', 404)
* })
* ```
*/
notFound: (handler: NotFoundHandler<E>) => Hono<E, S, BasePath>;
/**
* `.mount()` allows you to mount applications built with other frameworks into your Hono application.
*
* @see {@link https://hono.dev/docs/api/hono#mount}
*
* @param {string} path - base Path
* @param {Function} applicationHandler - other Request Handler
* @param {MountOptions} [options] - options of `.mount()`
* @returns {Hono} mounted Hono instance
*
* @example
* ```ts
* import { Router as IttyRouter } from 'itty-router'
* import { Hono } from 'hono'
* // Create itty-router application
* const ittyRouter = IttyRouter()
* // GET /itty-router/hello
* ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
*
* const app = new Hono()
* app.mount('/itty-router', ittyRouter.handle)
* ```
*
* @example
* ```ts
* const app = new Hono()
* // Send the request to another application without modification.
* app.mount('/app', anotherApp, {
* replaceRequest: (req) => req,
* })
* ```
*/
mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<E, S, BasePath>;
/**
* `.fetch()` will be entry point of your app.
*
* @see {@link https://hono.dev/docs/api/hono#fetch}
*
* @param {Request} request - request Object of request
* @param {Env} Env - env Object
* @param {ExecutionContext} - context of execution
* @returns {Response | Promise<Response>} response of request
*
*/
fetch: (request: Request, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
/**
* `.request()` is a useful method for testing.
* You can pass a URL or pathname to send a GET request.
* app will return a Response object.
* ```ts
* test('GET /hello is ok', async () => {
* const res = await app.request('/hello')
* expect(res.status).toBe(200)
* })
* ```
* @see https://hono.dev/docs/api/hono#request
*/
request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
/**
* `.fire()` automatically adds a global fetch event listener.
* This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
* @see https://hono.dev/docs/api/hono#fire
* @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
* @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
*/
fire: () => void;
}
export { Hono as HonoBase };
dist/types/middleware/body-limit/index.d.ts
Types
OnError
type OnError = (c: Context) => Response | Promise<Response>;
BodyLimitOptions
type BodyLimitOptions = { maxSize: number; onError?: OnError; };
Functions
bodyLimit
/** * Body Limit Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/body-limit} * * @param {BodyLimitOptions} options - The options for the body limit middleware. * @param {number} options.maxSize - The maximum body size allowed. * @param {OnError} [options.onError] - The error handler to be invoked if the specified body size is exceeded. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.post( * '/upload', * bodyLimit({ * maxSize: 50 * 1024, // 50kb * onError: (c) => { * return c.text('overflow :(', 413) * }, * }), * async (c) => { * const body = await c.req.parseBody() * if (body['file'] instanceof File) { * console.log(`Got file sized: ${body['file'].size}`) * } * return c.text('pass :)') * } * ) * ``` */ export declare const bodyLimit: (options: BodyLimitOptions) => MiddlewareHandler;
All
/**
* @module
* Body Limit Middleware for Hono.
*/
import type { Context } from '../../context';
import type { MiddlewareHandler } from '../../types';
type OnError = (c: Context) => Response | Promise<Response>;
type BodyLimitOptions = {
maxSize: number;
onError?: OnError;
};
/**
* Body Limit Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/body-limit}
*
* @param {BodyLimitOptions} options - The options for the body limit middleware.
* @param {number} options.maxSize - The maximum body size allowed.
* @param {OnError} [options.onError] - The error handler to be invoked if the specified body size is exceeded.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.post(
* '/upload',
* bodyLimit({
* maxSize: 50 * 1024, // 50kb
* onError: (c) => {
* return c.text('overflow :(', 413)
* },
* }),
* async (c) => {
* const body = await c.req.parseBody()
* if (body['file'] instanceof File) {
* console.log(`Got file sized: ${body['file'].size}`)
* }
* return c.text('pass :)')
* }
* )
* ```
*/
export declare const bodyLimit: (options: BodyLimitOptions) => MiddlewareHandler;
export {};
All
/**
* @module
* The preset that uses `PatternRouter`.
*/
import { HonoBase } from '../hono-base';
import type { HonoOptions } from '../hono-base';
import type { BlankEnv, BlankSchema, Env, Schema } from '../types';
export declare class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> extends HonoBase<E, S, BasePath> {
constructor(options?: HonoOptions<E>);
}
dist/types/middleware/serve-static/index.d.ts
Types
ServeStaticOptions
export type ServeStaticOptions<E extends Env = Env> = { root?: string; path?: string; precompressed?: boolean; mimes?: Record<string, string>; rewriteRequestPath?: (path: string) => string; onFound?: (path: string, c: Context<E>) => void | Promise<void>; onNotFound?: (path: string, c: Context<E>) => void | Promise<void>; };
Functions
serveStatic
/** * This middleware is not directly used by the user. Create a wrapper specifying `getContent()` by the environment such as Deno or Bun. */ export declare const serveStatic: <E extends Env = Env>(options: ServeStaticOptions<E> & { getContent: (path: string, c: Context<E>) => Promise<Data | Response | null>; pathResolve?: (path: string) => string; isDir?: (path: string) => boolean | undefined | Promise<boolean | undefined>; }) => MiddlewareHandler;
All
/**
* @module
* Serve Static Middleware for Hono.
*/
import type { Context, Data } from '../../context';
import type { Env, MiddlewareHandler } from '../../types';
export type ServeStaticOptions<E extends Env = Env> = {
root?: string;
path?: string;
precompressed?: boolean;
mimes?: Record<string, string>;
rewriteRequestPath?: (path: string) => string;
onFound?: (path: string, c: Context<E>) => void | Promise<void>;
onNotFound?: (path: string, c: Context<E>) => void | Promise<void>;
};
/**
* This middleware is not directly used by the user. Create a wrapper specifying `getContent()` by the environment such as Deno or Bun.
*/
export declare const serveStatic: <E extends Env = Env>(options: ServeStaticOptions<E> & {
getContent: (path: string, c: Context<E>) => Promise<Data | Response | null>;
pathResolve?: (path: string) => string;
isDir?: (path: string) => boolean | undefined | Promise<boolean | undefined>;
}) => MiddlewareHandler;
dist/types/http-exception.d.ts
Types
HTTPExceptionOptions
/** * Options for creating an `HTTPException`. * @property res - Optional response object to use. * @property message - Optional custom error message. * @property cause - Optional cause of the error. */ type HTTPExceptionOptions = { res?: Response; message?: string; cause?: unknown; };
All
/**
* @module
* This module provides the `HTTPException` class.
*/
import type { StatusCode } from './utils/http-status';
/**
* Options for creating an `HTTPException`.
* @property res - Optional response object to use.
* @property message - Optional custom error message.
* @property cause - Optional cause of the error.
*/
type HTTPExceptionOptions = {
res?: Response;
message?: string;
cause?: unknown;
};
/**
* `HTTPException` must be used when a fatal error such as authentication failure occurs.
*
* @see {@link https://hono.dev/docs/api/exception}
*
* @param {StatusCode} status - status code of HTTPException
* @param {HTTPExceptionOptions} options - options of HTTPException
* @param {HTTPExceptionOptions["res"]} options.res - response of options of HTTPException
* @param {HTTPExceptionOptions["message"]} options.message - message of options of HTTPException
* @param {HTTPExceptionOptions["cause"]} options.cause - cause of options of HTTPException
*
* @example
* ```ts
* import { HTTPException } from 'hono/http-exception'
*
* // ...
*
* app.post('/auth', async (c, next) => {
* // authentication
* if (authorized === false) {
* throw new HTTPException(401, { message: 'Custom error message' })
* }
* await next()
* })
* ```
*/
export declare class HTTPException extends Error {
readonly res?: Response;
readonly status: StatusCode;
/**
* Creates an instance of `HTTPException`.
* @param status - HTTP status code for the exception. Defaults to 500.
* @param options - Additional options for the exception.
*/
constructor(status?: StatusCode, options?: HTTPExceptionOptions);
/**
* Returns the response object associated with the exception.
* If a response object is not provided, a new response is created with the error message and status code.
* @returns The response object.
*/
getResponse(): Response;
}
export {};
dist/types/middleware/etag/index.d.ts
Types
ETagOptions
type ETagOptions = { retainedHeaders?: string[]; weak?: boolean; };
Functions
etag
/** * ETag Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/etag} * * @param {ETagOptions} [options] - The options for the ETag middleware. * @param {boolean} [options.weak=false] - Define using or not using a weak validation. If true is set, then `W/` is added to the prefix of the value. * @param {string[]} [options.retainedHeaders=RETAINED_304_HEADERS] - The headers that you want to retain in the 304 Response. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use('/etag/*', etag()) * app.get('/etag/abc', (c) => { * return c.text('Hono is cool') * }) * ``` */ export declare const etag: (options?: ETagOptions) => MiddlewareHandler;
All
/**
* @module
* ETag Middleware for Hono.
*/
import type { MiddlewareHandler } from '../../types';
type ETagOptions = {
retainedHeaders?: string[];
weak?: boolean;
};
/**
* Default headers to pass through on 304 responses. From the spec:
* > The response must not contain a body and must include the headers that
* > would have been sent in an equivalent 200 OK response: Cache-Control,
* > Content-Location, Date, ETag, Expires, and Vary.
*/
export declare const RETAINED_304_HEADERS: string[];
/**
* ETag Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/etag}
*
* @param {ETagOptions} [options] - The options for the ETag middleware.
* @param {boolean} [options.weak=false] - Define using or not using a weak validation. If true is set, then `W/` is added to the prefix of the value.
* @param {string[]} [options.retainedHeaders=RETAINED_304_HEADERS] - The headers that you want to retain in the 304 Response.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use('/etag/*', etag())
* app.get('/etag/abc', (c) => {
* return c.text('Hono is cool')
* })
* ```
*/
export declare const etag: (options?: ETagOptions) => MiddlewareHandler;
export {};
dist/types/middleware/cors/index.d.ts
Types
CORSOptions
type CORSOptions = { origin: string | string[] | ((origin: string, c: Context) => string | undefined | null); allowMethods?: string[]; allowHeaders?: string[]; maxAge?: number; credentials?: boolean; exposeHeaders?: string[]; };
Functions
cors
/** * CORS Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/cors} * * @param {CORSOptions} [options] - The options for the CORS middleware. * @param {string | string[] | ((origin: string, c: Context) => string | undefined | null)} [options.origin='*'] - The value of "Access-Control-Allow-Origin" CORS header. * @param {string[]} [options.allowMethods=['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH']] - The value of "Access-Control-Allow-Methods" CORS header. * @param {string[]} [options.allowHeaders=[]] - The value of "Access-Control-Allow-Headers" CORS header. * @param {number} [options.maxAge] - The value of "Access-Control-Max-Age" CORS header. * @param {boolean} [options.credentials] - The value of "Access-Control-Allow-Credentials" CORS header. * @param {string[]} [options.exposeHeaders=[]] - The value of "Access-Control-Expose-Headers" CORS header. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use('/api/*', cors()) * app.use( * '/api2/*', * cors({ * origin: 'http://example.com', * allowHeaders: ['X-Custom-Header', 'Upgrade-Insecure-Requests'], * allowMethods: ['POST', 'GET', 'OPTIONS'], * exposeHeaders: ['Content-Length', 'X-Kuma-Revision'], * maxAge: 600, * credentials: true, * }) * ) * * app.all('/api/abc', (c) => { * return c.json({ success: true }) * }) * app.all('/api2/abc', (c) => { * return c.json({ success: true }) * }) * ``` */ export declare const cors: (options?: CORSOptions) => MiddlewareHandler;
All
/**
* @module
* CORS Middleware for Hono.
*/
import type { Context } from '../../context';
import type { MiddlewareHandler } from '../../types';
type CORSOptions = {
origin: string | string[] | ((origin: string, c: Context) => string | undefined | null);
allowMethods?: string[];
allowHeaders?: string[];
maxAge?: number;
credentials?: boolean;
exposeHeaders?: string[];
};
/**
* CORS Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/cors}
*
* @param {CORSOptions} [options] - The options for the CORS middleware.
* @param {string | string[] | ((origin: string, c: Context) => string | undefined | null)} [options.origin='*'] - The value of "Access-Control-Allow-Origin" CORS header.
* @param {string[]} [options.allowMethods=['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH']] - The value of "Access-Control-Allow-Methods" CORS header.
* @param {string[]} [options.allowHeaders=[]] - The value of "Access-Control-Allow-Headers" CORS header.
* @param {number} [options.maxAge] - The value of "Access-Control-Max-Age" CORS header.
* @param {boolean} [options.credentials] - The value of "Access-Control-Allow-Credentials" CORS header.
* @param {string[]} [options.exposeHeaders=[]] - The value of "Access-Control-Expose-Headers" CORS header.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use('/api/*', cors())
* app.use(
* '/api2/*',
* cors({
* origin: 'http://example.com',
* allowHeaders: ['X-Custom-Header', 'Upgrade-Insecure-Requests'],
* allowMethods: ['POST', 'GET', 'OPTIONS'],
* exposeHeaders: ['Content-Length', 'X-Kuma-Revision'],
* maxAge: 600,
* credentials: true,
* })
* )
*
* app.all('/api/abc', (c) => {
* return c.json({ success: true })
* })
* app.all('/api2/abc', (c) => {
* return c.json({ success: true })
* })
* ```
*/
export declare const cors: (options?: CORSOptions) => MiddlewareHandler;
export {};
dist/types/middleware/compress/index.d.ts
Interfaces
CompressionOptions
interface CompressionOptions { encoding?: (typeof ENCODING_TYPES)[number]; threshold?: number; }
Functions
compress
/** * Compress Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/compress} * * @param {CompressionOptions} [options] - The options for the compress middleware. * @param {'gzip' | 'deflate'} [options.encoding] - The compression scheme to allow for response compression. Either 'gzip' or 'deflate'. If not defined, both are allowed and will be used based on the Accept-Encoding header. 'gzip' is prioritized if this option is not provided and the client provides both in the Accept-Encoding header. * @param {number} [options.threshold=1024] - The minimum size in bytes to compress. Defaults to 1024 bytes. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use(compress()) * ``` */ export declare const compress: (options?: CompressionOptions) => MiddlewareHandler;
All
/**
* @module
* Compress Middleware for Hono.
*/
import type { MiddlewareHandler } from '../../types';
declare const ENCODING_TYPES: readonly [
"gzip",
"deflate"
];
interface CompressionOptions {
encoding?: (typeof ENCODING_TYPES)[number];
threshold?: number;
}
/**
* Compress Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/compress}
*
* @param {CompressionOptions} [options] - The options for the compress middleware.
* @param {'gzip' | 'deflate'} [options.encoding] - The compression scheme to allow for response compression. Either 'gzip' or 'deflate'. If not defined, both are allowed and will be used based on the Accept-Encoding header. 'gzip' is prioritized if this option is not provided and the client provides both in the Accept-Encoding header.
* @param {number} [options.threshold=1024] - The minimum size in bytes to compress. Defaults to 1024 bytes.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(compress())
* ```
*/
export declare const compress: (options?: CompressionOptions) => MiddlewareHandler;
export {};
dist/types/jsx/dom/jsx-dev-runtime.d.ts
Functions
jsxDEV
export declare const jsxDEV: (tag: string | Function, props: Props, key?: string) => JSXNode;
Fragment
export declare const Fragment: (props: Record<string, unknown>) => JSXNode;
All
/**
* @module
* This module provides the `hono/jsx/dom` dev runtime.
*/
import type { JSXNode, Props } from '../base';
export declare const jsxDEV: (tag: string | Function, props: Props, key?: string) => JSXNode;
export declare const Fragment: (props: Record<string, unknown>) => JSXNode;
dist/types/jsx/dom/client.d.ts
Interfaces
Root
export interface Root { render(children: Child): void; unmount(): void; }
Types
RootOptions
export type RootOptions = Record<string, unknown>;
Functions
createRoot
/** * Create a root object for rendering * @param element Render target * @param options Options for createRoot (not supported yet) * @returns Root object has `render` and `unmount` methods */ export declare const createRoot: (element: HTMLElement | DocumentFragment, options?: RootOptions) => Root;
hydrateRoot
/** * Create a root object and hydrate app to the target element. * In hono/jsx/dom, hydrate is equivalent to render. * @param element Render target * @param reactNode A JSXNode to render * @param options Options for createRoot (not supported yet) * @returns Root object has `render` and `unmount` methods */ export declare const hydrateRoot: (element: HTMLElement | DocumentFragment, reactNode: Child, options?: RootOptions) => Root;
All
/**
* @module
* This module provides APIs for `hono/jsx/dom/client`, which is compatible with `react-dom/client`.
*/
import type { Child } from '../base';
export interface Root {
render(children: Child): void;
unmount(): void;
}
export type RootOptions = Record<string, unknown>;
/**
* Create a root object for rendering
* @param element Render target
* @param options Options for createRoot (not supported yet)
* @returns Root object has `render` and `unmount` methods
*/
export declare const createRoot: (element: HTMLElement | DocumentFragment, options?: RootOptions) => Root;
/**
* Create a root object and hydrate app to the target element.
* In hono/jsx/dom, hydrate is equivalent to render.
* @param element Render target
* @param reactNode A JSXNode to render
* @param options Options for createRoot (not supported yet)
* @returns Root object has `render` and `unmount` methods
*/
export declare const hydrateRoot: (element: HTMLElement | DocumentFragment, reactNode: Child, options?: RootOptions) => Root;
declare const _default: {
createRoot: (element: HTMLElement | DocumentFragment, options?: RootOptions) => Root;
hydrateRoot: (element: HTMLElement | DocumentFragment, reactNode: Child, options?: RootOptions) => Root;
};
export default _default;
Interfaces
GetCookie
interface GetCookie { (c: Context, key: string): string | undefined; (c: Context): Cookie; (c: Context, key: string, prefixOptions: CookiePrefixOptions): string | undefined; }
GetSignedCookie
interface GetSignedCookie { (c: Context, secret: string | BufferSource, key: string): Promise<string | undefined | false>; (c: Context, secret: string): Promise<SignedCookie>; (c: Context, secret: string | BufferSource, key: string, prefixOptions: CookiePrefixOptions): Promise<string | undefined | false>; }
Functions
setCookie
export declare const setCookie: (c: Context, name: string, value: string, opt?: CookieOptions) => void;
setSignedCookie
export declare const setSignedCookie: (c: Context, name: string, value: string, secret: string | BufferSource, opt?: CookieOptions) => Promise<void>;
deleteCookie
export declare const deleteCookie: (c: Context, name: string, opt?: CookieOptions) => string | undefined;
All
/**
* @module
* Cookie Helper for Hono.
*/
import type { Context } from '../../context';
import type { Cookie, CookieOptions, CookiePrefixOptions, SignedCookie } from '../../utils/cookie';
interface GetCookie {
(c: Context, key: string): string | undefined;
(c: Context): Cookie;
(c: Context, key: string, prefixOptions: CookiePrefixOptions): string | undefined;
}
interface GetSignedCookie {
(c: Context, secret: string | BufferSource, key: string): Promise<string | undefined | false>;
(c: Context, secret: string): Promise<SignedCookie>;
(c: Context, secret: string | BufferSource, key: string, prefixOptions: CookiePrefixOptions): Promise<string | undefined | false>;
}
export declare const getCookie: GetCookie;
export declare const getSignedCookie: GetSignedCookie;
export declare const setCookie: (c: Context, name: string, value: string, opt?: CookieOptions) => void;
export declare const setSignedCookie: (c: Context, name: string, value: string, secret: string | BufferSource, opt?: CookieOptions) => Promise<void>;
export declare const deleteCookie: (c: Context, name: string, opt?: CookieOptions) => string | undefined;
export {};
dist/types/middleware/logger/index.d.ts
Types
PrintFunc
type PrintFunc = (str: string, ...rest: string[]) => void;
Functions
logger
/** * Logger Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/logger} * * @param {PrintFunc} [fn=console.log] - Optional function for customized logging behavior. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use(logger()) * app.get('/', (c) => c.text('Hello Hono!')) * ``` */ export declare const logger: (fn?: PrintFunc) => MiddlewareHandler;
All
/**
* @module
* Logger Middleware for Hono.
*/
import type { MiddlewareHandler } from '../../types';
type PrintFunc = (str: string, ...rest: string[]) => void;
/**
* Logger Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/logger}
*
* @param {PrintFunc} [fn=console.log] - Optional function for customized logging behavior.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(logger())
* app.get('/', (c) => c.text('Hello Hono!'))
* ```
*/
export declare const logger: (fn?: PrintFunc) => MiddlewareHandler;
export {};
dist/types/helper/html/index.d.ts
Functions
html
export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString>;
All
/**
* @module
* html Helper for Hono.
*/
import { raw } from '../../utils/html';
import type { HtmlEscapedString } from '../../utils/html';
export { raw };
export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString>;
dist/types/middleware/csrf/index.d.ts
Types
IsAllowedOriginHandler
type IsAllowedOriginHandler = (origin: string, context: Context) => boolean;
Interfaces
CSRFOptions
interface CSRFOptions { origin?: string | string[] | IsAllowedOriginHandler; }
Functions
csrf
/** * CSRF Protection Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/csrf} * * @param {CSRFOptions} [options] - The options for the CSRF protection middleware. * @param {string|string[]|(origin: string, context: Context) => boolean} [options.origin] - Specify origins. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use(csrf()) * * // Specifying origins with using `origin` option * // string * app.use(csrf({ origin: 'myapp.example.com' })) * * // string[] * app.use( * csrf({ * origin: ['myapp.example.com', 'development.myapp.example.com'], * }) * ) * * // Function * // It is strongly recommended that the protocol be verified to ensure a match to `$`. * // You should *never* do a forward match. * app.use( * '*', * csrf({ * origin: (origin) => /https:\/\/(\w+\.)?myapp\.example\.com$/.test(origin), * }) * ) * ``` */ export declare const csrf: (options?: CSRFOptions) => MiddlewareHandler;
All
/**
* @module
* CSRF Protection Middleware for Hono.
*/
import type { Context } from '../../context';
import type { MiddlewareHandler } from '../../types';
type IsAllowedOriginHandler = (origin: string, context: Context) => boolean;
interface CSRFOptions {
origin?: string | string[] | IsAllowedOriginHandler;
}
/**
* CSRF Protection Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/csrf}
*
* @param {CSRFOptions} [options] - The options for the CSRF protection middleware.
* @param {string|string[]|(origin: string, context: Context) => boolean} [options.origin] - Specify origins.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(csrf())
*
* // Specifying origins with using `origin` option
* // string
* app.use(csrf({ origin: 'myapp.example.com' }))
*
* // string[]
* app.use(
* csrf({
* origin: ['myapp.example.com', 'development.myapp.example.com'],
* })
* )
*
* // Function
* // It is strongly recommended that the protocol be verified to ensure a match to `$`.
* // You should *never* do a forward match.
* app.use(
* '*',
* csrf({
* origin: (origin) => /https:\/\/(\w+\.)?myapp\.example\.com$/.test(origin),
* })
* )
* ```
*/
export declare const csrf: (options?: CSRFOptions) => MiddlewareHandler;
export {};
All
/**
* @module
* The preset that uses `LinearRouter`.
*/
import { HonoBase } from '../hono-base';
import type { HonoOptions } from '../hono-base';
import type { BlankEnv, BlankSchema, Env, Schema } from '../types';
export declare class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> extends HonoBase<E, S, BasePath> {
constructor(options?: HonoOptions<E>);
}
dist/types/middleware/bearer-auth/index.d.ts
Types
MessageFunction
type MessageFunction = (c: Context) => string | object | Promise<string | object>;
BearerAuthOptions
type BearerAuthOptions = { token: string | string[]; realm?: string; prefix?: string; headerName?: string; hashFunction?: Function; noAuthenticationHeaderMessage?: string | object | MessageFunction; invalidAuthenticationHeaderMessage?: string | object | MessageFunction; invalidTokenMessage?: string | object | MessageFunction; } | { realm?: string; prefix?: string; headerName?: string; verifyToken: (token: string, c: Context) => boolean | Promise<boolean>; hashFunction?: Function; noAuthenticationHeaderMessage?: string | object | MessageFunction; invalidAuthenticationHeaderMessage?: string | object | MessageFunction; invalidTokenMessage?: string | object | MessageFunction; };
Functions
bearerAuth
/** * Bearer Auth Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/bearer-auth} * * @param {BearerAuthOptions} options - The options for the bearer authentication middleware. * @param {string | string[]} [options.token] - The string or array of strings to validate the incoming bearer token against. * @param {Function} [options.verifyToken] - The function to verify the token. * @param {string} [options.realm=""] - The domain name of the realm, as part of the returned WWW-Authenticate challenge header. * @param {string} [options.prefix="Bearer"] - The prefix (or known as `schema`) for the Authorization header value. If set to the empty string, no prefix is expected. * @param {string} [options.headerName=Authorization] - The header name. * @param {Function} [options.hashFunction] - A function to handle hashing for safe comparison of authentication tokens. * @param {string | object | MessageFunction} [options.noAuthenticationHeaderMessage="Unauthorized"] - The no authentication header message. * @param {string | object | MessageFunction} [options.invalidAuthenticationHeaderMeasage="Bad Request"] - The invalid authentication header message. * @param {string | object | MessageFunction} [options.invalidTokenMessage="Unauthorized"] - The invalid token message. * @returns {MiddlewareHandler} The middleware handler function. * @throws {Error} If neither "token" nor "verifyToken" options are provided. * @throws {HTTPException} If authentication fails, with 401 status code for missing or invalid token, or 400 status code for invalid request. * * @example * ```ts * const app = new Hono() * * const token = 'honoiscool' * * app.use('/api/*', bearerAuth({ token })) * * app.get('/api/page', (c) => { * return c.json({ message: 'You are authorized' }) * }) * ``` */ export declare const bearerAuth: (options: BearerAuthOptions) => MiddlewareHandler;
All
/**
* @module
* Bearer Auth Middleware for Hono.
*/
import type { Context } from '../../context';
import type { MiddlewareHandler } from '../../types';
type MessageFunction = (c: Context) => string | object | Promise<string | object>;
type BearerAuthOptions = {
token: string | string[];
realm?: string;
prefix?: string;
headerName?: string;
hashFunction?: Function;
noAuthenticationHeaderMessage?: string | object | MessageFunction;
invalidAuthenticationHeaderMessage?: string | object | MessageFunction;
invalidTokenMessage?: string | object | MessageFunction;
} | {
realm?: string;
prefix?: string;
headerName?: string;
verifyToken: (token: string, c: Context) => boolean | Promise<boolean>;
hashFunction?: Function;
noAuthenticationHeaderMessage?: string | object | MessageFunction;
invalidAuthenticationHeaderMessage?: string | object | MessageFunction;
invalidTokenMessage?: string | object | MessageFunction;
};
/**
* Bearer Auth Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/bearer-auth}
*
* @param {BearerAuthOptions} options - The options for the bearer authentication middleware.
* @param {string | string[]} [options.token] - The string or array of strings to validate the incoming bearer token against.
* @param {Function} [options.verifyToken] - The function to verify the token.
* @param {string} [options.realm=""] - The domain name of the realm, as part of the returned WWW-Authenticate challenge header.
* @param {string} [options.prefix="Bearer"] - The prefix (or known as `schema`) for the Authorization header value. If set to the empty string, no prefix is expected.
* @param {string} [options.headerName=Authorization] - The header name.
* @param {Function} [options.hashFunction] - A function to handle hashing for safe comparison of authentication tokens.
* @param {string | object | MessageFunction} [options.noAuthenticationHeaderMessage="Unauthorized"] - The no authentication header message.
* @param {string | object | MessageFunction} [options.invalidAuthenticationHeaderMeasage="Bad Request"] - The invalid authentication header message.
* @param {string | object | MessageFunction} [options.invalidTokenMessage="Unauthorized"] - The invalid token message.
* @returns {MiddlewareHandler} The middleware handler function.
* @throws {Error} If neither "token" nor "verifyToken" options are provided.
* @throws {HTTPException} If authentication fails, with 401 status code for missing or invalid token, or 400 status code for invalid request.
*
* @example
* ```ts
* const app = new Hono()
*
* const token = 'honoiscool'
*
* app.use('/api/*', bearerAuth({ token }))
*
* app.get('/api/page', (c) => {
* return c.json({ message: 'You are authorized' })
* })
* ```
*/
export declare const bearerAuth: (options: BearerAuthOptions) => MiddlewareHandler;
export {};
Interfaces
CreateCssJsxDomObjectsType
interface CreateCssJsxDomObjectsType { (args: { id: Readonly<string>; }): readonly [ { toString(this: CssClassName): string; }, FC<PropsWithChildren<void>> ]; }
CssType
interface CssType { (strings: TemplateStringsArray, ...values: CssVariableType[]): string; }
CxType
interface CxType { (...args: (string | boolean | null | undefined)[]): string; }
KeyframesType
interface KeyframesType { (strings: TemplateStringsArray, ...values: CssVariableType[]): CssClassName; }
ViewTransitionType
interface ViewTransitionType { (strings: TemplateStringsArray, ...values: CssVariableType[]): string; (content: string): string; (): string; }
DefaultContextType
interface DefaultContextType { css: CssType; cx: CxType; keyframes: KeyframesType; viewTransition: ViewTransitionType; Style: FC<PropsWithChildren<void>>; }
Functions
createCssContext
/** * @experimental * `createCssContext` is an experimental feature. * The API might be changed. */ export declare const createCssContext: ({ id }: { id: Readonly<string>; }) => DefaultContextType;
All
/**
* @module
* This module provides APIs that enable `hono/jsx/dom` to support.
*/
import type { FC, PropsWithChildren } from '../';
import type { CssClassName, CssVariableType } from '../../helper/css/common';
export { rawCssString } from '../../helper/css/common';
interface CreateCssJsxDomObjectsType {
(args: {
id: Readonly<string>;
}): readonly [
{
toString(this: CssClassName): string;
},
FC<PropsWithChildren<void>>
];
}
export declare const createCssJsxDomObjects: CreateCssJsxDomObjectsType;
interface CssType {
(strings: TemplateStringsArray, ...values: CssVariableType[]): string;
}
interface CxType {
(...args: (string | boolean | null | undefined)[]): string;
}
interface KeyframesType {
(strings: TemplateStringsArray, ...values: CssVariableType[]): CssClassName;
}
interface ViewTransitionType {
(strings: TemplateStringsArray, ...values: CssVariableType[]): string;
(content: string): string;
(): string;
}
interface DefaultContextType {
css: CssType;
cx: CxType;
keyframes: KeyframesType;
viewTransition: ViewTransitionType;
Style: FC<PropsWithChildren<void>>;
}
/**
* @experimental
* `createCssContext` is an experimental feature.
* The API might be changed.
*/
export declare const createCssContext: ({ id }: {
id: Readonly<string>;
}) => DefaultContextType;
/**
* @experimental
* `css` is an experimental feature.
* The API might be changed.
*/
export declare const css: CssType;
/**
* @experimental
* `cx` is an experimental feature.
* The API might be changed.
*/
export declare const cx: CxType;
/**
* @experimental
* `keyframes` is an experimental feature.
* The API might be changed.
*/
export declare const keyframes: KeyframesType;
/**
* @experimental
* `viewTransition` is an experimental feature.
* The API might be changed.
*/
export declare const viewTransition: ViewTransitionType;
/**
* @experimental
* `Style` is an experimental feature.
* The API might be changed.
*/
export declare const Style: FC<PropsWithChildren<void>>;
dist/types/utils/jwt/index.d.ts
All
/**
* @module
* JWT utility.
*/
export declare const Jwt: {
sign: (payload: import("./types").JWTPayload, privateKey: import("./jws").SignatureKey, alg?: import("./jwa").SignatureAlgorithm) => Promise<string>;
verify: (token: string, publicKey: import("./jws").SignatureKey, alg?: import("./jwa").SignatureAlgorithm) => Promise<import("./types").JWTPayload>;
decode: (token: string) => {
header: import("./jwt").TokenHeader;
payload: import("./types").JWTPayload;
};
};
dist/types/middleware/powered-by/index.d.ts
Types
PoweredByOptions
type PoweredByOptions = { /** * The value for X-Powered-By header. * @default Hono */ serverName?: string; };
Functions
poweredBy
/** * Powered By Middleware for Hono. * * @param options - The options for the Powered By Middleware. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * import { poweredBy } from 'hono/powered-by' * * const app = new Hono() * * app.use(poweredBy()) // With options: poweredBy({ serverName: "My Server" }) * ``` */ export declare const poweredBy: (options?: PoweredByOptions) => MiddlewareHandler;
All
/**
* @module
* Powered By Middleware for Hono.
*/
import type { MiddlewareHandler } from '../../types';
type PoweredByOptions = {
/**
* The value for X-Powered-By header.
* @default Hono
*/
serverName?: string;
};
/**
* Powered By Middleware for Hono.
*
* @param options - The options for the Powered By Middleware.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* import { poweredBy } from 'hono/powered-by'
*
* const app = new Hono()
*
* app.use(poweredBy()) // With options: poweredBy({ serverName: "My Server" })
* ```
*/
export declare const poweredBy: (options?: PoweredByOptions) => MiddlewareHandler;
export {};
dist/types/middleware/trailing-slash/index.d.ts
Functions
trimTrailingSlash
/** * Trailing Slash Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/trailing-slash} * * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use(trimTrailingSlash()) * app.get('/about/me/', (c) => c.text('With Trailing Slash')) * ``` */ export declare const trimTrailingSlash: () => MiddlewareHandler;
appendTrailingSlash
/** * Append trailing slash middleware for Hono. * Append a trailing slash to the URL if it doesn't have one. For example, `/path/to/page` will be redirected to `/path/to/page/`. * * @see {@link https://hono.dev/docs/middleware/builtin/trailing-slash} * * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use(appendTrailingSlash()) * ``` */ export declare const appendTrailingSlash: () => MiddlewareHandler;
All
/**
* @module
* Trailing Slash Middleware for Hono.
*/
import type { MiddlewareHandler } from '../../types';
/**
* Trailing Slash Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/trailing-slash}
*
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(trimTrailingSlash())
* app.get('/about/me/', (c) => c.text('With Trailing Slash'))
* ```
*/
export declare const trimTrailingSlash: () => MiddlewareHandler;
/**
* Append trailing slash middleware for Hono.
* Append a trailing slash to the URL if it doesn't have one. For example, `/path/to/page` will be redirected to `/path/to/page/`.
*
* @see {@link https://hono.dev/docs/middleware/builtin/trailing-slash}
*
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(appendTrailingSlash())
* ```
*/
export declare const appendTrailingSlash: () => MiddlewareHandler;
dist/types/helper/dev/index.d.ts
Interfaces
ShowRoutesOptions
interface ShowRoutesOptions { verbose?: boolean; colorize?: boolean; }
RouteData
interface RouteData { path: string; method: string; name: string; isMiddleware: boolean; }
Functions
inspectRoutes
export declare const inspectRoutes: <E extends Env>(hono: Hono<E>) => RouteData[];
showRoutes
export declare const showRoutes: <E extends Env>(hono: Hono<E>, opts?: ShowRoutesOptions) => void;
getRouterName
export declare const getRouterName: <E extends Env>(app: Hono<E>) => string;
All
/**
* @module
* Dev Helper for Hono.
*/
import type { Hono } from '../../hono';
import type { Env } from '../../types';
interface ShowRoutesOptions {
verbose?: boolean;
colorize?: boolean;
}
interface RouteData {
path: string;
method: string;
name: string;
isMiddleware: boolean;
}
export declare const inspectRoutes: <E extends Env>(hono: Hono<E>) => RouteData[];
export declare const showRoutes: <E extends Env>(hono: Hono<E>, opts?: ShowRoutesOptions) => void;
export declare const getRouterName: <E extends Env>(app: Hono<E>) => string;
export {};
dist/types/middleware/timeout/index.d.ts
Types
HTTPExceptionFunction
export type HTTPExceptionFunction = (context: Context) => HTTPException;
Functions
timeout
/** * Timeout Middleware for Hono. * * @param {number} duration - The timeout duration in milliseconds. * @param {HTTPExceptionFunction | HTTPException} [exception=defaultTimeoutException] - The exception to throw when the timeout occurs. Can be a function that returns an HTTPException or an HTTPException object. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use( * '/long-request', * timeout(5000) // Set timeout to 5 seconds * ) * * app.get('/long-request', async (c) => { * await someLongRunningFunction() * return c.text('Completed within time limit') * }) * ``` */ export declare const timeout: (duration: number, exception?: HTTPExceptionFunction | HTTPException) => MiddlewareHandler;
All
/**
* @module
* Timeout Middleware for Hono.
*/
import type { Context } from '../../context';
import { HTTPException } from '../../http-exception';
import type { MiddlewareHandler } from '../../types';
export type HTTPExceptionFunction = (context: Context) => HTTPException;
/**
* Timeout Middleware for Hono.
*
* @param {number} duration - The timeout duration in milliseconds.
* @param {HTTPExceptionFunction | HTTPException} [exception=defaultTimeoutException] - The exception to throw when the timeout occurs. Can be a function that returns an HTTPException or an HTTPException object.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(
* '/long-request',
* timeout(5000) // Set timeout to 5 seconds
* )
*
* app.get('/long-request', async (c) => {
* await someLongRunningFunction()
* return c.text('Completed within time limit')
* })
* ```
*/
export declare const timeout: (duration: number, exception?: HTTPExceptionFunction | HTTPException) => MiddlewareHandler;
dist/types/helper/testing/index.d.ts
Types
ExtractEnv
type ExtractEnv<T> = T extends Hono<infer E, Schema, string> ? E : never;
Functions
testClient
export declare const testClient: <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext) => UnionToIntersection<Client<T>>;
All
/**
* @module
* Testing Helper for Hono.
*/
import type { Client } from '../../client/types';
import type { ExecutionContext } from '../../context';
import type { Hono } from '../../hono';
import type { Schema } from '../../types';
import type { UnionToIntersection } from '../../utils/types';
type ExtractEnv<T> = T extends Hono<infer E, Schema, string> ? E : never;
export declare const testClient: <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext) => UnionToIntersection<Client<T>>;
export {};
Types
Body
type Body = { json: any; text: string; arrayBuffer: ArrayBuffer; blob: Blob; formData: FormData; };
BodyCache
type BodyCache = Partial<Body & { parsedBody: BodyData; }>;
All
import type { Result } from './router';
import type { Input, InputToDataByTarget, ParamKeyToRecord, ParamKeys, RemoveQuestion, RouterRoute, ValidationTargets } from './types';
import type { BodyData, ParseBodyOptions } from './utils/body';
import type { CustomHeader, RequestHeader } from './utils/headers';
import type { Simplify, UnionToIntersection } from './utils/types';
type Body = {
json: any;
text: string;
arrayBuffer: ArrayBuffer;
blob: Blob;
formData: FormData;
};
type BodyCache = Partial<Body & {
parsedBody: BodyData;
}>;
export declare class HonoRequest<P extends string = "/", I extends Input["out"] = {}> {
/**
* `.raw` can get the raw Request object.
*
* @see {@link https://hono.dev/docs/api/request#raw}
*
* @example
* ```ts
* // For Cloudflare Workers
* app.post('/', async (c) => {
* const metadata = c.req.raw.cf?.hostMetadata?
* ...
* })
* ```
*/
raw: Request;
routeIndex: number;
/**
* `.path` can get the pathname of the request.
*
* @see {@link https://hono.dev/docs/api/request#path}
*
* @example
* ```ts
* app.get('/about/me', (c) => {
* const pathname = c.req.path // `/about/me`
* })
* ```
*/
path: string;
bodyCache: BodyCache;
constructor(request: Request, path?: string, matchResult?: Result<[
unknown,
RouterRoute
]>);
/**
* `.req.param()` gets the path parameters.
*
* @see {@link https://hono.dev/docs/api/routing#path-parameter}
*
* @example
* ```ts
* const name = c.req.param('name')
* // or all parameters at once
* const { id, comment_id } = c.req.param()
* ```
*/
param<P2 extends ParamKeys<P> = ParamKeys<P>>(key: P2 extends `${infer _}?` ? never : P2): string;
param<P2 extends RemoveQuestion<ParamKeys<P>> = RemoveQuestion<ParamKeys<P>>>(key: P2): string | undefined;
param(key: string): string | undefined;
param<P2 extends string = P>(): Simplify<UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>>;
/**
* `.query()` can get querystring parameters.
*
* @see {@link https://hono.dev/docs/api/request#query}
*
* @example
* ```ts
* // Query params
* app.get('/search', (c) => {
* const query = c.req.query('q')
* })
*
* // Get all params at once
* app.get('/search', (c) => {
* const { q, limit, offset } = c.req.query()
* })
* ```
*/
query(key: string): string | undefined;
query(): Record<string, string>;
/**
* `.queries()` can get multiple querystring parameter values, e.g. /search?tags=A&tags=B
*
* @see {@link https://hono.dev/docs/api/request#queries}
*
* @example
* ```ts
* app.get('/search', (c) => {
* // tags will be string[]
* const tags = c.req.queries('tags')
* })
* ```
*/
queries(key: string): string[] | undefined;
queries(): Record<string, string[]>;
/**
* `.header()` can get the request header value.
*
* @see {@link https://hono.dev/docs/api/request#header}
*
* @example
* ```ts
* app.get('/', (c) => {
* const userAgent = c.req.header('User-Agent')
* })
* ```
*/
header(name: RequestHeader): string | undefined;
header(name: string): string | undefined;
header(): Record<RequestHeader | (string & CustomHeader), string>;
/**
* `.parseBody()` can parse Request body of type `multipart/form-data` or `application/x-www-form-urlencoded`
*
* @see {@link https://hono.dev/docs/api/request#parsebody}
*
* @example
* ```ts
* app.post('/entry', async (c) => {
* const body = await c.req.parseBody()
* })
* ```
*/
parseBody<Options extends Partial<ParseBodyOptions>, T extends BodyData<Options>>(options?: Options): Promise<T>;
parseBody<T extends BodyData>(options?: Partial<ParseBodyOptions>): Promise<T>;
/**
* `.json()` can parse Request body of type `application/json`
*
* @see {@link https://hono.dev/docs/api/request#json}
*
* @example
* ```ts
* app.post('/entry', async (c) => {
* const body = await c.req.json()
* })
* ```
*/
json<T = any>(): Promise<T>;
/**
* `.text()` can parse Request body of type `text/plain`
*
* @see {@link https://hono.dev/docs/api/request#text}
*
* @example
* ```ts
* app.post('/entry', async (c) => {
* const body = await c.req.text()
* })
* ```
*/
text(): Promise<string>;
/**
* `.arrayBuffer()` parse Request body as an `ArrayBuffer`
*
* @see {@link https://hono.dev/docs/api/request#arraybuffer}
*
* @example
* ```ts
* app.post('/entry', async (c) => {
* const body = await c.req.arrayBuffer()
* })
* ```
*/
arrayBuffer(): Promise<ArrayBuffer>;
/**
* Parses the request body as a `Blob`.
* @example
* ```ts
* app.post('/entry', async (c) => {
* const body = await c.req.blob();
* });
* ```
* @see https://hono.dev/docs/api/request#blob
*/
blob(): Promise<Blob>;
/**
* Parses the request body as `FormData`.
* @example
* ```ts
* app.post('/entry', async (c) => {
* const body = await c.req.formData();
* });
* ```
* @see https://hono.dev/docs/api/request#formdata
*/
formData(): Promise<FormData>;
/**
* Adds validated data to the request.
*
* @param target - The target of the validation.
* @param data - The validated data to add.
*/
addValidatedData(target: keyof ValidationTargets, data: {}): void;
/**
* Gets validated data from the request.
*
* @param target - The target of the validation.
* @returns The validated data.
*
* @see https://hono.dev/docs/api/request#valid
*/
valid<T extends keyof I & keyof ValidationTargets>(target: T): InputToDataByTarget<I, T>;
/**
* `.url()` can get the request url strings.
*
* @see {@link https://hono.dev/docs/api/request#url}
*
* @example
* ```ts
* app.get('/about/me', (c) => {
* const url = c.req.url // `http://localhost:8787/about/me`
* ...
* })
* ```
*/
get url(): string;
/**
* `.method()` can get the method name of the request.
*
* @see {@link https://hono.dev/docs/api/request#method}
*
* @example
* ```ts
* app.get('/about/me', (c) => {
* const method = c.req.method // `GET`
* })
* ```
*/
get method(): string;
/**
* `.matchedRoutes()` can return a matched route in the handler
*
* @see {@link https://hono.dev/docs/api/request#matchedroutes}
*
* @example
* ```ts
* app.use('*', async function logger(c, next) {
* await next()
* c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
* const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
* console.log(
* method,
* ' ',
* path,
* ' '.repeat(Math.max(10 - path.length, 0)),
* name,
* i === c.req.routeIndex ? '<- respond from here' : ''
* )
* })
* })
* ```
*/
get matchedRoutes(): RouterRoute[];
/**
* `routePath()` can retrieve the path registered within the handler
*
* @see {@link https://hono.dev/docs/api/request#routepath}
*
* @example
* ```ts
* app.get('/posts/:id', (c) => {
* return c.json({ path: c.req.routePath })
* })
* ```
*/
get routePath(): string;
}
export {};
dist/types/middleware/basic-auth/index.d.ts
Types
MessageFunction
type MessageFunction = (c: Context) => string | object | Promise<string | object>;
BasicAuthOptions
type BasicAuthOptions = { username: string; password: string; realm?: string; hashFunction?: Function; invalidUserMessage?: string | object | MessageFunction; } | { verifyUser: (username: string, password: string, c: Context) => boolean | Promise<boolean>; realm?: string; hashFunction?: Function; invalidUserMessage?: string | object | MessageFunction; };
Functions
basicAuth
/** * Basic Auth Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/basic-auth} * * @param {BasicAuthOptions} options - The options for the basic authentication middleware. * @param {string} options.username - The username for authentication. * @param {string} options.password - The password for authentication. * @param {string} [options.realm="Secure Area"] - The realm attribute for the WWW-Authenticate header. * @param {Function} [options.hashFunction] - The hash function used for secure comparison. * @param {Function} [options.verifyUser] - The function to verify user credentials. * @param {string | object | MessageFunction} [options.invalidUserMessage="Unauthorized"] - The invalid user message. * @returns {MiddlewareHandler} The middleware handler function. * @throws {HTTPException} If neither "username and password" nor "verifyUser" options are provided. * * @example * ```ts * const app = new Hono() * * app.use( * '/auth/*', * basicAuth({ * username: 'hono', * password: 'acoolproject', * }) * ) * * app.get('/auth/page', (c) => { * return c.text('You are authorized') * }) * ``` */ export declare const basicAuth: (options: BasicAuthOptions, ...users: { username: string; password: string; }[]) => MiddlewareHandler;
All
/**
* @module
* Basic Auth Middleware for Hono.
*/
import type { Context } from '../../context';
import type { MiddlewareHandler } from '../../types';
type MessageFunction = (c: Context) => string | object | Promise<string | object>;
type BasicAuthOptions = {
username: string;
password: string;
realm?: string;
hashFunction?: Function;
invalidUserMessage?: string | object | MessageFunction;
} | {
verifyUser: (username: string, password: string, c: Context) => boolean | Promise<boolean>;
realm?: string;
hashFunction?: Function;
invalidUserMessage?: string | object | MessageFunction;
};
/**
* Basic Auth Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/basic-auth}
*
* @param {BasicAuthOptions} options - The options for the basic authentication middleware.
* @param {string} options.username - The username for authentication.
* @param {string} options.password - The password for authentication.
* @param {string} [options.realm="Secure Area"] - The realm attribute for the WWW-Authenticate header.
* @param {Function} [options.hashFunction] - The hash function used for secure comparison.
* @param {Function} [options.verifyUser] - The function to verify user credentials.
* @param {string | object | MessageFunction} [options.invalidUserMessage="Unauthorized"] - The invalid user message.
* @returns {MiddlewareHandler} The middleware handler function.
* @throws {HTTPException} If neither "username and password" nor "verifyUser" options are provided.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(
* '/auth/*',
* basicAuth({
* username: 'hono',
* password: 'acoolproject',
* })
* )
*
* app.get('/auth/page', (c) => {
* return c.text('You are authorized')
* })
* ```
*/
export declare const basicAuth: (options: BasicAuthOptions, ...users: {
username: string;
password: string;
}[]) => MiddlewareHandler;
export {};
dist/types/helper/websocket/index.d.ts
Interfaces
WSEvents
/** * WebSocket Event Listeners type */ export interface WSEvents<T = unknown> { onOpen?: (evt: Event, ws: WSContext<T>) => void; onMessage?: (evt: MessageEvent<WSMessageReceive>, ws: WSContext<T>) => void; onClose?: (evt: CloseEvent, ws: WSContext<T>) => void; onError?: (evt: Event, ws: WSContext<T>) => void; }
WSContextInit
/** * An argument for WSContext class */ export interface WSContextInit<T = unknown> { send(data: string | ArrayBuffer, options: SendOptions): void; close(code?: number, reason?: string): void; raw?: T; readyState: WSReadyState; url?: string | URL | null; protocol?: string | null; }
SendOptions
/** * Options for sending message */ export interface SendOptions { compress?: boolean; }
WebSocketHelperDefineContext
export interface WebSocketHelperDefineContext { }
Types
UpgradeWebSocket
/** * Upgrade WebSocket Type */ export type UpgradeWebSocket<T = unknown, U = any, _WSEvents = WSEvents<T>> = (createEvents: (c: Context) => _WSEvents | Promise<_WSEvents>, options?: U) => MiddlewareHandler<any, string, { outputFormat: "ws"; }>;
WSReadyState
/** * ReadyState for WebSocket */ export type WSReadyState = 0 | 1 | 2 | 3;
WSMessageReceive
export type WSMessageReceive = string | Blob | ArrayBufferLike;
WebSocketHelperDefineHandler
export type WebSocketHelperDefineHandler<T, U> = (c: Context, events: WSEvents<T>, options?: U) => Promise<Response | void> | Response | void;
Functions
createWSMessageEvent
export declare const createWSMessageEvent: (source: WSMessageReceive) => MessageEvent<WSMessageReceive>;
defineWebSocketHelper
/** * Create a WebSocket adapter/helper */ export declare const defineWebSocketHelper: <T = unknown, U = any>(handler: WebSocketHelperDefineHandler<T, U>) => UpgradeWebSocket<T, U>;
All
/**
* @module
* WebSocket Helper for Hono.
*/
import type { Context } from '../../context';
import type { MiddlewareHandler } from '../../types';
/**
* WebSocket Event Listeners type
*/
export interface WSEvents<T = unknown> {
onOpen?: (evt: Event, ws: WSContext<T>) => void;
onMessage?: (evt: MessageEvent<WSMessageReceive>, ws: WSContext<T>) => void;
onClose?: (evt: CloseEvent, ws: WSContext<T>) => void;
onError?: (evt: Event, ws: WSContext<T>) => void;
}
/**
* Upgrade WebSocket Type
*/
export type UpgradeWebSocket<T = unknown, U = any, _WSEvents = WSEvents<T>> = (createEvents: (c: Context) => _WSEvents | Promise<_WSEvents>, options?: U) => MiddlewareHandler<any, string, {
outputFormat: "ws";
}>;
/**
* ReadyState for WebSocket
*/
export type WSReadyState = 0 | 1 | 2 | 3;
/**
* An argument for WSContext class
*/
export interface WSContextInit<T = unknown> {
send(data: string | ArrayBuffer, options: SendOptions): void;
close(code?: number, reason?: string): void;
raw?: T;
readyState: WSReadyState;
url?: string | URL | null;
protocol?: string | null;
}
/**
* Options for sending message
*/
export interface SendOptions {
compress?: boolean;
}
/**
* A context for controlling WebSockets
*/
export declare class WSContext<T = unknown> {
constructor(init: WSContextInit<T>);
send(source: string | ArrayBuffer | Uint8Array, options?: SendOptions): void;
raw?: T;
binaryType: BinaryType;
get readyState(): WSReadyState;
url: URL | null;
protocol: string | null;
close(code?: number, reason?: string): void;
}
export type WSMessageReceive = string | Blob | ArrayBufferLike;
export declare const createWSMessageEvent: (source: WSMessageReceive) => MessageEvent<WSMessageReceive>;
export interface WebSocketHelperDefineContext {
}
export type WebSocketHelperDefineHandler<T, U> = (c: Context, events: WSEvents<T>, options?: U) => Promise<Response | void> | Response | void;
/**
* Create a WebSocket adapter/helper
*/
export declare const defineWebSocketHelper: <T = unknown, U = any>(handler: WebSocketHelperDefineHandler<T, U>) => UpgradeWebSocket<T, U>;
Interfaces
Router
/** * Interface representing a router. * * @template T - The type of the handler. */ export interface Router<T> { /** * The name of the router. */ name: string; /** * Adds a route to the router. * * @param method - The HTTP method (e.g., 'get', 'post'). * @param path - The path for the route. * @param handler - The handler for the route. */ add(method: string, path: string, handler: T): void; /** * Matches a route based on the given method and path. * * @param method - The HTTP method (e.g., 'get', 'post'). * @param path - The path to match. * @returns The result of the match. */ match(method: string, path: string): Result<T>; }
Types
ParamIndexMap
/** * Type representing a map of parameter indices. */ export type ParamIndexMap = Record<string, number>;
ParamStash
/** * Type representing a stash of parameters. */ export type ParamStash = string[];
Params
/** * Type representing a map of parameters. */ export type Params = Record<string, string>;
Result
/** * Type representing the result of a route match. * * The result can be in one of two formats: * 1. An array of handlers with their corresponding parameter index maps, followed by a parameter stash. * 2. An array of handlers with their corresponding parameter maps. * * Example: * * [[handler, paramIndexMap][], paramArray] * ```typescript * [ * [ * [middlewareA, {}], // '*' * [funcA, {'id': 0}], // '/user/:id/*' * [funcB, {'id': 0, 'action': 1}], // '/user/:id/:action' * ], * ['123', 'abc'] * ] * ``` * * [[handler, params][]] * ```typescript * [ * [ * [middlewareA, {}], // '*' * [funcA, {'id': '123'}], // '/user/:id/*' * [funcB, {'id': '123', 'action': 'abc'}], // '/user/:id/:action' * ] * ] * ``` */ export type Result<T> = [ [ T, ParamIndexMap ][], ParamStash ] | [ [ T, Params ][] ];
All
/**
* @module
* This module provides types definitions and variables for the routers.
*/
/**
* Constant representing all HTTP methods in uppercase.
*/
export declare const METHOD_NAME_ALL: "ALL";
/**
* Constant representing all HTTP methods in lowercase.
*/
export declare const METHOD_NAME_ALL_LOWERCASE: "all";
/**
* Array of supported HTTP methods.
*/
export declare const METHODS: readonly [
"get",
"post",
"put",
"delete",
"options",
"patch"
];
/**
* Error message indicating that a route cannot be added because the matcher is already built.
*/
export declare const MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
/**
* Interface representing a router.
*
* @template T - The type of the handler.
*/
export interface Router<T> {
/**
* The name of the router.
*/
name: string;
/**
* Adds a route to the router.
*
* @param method - The HTTP method (e.g., 'get', 'post').
* @param path - The path for the route.
* @param handler - The handler for the route.
*/
add(method: string, path: string, handler: T): void;
/**
* Matches a route based on the given method and path.
*
* @param method - The HTTP method (e.g., 'get', 'post').
* @param path - The path to match.
* @returns The result of the match.
*/
match(method: string, path: string): Result<T>;
}
/**
* Type representing a map of parameter indices.
*/
export type ParamIndexMap = Record<string, number>;
/**
* Type representing a stash of parameters.
*/
export type ParamStash = string[];
/**
* Type representing a map of parameters.
*/
export type Params = Record<string, string>;
/**
* Type representing the result of a route match.
*
* The result can be in one of two formats:
* 1. An array of handlers with their corresponding parameter index maps, followed by a parameter stash.
* 2. An array of handlers with their corresponding parameter maps.
*
* Example:
*
* [[handler, paramIndexMap][], paramArray]
* ```typescript
* [
* [
* [middlewareA, {}], // '*'
* [funcA, {'id': 0}], // '/user/:id/*'
* [funcB, {'id': 0, 'action': 1}], // '/user/:id/:action'
* ],
* ['123', 'abc']
* ]
* ```
*
* [[handler, params][]]
* ```typescript
* [
* [
* [middlewareA, {}], // '*'
* [funcA, {'id': '123'}], // '/user/:id/*'
* [funcB, {'id': '123', 'action': 'abc'}], // '/user/:id/:action'
* ]
* ]
* ```
*/
export type Result<T> = [
[
T,
ParamIndexMap
][],
ParamStash
] | [
[
T,
Params
][]
];
/**
* Error class representing an unsupported path error.
*/
export declare class UnsupportedPathError extends Error {
}
dist/types/middleware/jsx-renderer/index.d.ts
Types
RendererOptions
type RendererOptions = { docType?: boolean | string; stream?: boolean | Record<string, string>; };
ComponentWithChildren
type ComponentWithChildren = (props: PropsWithChildren<PropsForRenderer & { Layout: FC; }>, c: Context) => HtmlEscapedString | Promise<HtmlEscapedString>;
Functions
jsxRenderer
/** * JSX Renderer Middleware for hono. * * @see {@link https://hono.dev/docs/middleware/builtin/jsx-renderer} * * @param {ComponentWithChildren} [component] - The component to render, which can accept children and props. * @param {RendererOptions} [options] - The options for the JSX renderer middleware. * @param {boolean | string} [options.docType=true] - The DOCTYPE to be added at the beginning of the HTML. If set to false, no DOCTYPE will be added. * @param {boolean | Record<string, string>} [options.stream=false] - If set to true, enables streaming response with default headers. If a record is provided, custom headers will be used. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.get( * '/page/*', * jsxRenderer(({ children }) => { * return ( * <html> * <body> * <header>Menu</header> * <div>{children}</div> * </body> * </html> * ) * }) * ) * * app.get('/page/about', (c) => { * return c.render(<h1>About me!</h1>) * }) * ``` */ export declare const jsxRenderer: (component?: ComponentWithChildren, options?: RendererOptions) => MiddlewareHandler;
useRequestContext
/** * useRequestContext for Hono. * * @template E - The environment type. * @template P - The parameter type. * @template I - The input type. * @returns {Context<E, P, I>} An instance of Context. * * @example * ```ts * const RequestUrlBadge: FC = () => { * const c = useRequestContext() * return <b>{c.req.url}</b> * } * * app.get('/page/info', (c) => { * return c.render( * <div> * You are accessing: <RequestUrlBadge /> * </div> * ) * }) * ``` */ export declare const useRequestContext: <E extends Env = any, P extends string = any, I extends Input = {}>() => Context<E, P, I>;
All
/**
* @module
* JSX Renderer Middleware for Hono.
*/
import type { Context, PropsForRenderer } from '../../context';
import type { FC, Context as JSXContext, PropsWithChildren } from '../../jsx';
import type { Env, Input, MiddlewareHandler } from '../../types';
import type { HtmlEscapedString } from '../../utils/html';
export declare const RequestContext: JSXContext<Context<any, any, {}> | null>;
type RendererOptions = {
docType?: boolean | string;
stream?: boolean | Record<string, string>;
};
type ComponentWithChildren = (props: PropsWithChildren<PropsForRenderer & {
Layout: FC;
}>, c: Context) => HtmlEscapedString | Promise<HtmlEscapedString>;
/**
* JSX Renderer Middleware for hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/jsx-renderer}
*
* @param {ComponentWithChildren} [component] - The component to render, which can accept children and props.
* @param {RendererOptions} [options] - The options for the JSX renderer middleware.
* @param {boolean | string} [options.docType=true] - The DOCTYPE to be added at the beginning of the HTML. If set to false, no DOCTYPE will be added.
* @param {boolean | Record<string, string>} [options.stream=false] - If set to true, enables streaming response with default headers. If a record is provided, custom headers will be used.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.get(
* '/page/*',
* jsxRenderer(({ children }) => {
* return (
* <html>
* <body>
* <header>Menu</header>
* <div>{children}</div>
* </body>
* </html>
* )
* })
* )
*
* app.get('/page/about', (c) => {
* return c.render(<h1>About me!</h1>)
* })
* ```
*/
export declare const jsxRenderer: (component?: ComponentWithChildren, options?: RendererOptions) => MiddlewareHandler;
/**
* useRequestContext for Hono.
*
* @template E - The environment type.
* @template P - The parameter type.
* @template I - The input type.
* @returns {Context<E, P, I>} An instance of Context.
*
* @example
* ```ts
* const RequestUrlBadge: FC = () => {
* const c = useRequestContext()
* return <b>{c.req.url}</b>
* }
*
* app.get('/page/info', (c) => {
* return c.render(
* <div>
* You are accessing: <RequestUrlBadge />
* </div>
* )
* })
* ```
*/
export declare const useRequestContext: <E extends Env = any, P extends string = any, I extends Input = {}>() => Context<E, P, I>;
export {};
dist/types/middleware/combine/index.d.ts
Types
Condition
type Condition = (c: Context) => boolean;
Functions
some
/** * Create a composed middleware that runs the first middleware that returns true. * * @param middleware - An array of MiddlewareHandler or Condition functions. * Middleware is applied in the order it is passed, and if any middleware exits without returning * an exception first, subsequent middleware will not be executed. * You can also pass a condition function that returns a boolean value. If returns true * the evaluation will be halted, and rest of the middleware will not be executed. * @returns A composed middleware. * * @example * ```ts * import { some } from 'hono/combine' * import { bearerAuth } from 'hono/bearer-auth' * import { myRateLimit } from '@/rate-limit' * * // If client has a valid token, then skip rate limiting. * // Otherwise, apply rate limiting. * app.use('/api/*', some( * bearerAuth({ token }), * myRateLimit({ limit: 100 }), * )); * ``` */ export declare const some: (...middleware: (MiddlewareHandler | Condition)[]) => MiddlewareHandler;
every
/** * Create a composed middleware that runs all middleware and throws an error if any of them fail. * * @param middleware - An array of MiddlewareHandler or Condition functions. * Middleware is applied in the order it is passed, and if any middleware throws an error, * subsequent middleware will not be executed. * You can also pass a condition function that returns a boolean value. If returns false * the evaluation will be halted, and rest of the middleware will not be executed. * @returns A composed middleware. * * @example * ```ts * import { some, every } from 'hono/combine' * import { bearerAuth } from 'hono/bearer-auth' * import { myCheckLocalNetwork } from '@/check-local-network' * import { myRateLimit } from '@/rate-limit' * * // If client is in local network, then skip authentication and rate limiting. * // Otherwise, apply authentication and rate limiting. * app.use('/api/*', some( * myCheckLocalNetwork(), * every( * bearerAuth({ token }), * myRateLimit({ limit: 100 }), * ), * )); * ``` */ export declare const every: (...middleware: (MiddlewareHandler | Condition)[]) => MiddlewareHandler;
except
/** * Create a composed middleware that runs all middleware except when the condition is met. * * @param condition - A string or Condition function. * If there are multiple targets to match any of them, they can be passed as an array. * If a string is passed, it will be treated as a path pattern to match. * If a Condition function is passed, it will be evaluated against the request context. * @param middleware - A composed middleware * * @example * ```ts * import { except } from 'hono/combine' * import { bearerAuth } from 'hono/bearer-auth * * // If client is accessing public API, then skip authentication. * // Otherwise, require a valid token. * app.use('/api/*', except( * '/api/public/*', * bearerAuth({ token }), * )); * ``` */ export declare const except: (condition: string | Condition | (string | Condition)[], ...middleware: MiddlewareHandler[]) => MiddlewareHandler;
All
/**
* @module
* Combine Middleware for Hono.
*/
import type { Context } from '../../context';
import type { MiddlewareHandler } from '../../types';
type Condition = (c: Context) => boolean;
/**
* Create a composed middleware that runs the first middleware that returns true.
*
* @param middleware - An array of MiddlewareHandler or Condition functions.
* Middleware is applied in the order it is passed, and if any middleware exits without returning
* an exception first, subsequent middleware will not be executed.
* You can also pass a condition function that returns a boolean value. If returns true
* the evaluation will be halted, and rest of the middleware will not be executed.
* @returns A composed middleware.
*
* @example
* ```ts
* import { some } from 'hono/combine'
* import { bearerAuth } from 'hono/bearer-auth'
* import { myRateLimit } from '@/rate-limit'
*
* // If client has a valid token, then skip rate limiting.
* // Otherwise, apply rate limiting.
* app.use('/api/*', some(
* bearerAuth({ token }),
* myRateLimit({ limit: 100 }),
* ));
* ```
*/
export declare const some: (...middleware: (MiddlewareHandler | Condition)[]) => MiddlewareHandler;
/**
* Create a composed middleware that runs all middleware and throws an error if any of them fail.
*
* @param middleware - An array of MiddlewareHandler or Condition functions.
* Middleware is applied in the order it is passed, and if any middleware throws an error,
* subsequent middleware will not be executed.
* You can also pass a condition function that returns a boolean value. If returns false
* the evaluation will be halted, and rest of the middleware will not be executed.
* @returns A composed middleware.
*
* @example
* ```ts
* import { some, every } from 'hono/combine'
* import { bearerAuth } from 'hono/bearer-auth'
* import { myCheckLocalNetwork } from '@/check-local-network'
* import { myRateLimit } from '@/rate-limit'
*
* // If client is in local network, then skip authentication and rate limiting.
* // Otherwise, apply authentication and rate limiting.
* app.use('/api/*', some(
* myCheckLocalNetwork(),
* every(
* bearerAuth({ token }),
* myRateLimit({ limit: 100 }),
* ),
* ));
* ```
*/
export declare const every: (...middleware: (MiddlewareHandler | Condition)[]) => MiddlewareHandler;
/**
* Create a composed middleware that runs all middleware except when the condition is met.
*
* @param condition - A string or Condition function.
* If there are multiple targets to match any of them, they can be passed as an array.
* If a string is passed, it will be treated as a path pattern to match.
* If a Condition function is passed, it will be evaluated against the request context.
* @param middleware - A composed middleware
*
* @example
* ```ts
* import { except } from 'hono/combine'
* import { bearerAuth } from 'hono/bearer-auth
*
* // If client is accessing public API, then skip authentication.
* // Otherwise, require a valid token.
* app.use('/api/*', except(
* '/api/public/*',
* bearerAuth({ token }),
* ));
* ```
*/
export declare const except: (condition: string | Condition | (string | Condition)[], ...middleware: MiddlewareHandler[]) => MiddlewareHandler;
export {};
dist/types/helper/adapter/index.d.ts
Types
Runtime
export type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other";
Functions
env
export declare const env: <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime) => T & C["env"];
getRuntimeKey
export declare const getRuntimeKey: () => Runtime;
checkUserAgentEquals
export declare const checkUserAgentEquals: (platform: string) => boolean;
All
/**
* @module
* Adapter Helper for Hono.
*/
import type { Context } from '../../context';
export type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other";
export declare const env: <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime) => T & C["env"];
export declare const knownUserAgents: Partial<Record<Runtime, string>>;
export declare const getRuntimeKey: () => Runtime;
export declare const checkUserAgentEquals: (platform: string) => boolean;
Functions
renderToReadableStream
/** * @experimental * `renderToReadableStream()` is an experimental feature. * The API might be changed. */ export declare const renderToReadableStream: (content: HtmlEscapedString | JSXNode | Promise<HtmlEscapedString>, onError?: (e: unknown) => string | void) => ReadableStream<Uint8Array>;
All
/**
* @module
* This module enables JSX to supports streaming Response.
*/
import type { HtmlEscapedString } from '../utils/html';
import { JSXNode } from './base';
import type { FC, PropsWithChildren } from './';
/**
* @experimental
* `Suspense` is an experimental feature.
* The API might be changed.
*/
export declare const Suspense: FC<PropsWithChildren<{
fallback: any;
}>>;
/**
* @experimental
* `renderToReadableStream()` is an experimental feature.
* The API might be changed.
*/
export declare const renderToReadableStream: (content: HtmlEscapedString | JSXNode | Promise<HtmlEscapedString>, onError?: (e: unknown) => string | void) => ReadableStream<Uint8Array>;
dist/types/helper/factory/index.d.ts
Types
InitApp
type InitApp<E extends Env = Env> = (app: Hono<E>) => void;
Interfaces
CreateHandlersInterface
export interface CreateHandlersInterface<E extends Env, P extends string> { <I extends Input = {}, R extends HandlerResponse<any> = any, E2 extends Env = E>(handler1: H<E2, P, I, R>): [ H<E2, P, I, R> ]; <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[ E, E2 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>): [ H<E2, P, I, R>, H<E3, P, I2, R> ]; <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[ E, E2, E3 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>): [ H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R> ]; <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[ E, E2, E3, E4 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>): [ H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R> ]; <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, R extends HandlerResponse<any> = any, 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 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>): [ H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R>, H<E6, P, I5, R> ]; <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, R extends HandlerResponse<any> = any, 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 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>): [ H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R>, H<E6, P, I5, R>, H<E7, P, I6, R> ]; <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, R extends HandlerResponse<any> = any, 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 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>, handler7: H<E8, P, I7, R>): [ H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R>, H<E6, P, I5, R>, H<E7, P, I6, R>, H<E8, P, I7, R> ]; <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, R extends HandlerResponse<any> = any, 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 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>, handler7: H<E8, P, I7, R>, handler8: H<E9, P, I8, R>): [ H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R>, H<E6, P, I5, R>, H<E7, P, I6, R>, H<E8, P, I7, R>, H<E9, P, I8, R> ]; <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, R extends HandlerResponse<any> = any, 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 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>, handler7: H<E8, P, I7, R>, handler8: H<E9, P, I8, R>, handler9: H<E10, P, I9, R>): [ H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R>, H<E6, P, I5, R>, H<E7, P, I6, R>, H<E8, P, I7, R>, H<E9, P, I8, R>, H<E10, P, I9, R> ]; <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, R extends HandlerResponse<any> = any, 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 ]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>, handler7: H<E8, P, I7, R>, handler8: H<E9, P, I8, R>, handler9: H<E10, P, I9, R>, handler10: H<E11, P, I10, R>): [ H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R>, H<E6, P, I5, R>, H<E7, P, I6, R>, H<E8, P, I7, R>, H<E9, P, I8, R>, H<E10, P, I9, R>, H<E11, P, I10, R> ]; }
Functions
createFactory
export declare const createFactory: <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }) => Factory<E, P>;
createMiddleware
export declare const createMiddleware: <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>;
All
/**
* @module
* Factory Helper for Hono.
*/
import { Hono } from '../../hono';
import type { Env, H, HandlerResponse, Input, IntersectNonAnyTypes, MiddlewareHandler } from '../../types';
type InitApp<E extends Env = Env> = (app: Hono<E>) => void;
export interface CreateHandlersInterface<E extends Env, P extends string> {
<I extends Input = {}, R extends HandlerResponse<any> = any, E2 extends Env = E>(handler1: H<E2, P, I, R>): [
H<E2, P, I, R>
];
<I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[
E,
E2
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>
];
<I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[
E,
E2,
E3
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>,
H<E4, P, I3, R>
];
<I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[
E,
E2,
E3,
E4
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>,
H<E4, P, I3, R>,
H<E5, P, I4, R>
];
<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, R extends HandlerResponse<any> = any, 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
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>,
H<E4, P, I3, R>,
H<E5, P, I4, R>,
H<E6, P, I5, R>
];
<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, R extends HandlerResponse<any> = any, 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
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>,
H<E4, P, I3, R>,
H<E5, P, I4, R>,
H<E6, P, I5, R>,
H<E7, P, I6, R>
];
<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, R extends HandlerResponse<any> = any, 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
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>, handler7: H<E8, P, I7, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>,
H<E4, P, I3, R>,
H<E5, P, I4, R>,
H<E6, P, I5, R>,
H<E7, P, I6, R>,
H<E8, P, I7, R>
];
<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, R extends HandlerResponse<any> = any, 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
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>, handler7: H<E8, P, I7, R>, handler8: H<E9, P, I8, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>,
H<E4, P, I3, R>,
H<E5, P, I4, R>,
H<E6, P, I5, R>,
H<E7, P, I6, R>,
H<E8, P, I7, R>,
H<E9, P, I8, R>
];
<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, R extends HandlerResponse<any> = any, 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
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>, handler7: H<E8, P, I7, R>, handler8: H<E9, P, I8, R>, handler9: H<E10, P, I9, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>,
H<E4, P, I3, R>,
H<E5, P, I4, R>,
H<E6, P, I5, R>,
H<E7, P, I6, R>,
H<E8, P, I7, R>,
H<E9, P, I8, R>,
H<E10, P, I9, R>
];
<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, R extends HandlerResponse<any> = any, 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
]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R>, handler3: H<E4, P, I3, R>, handler4: H<E5, P, I4, R>, handler5: H<E6, P, I5, R>, handler6: H<E7, P, I6, R>, handler7: H<E8, P, I7, R>, handler8: H<E9, P, I8, R>, handler9: H<E10, P, I9, R>, handler10: H<E11, P, I10, R>): [
H<E2, P, I, R>,
H<E3, P, I2, R>,
H<E4, P, I3, R>,
H<E5, P, I4, R>,
H<E6, P, I5, R>,
H<E7, P, I6, R>,
H<E8, P, I7, R>,
H<E9, P, I8, R>,
H<E10, P, I9, R>,
H<E11, P, I10, R>
];
}
export declare class Factory<E extends Env = any, P extends string = any> {
constructor(init?: {
initApp?: InitApp<E>;
});
createApp: () => Hono<E>;
createMiddleware: <I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>;
createHandlers: CreateHandlersInterface<E, P>;
}
export declare const createFactory: <E extends Env = any, P extends string = any>(init?: {
initApp?: InitApp<E>;
}) => Factory<E, P>;
export declare const createMiddleware: <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>;
export {};
dist/types/middleware/cache/index.d.ts
Functions
cache
/** * Cache Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/cache} * * @param {Object} options - The options for the cache middleware. * @param {string | Function} options.cacheName - The name of the cache. Can be used to store multiple caches with different identifiers. * @param {boolean} [options.wait=false] - A boolean indicating if Hono should wait for the Promise of the `cache.put` function to resolve before continuing with the request. Required to be true for the Deno environment. * @param {string} [options.cacheControl] - A string of directives for the `Cache-Control` header. * @param {string | string[]} [options.vary] - Sets the `Vary` header in the response. If the original response header already contains a `Vary` header, the values are merged, removing any duplicates. * @param {Function} [options.keyGenerator] - Generates keys for every request in the `cacheName` store. This can be used to cache data based on request parameters or context parameters. * @returns {MiddlewareHandler} The middleware handler function. * @throws {Error} If the `vary` option includes "*". * * @example * ```ts * app.get( * '*', * cache({ * cacheName: 'my-app', * cacheControl: 'max-age=3600', * }) * ) * ``` */ export declare const cache: (options: { cacheName: string | ((c: Context) => Promise<string> | string); wait?: boolean; cacheControl?: string; vary?: string | string[]; keyGenerator?: (c: Context) => Promise<string> | string; }) => MiddlewareHandler;
All
/**
* @module
* Cache Middleware for Hono.
*/
import type { Context } from '../../context';
import type { MiddlewareHandler } from '../../types';
/**
* Cache Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/cache}
*
* @param {Object} options - The options for the cache middleware.
* @param {string | Function} options.cacheName - The name of the cache. Can be used to store multiple caches with different identifiers.
* @param {boolean} [options.wait=false] - A boolean indicating if Hono should wait for the Promise of the `cache.put` function to resolve before continuing with the request. Required to be true for the Deno environment.
* @param {string} [options.cacheControl] - A string of directives for the `Cache-Control` header.
* @param {string | string[]} [options.vary] - Sets the `Vary` header in the response. If the original response header already contains a `Vary` header, the values are merged, removing any duplicates.
* @param {Function} [options.keyGenerator] - Generates keys for every request in the `cacheName` store. This can be used to cache data based on request parameters or context parameters.
* @returns {MiddlewareHandler} The middleware handler function.
* @throws {Error} If the `vary` option includes "*".
*
* @example
* ```ts
* app.get(
* '*',
* cache({
* cacheName: 'my-app',
* cacheControl: 'max-age=3600',
* })
* )
* ```
*/
export declare const cache: (options: {
cacheName: string | ((c: Context) => Promise<string> | string);
wait?: boolean;
cacheControl?: string;
vary?: string | string[];
keyGenerator?: (c: Context) => Promise<string> | string;
}) => MiddlewareHandler;
dist/types/middleware/method-override/index.d.ts
Types
MethodOverrideOptions
type MethodOverrideOptions = { app: Hono<any, any, any>; } & ({ form?: string; header?: never; query?: never; } | { form?: never; header: string; query?: never; } | { form?: never; header?: never; query: string; });
Functions
methodOverride
/** * Method Override Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/method-override} * * @param {MethodOverrideOptions} options - The options for the method override middleware. * @param {Hono} options.app - The instance of Hono is used in your application. * @param {string} [options.form=_method] - Form key with a value containing the method name. * @param {string} [options.header] - Header name with a value containing the method name. * @param {string} [options.query] - Query parameter key with a value containing the method name. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * // If no options are specified, the value of `_method` in the form, * // e.g. DELETE, is used as the method. * app.use('/posts', methodOverride({ app })) * * app.delete('/posts', (c) => { * // .... * }) * ``` */ export declare const methodOverride: (options: MethodOverrideOptions) => MiddlewareHandler;
All
/**
* @module
* Method Override Middleware for Hono.
*/
import type { Hono } from '../../hono';
import type { MiddlewareHandler } from '../../types';
type MethodOverrideOptions = {
app: Hono<any, any, any>;
} & ({
form?: string;
header?: never;
query?: never;
} | {
form?: never;
header: string;
query?: never;
} | {
form?: never;
header?: never;
query: string;
});
/**
* Method Override Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/method-override}
*
* @param {MethodOverrideOptions} options - The options for the method override middleware.
* @param {Hono} options.app - The instance of Hono is used in your application.
* @param {string} [options.form=_method] - Form key with a value containing the method name.
* @param {string} [options.header] - Header name with a value containing the method name.
* @param {string} [options.query] - Query parameter key with a value containing the method name.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* // If no options are specified, the value of `_method` in the form,
* // e.g. DELETE, is used as the method.
* app.use('/posts', methodOverride({ app }))
*
* app.delete('/posts', (c) => {
* // ....
* })
* ```
*/
export declare const methodOverride: (options: MethodOverrideOptions) => MiddlewareHandler;
export {};
Types
Bindings
export type Bindings = object;
Variables
export type Variables = object;
BlankEnv
export type BlankEnv = {};
Env
export type Env = { Bindings?: Bindings; Variables?: Variables; };
Next
export type Next = () => Promise<void>;
ExtractInput
export type ExtractInput<I extends Input | Input["in"]> = I extends Input ? unknown extends I["in"] ? {} : I["in"] : I;
Input
export type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; };
BlankSchema
export type BlankSchema = {};
BlankInput
export type BlankInput = {};
HandlerResponse
export type HandlerResponse<O> = Response | TypedResponse<O> | Promise<Response | TypedResponse<O>>;
Handler
export type Handler<E extends Env = any, P extends string = any, I extends Input = BlankInput, R extends HandlerResponse<any> = any> = (c: Context<E, P, I>, next: Next) => R;
MiddlewareHandler
export type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void>;
H
export type H<E extends Env = any, P extends string = any, I extends Input = BlankInput, R extends HandlerResponse<any> = any> = Handler<E, P, I, R> | MiddlewareHandler<E, P, I>;
NotFoundHandler
export type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response>;
ErrorHandler
export type ErrorHandler<E extends Env = any> = (err: Error | HTTPResponseError, c: Context<E>) => Response | Promise<Response>;
ExtractStringKey
type ExtractStringKey<S> = keyof S & string;
ToSchema
export type ToSchema<M extends string, P extends string, I extends Input | Input["in"], RorO> = Simplify<{ [K in P]: { [K2 in M as AddDollar<K2>]: Simplify<{ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { output: {}; outputFormat: ResponseFormat; status: StatusCode; } : RorO extends TypedResponse<infer T, infer U, infer F> ? { output: unknown extends T ? {} : T; outputFormat: I extends { outputFormat: string; } ? I["outputFormat"] : F; status: U; } : { output: unknown extends RorO ? {} : RorO; outputFormat: unknown extends RorO ? "json" : I extends { outputFormat: string; } ? I["outputFormat"] : "json"; status: StatusCode; })>; }; }>;
Schema
export type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; };
ChangePathOfSchema
type ChangePathOfSchema<S extends Schema, Path extends string> = keyof S extends never ? { [K in Path]: {}; } : { [K in keyof S as Path]: S[K]; };
Endpoint
export type Endpoint = { input: any; output: any; outputFormat: ResponseFormat; status: StatusCode; };
ExtractParams
type ExtractParams<Path extends string> = string extends Path ? Record<string, string> : Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? { [K in Param | keyof ExtractParams<`/${Rest}`>]: string; } : Path extends `${infer _Start}:${infer Param}` ? { [K in Param]: string; } : never;
FlattenIfIntersect
type FlattenIfIntersect<T> = T extends infer O ? { [K in keyof O]: O[K]; } : never;
MergeSchemaPath
export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> = { [P in keyof OrigSchema as MergePath<SubPath, P & string>]: [ OrigSchema[P] ] extends [ Record<string, Endpoint> ] ? { [M in keyof OrigSchema[P]]: MergeEndpointParamsWithPath<OrigSchema[P][M], SubPath>; } : never; };
MergeEndpointParamsWithPath
type MergeEndpointParamsWithPath<T extends Endpoint, SubPath extends string> = T extends unknown ? { input: T["input"] extends { param: infer _; } ? ExtractParams<SubPath> extends never ? T["input"] : FlattenIfIntersect<T["input"] & { param: { [K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}` ? Prefix : K]: string; }; }> : RemoveBlankRecord<ExtractParams<SubPath>> extends never ? T["input"] : T["input"] & { param: { [K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}` ? Prefix : K]: string; }; }; output: T["output"]; outputFormat: T["outputFormat"]; status: T["status"]; } : never;
AddParam
export type AddParam<I, P extends string> = ParamKeys<P> extends never ? I : I extends { param: infer _; } ? I : I & { param: UnionToIntersection<ParamKeyToRecord<ParamKeys<P>>>; };
AddDollar
type AddDollar<T extends string> = `$${Lowercase<T>}`;
MergePath
export type MergePath<A extends string, B extends string> = B extends "" ? MergePath<A, "/"> : 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}`;
KnownResponseFormat
export type KnownResponseFormat = "json" | "text" | "redirect";
ResponseFormat
export type ResponseFormat = KnownResponseFormat | string;
TypedResponse
export type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : ResponseFormat> = { _data: T; _status: U; _format: F; };
MergeTypedResponse
type MergeTypedResponse<T> = T extends Promise<infer T2> ? T2 extends TypedResponse ? T2 : TypedResponse : T extends TypedResponse ? T : TypedResponse;
FormValue
export type FormValue = string | Blob;
ParsedFormValue
export type ParsedFormValue = string | File;
ValidationTargets
export type ValidationTargets<T extends FormValue = ParsedFormValue, P extends string = string> = { json: any; form: Record<string, T | T[]>; query: Record<string, string | string[]>; param: Record<P, P extends `${infer _}?` ? string | undefined : string>; header: Record<RequestHeader | CustomHeader, string>; cookie: Record<string, string>; };
ParamKeyName
type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Name}{${infer Rest}` ? Rest extends `${infer _Pattern}?` ? `${Name}?` : Name : NameWithPattern;
ParamKey
type ParamKey<Component> = Component extends `:${infer NameWithPattern}` ? ParamKeyName<NameWithPattern> : never;
ParamKeys
export type ParamKeys<Path> = Path extends `${infer Component}/${infer Rest}` ? ParamKey<Component> | ParamKeys<Rest> : ParamKey<Path>;
ParamKeyToRecord
export type ParamKeyToRecord<T extends string> = T extends `${infer R}?` ? Record<R, string | undefined> : { [K in T]: string; };
InputToDataByTarget
export type InputToDataByTarget<T extends Input["out"], Target extends keyof ValidationTargets> = T extends { [K in Target]: infer R; } ? R : never;
RemoveQuestion
export type RemoveQuestion<T> = T extends `${infer R}?` ? R : T;
ExtractSchema
export type ExtractSchema<T> = UnionToIntersection<T extends HonoBase<infer _, infer S, any> ? S : never>;
EnvOrEmpty
type EnvOrEmpty<T> = T extends Env ? (Env extends T ? {} : T) : T;
IntersectNonAnyTypes
export type IntersectNonAnyTypes<T extends any[]> = T extends [ infer Head, ...infer Rest ] ? IfAnyThenEmptyObject<EnvOrEmpty<Head>> & IntersectNonAnyTypes<Rest> : {};
Interfaces
RouterRoute
export interface RouterRoute { path: string; method: string; handler: H; }
HTTPResponseError
export interface HTTPResponseError extends Error { getResponse: () => Response; }
HandlerInterface
export interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> { <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<S>, I extends Input = BlankInput, R extends HandlerResponse<any> = any, E2 extends Env = E>(handler: H<E2, P, I, R>): HonoBase<IntersectNonAnyTypes<[ E, E2 ]>, S & ToSchema<M, P, I, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3 ]>, S & ToSchema<M, P, I2, MergeTypedResponse<R>>, BasePath>; <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>): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4 ]>, S & ToSchema<M, P, I3, MergeTypedResponse<R>>, BasePath>; <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> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I2, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5 ]>, S & ToSchema<M, P, I4, MergeTypedResponse<R>>, BasePath>; <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> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I3, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6 ]>, S & ToSchema<M, P, I5, MergeTypedResponse<R>>, BasePath>; <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: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4, R> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I4, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [ H<E2, P, I>, H<E3, P, I2>, H<E4, P, I3>, H<E5, P, I4>, H<E6, P, I5>, H<E7, P, I6, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7 ]>, S & ToSchema<M, P, I6, MergeTypedResponse<R>>, BasePath>; <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: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5, R> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I5, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [ H<E2, P, I>, H<E3, P, I2>, H<E4, P, I3>, H<E5, P, I4>, H<E6, P, I5>, H<E7, P, I6>, H<E8, P, I7, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8 ]>, S & ToSchema<M, P, I7, MergeTypedResponse<R>>, BasePath>; <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: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6, R> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I6, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [ H<E2, P, I>, H<E3, P, I2>, H<E4, P, I3>, H<E5, P, I4>, H<E6, P, I5>, H<E7, P, I6>, H<E8, P, I7>, H<E9, P, I8, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9 ]>, S & ToSchema<M, P, I8, MergeTypedResponse<R>>, BasePath>; <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: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7, R> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I7, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [ H<E2, P, I>, H<E3, P, I2>, H<E4, P, I3>, H<E5, P, I4>, H<E6, P, I5>, H<E7, P, I6>, H<E8, P, I7>, H<E9, P, I8>, H<E10, P, I9, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10 ]>, S & ToSchema<M, P, I9, MergeTypedResponse<R>>, BasePath>; <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: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8, R> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I8, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [ H<E2, P, I>, H<E3, P, I2>, H<E4, P, I3>, H<E5, P, I4>, H<E6, P, I5>, H<E7, P, I6>, H<E8, P, I7>, H<E9, P, I8>, H<E10, P, I9>, H<E11, P, I10, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11 ]>, S & ToSchema<M, P, I10, MergeTypedResponse<R>>, BasePath>; <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: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8>, H<E10, MergedPath, I9, R> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I9, MergeTypedResponse<R>>, BasePath>; <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: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8>, H<E10, MergedPath, I9>, H<E11, MergedPath, I10, R> ]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I10, MergeTypedResponse<R>>, BasePath>; <P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<S>, I extends Input = BlankInput, R extends HandlerResponse<any> = any>(...handlers: H<E, P, I, R>[]): HonoBase<E, S & ToSchema<M, P, I, MergeTypedResponse<R>>, BasePath>; <P extends string, I extends Input = BlankInput, R extends HandlerResponse<any> = any>(path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>; <P extends string, R extends HandlerResponse<any> = any, I extends Input = BlankInput>(path: P): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>; }
MiddlewareHandlerInterface
export interface MiddlewareHandlerInterface<E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/"> { <E2 extends Env = E>(...handlers: MiddlewareHandler<E2, MergePath<BasePath, ExtractStringKey<S>>>[]): HonoBase<IntersectNonAnyTypes<[ E, E2 ]>, S, BasePath>; <E2 extends Env = E>(handler: MiddlewareHandler<E2, MergePath<BasePath, ExtractStringKey<S>>>): HonoBase<IntersectNonAnyTypes<[ E, E2 ]>, S, BasePath>; <E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[ E, E2 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, E2 extends Env = E>(path: P, handler: MiddlewareHandler<E2, MergedPath>): HonoBase<IntersectNonAnyTypes<[ E, E2 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[ E, E2, E3 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[ E, E2 ]>>(path: P, ...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[ E, E2, E3, E4 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[ E, E2, E3 ]>>(path: P, ...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <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 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[ E, E2, E3, E4 ]>>(path: P, ...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <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 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <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 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P>, MiddlewareHandler<E8, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <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 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P>, MiddlewareHandler<E8, P>, MiddlewareHandler<E9, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P>, MiddlewareHandler<E8, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <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 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P>, MiddlewareHandler<E8, P>, MiddlewareHandler<E9, P>, MiddlewareHandler<E10, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P>, MiddlewareHandler<E8, P>, MiddlewareHandler<E9, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <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 ]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P>, MiddlewareHandler<E8, P>, MiddlewareHandler<E9, P>, MiddlewareHandler<E10, P>, MiddlewareHandler<E11, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11 ]>, S, BasePath>; <P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [ MiddlewareHandler<E2, P>, MiddlewareHandler<E3, P>, MiddlewareHandler<E4, P>, MiddlewareHandler<E5, P>, MiddlewareHandler<E6, P>, MiddlewareHandler<E7, P>, MiddlewareHandler<E8, P>, MiddlewareHandler<E9, P>, MiddlewareHandler<E10, P> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10 ]>, ChangePathOfSchema<S, MergedPath>, BasePath>; <P extends string, E2 extends Env = E>(path: P, ...handlers: MiddlewareHandler<E2, MergePath<BasePath, P>>[]): HonoBase<E, S, BasePath>; }
OnHandlerInterface
export interface OnHandlerInterface<E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/"> { <M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, E2 extends Env = E>(method: M, path: P, handler: H<E2, MergedPath, I, R>): HonoBase<IntersectNonAnyTypes<[ E, E2 ]>, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>; <M extends string, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3 ]>, S & ToSchema<M, MergePath<BasePath, P>, I2, MergeTypedResponse<R>>, BasePath>; <M extends string, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4 ]>, S & ToSchema<M, MergePath<BasePath, P>, I3, MergeTypedResponse<R>>, BasePath>; <M extends string, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5 ]>, S & ToSchema<M, MergePath<BasePath, P>, I4, MergeTypedResponse<R>>, BasePath>; <M extends string, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6 ]>, S & ToSchema<M, MergePath<BasePath, P>, I5, MergeTypedResponse<R>>, BasePath>; <M extends string, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7 ]>, S & ToSchema<M, MergePath<BasePath, P>, I6, MergeTypedResponse<R>>, BasePath>; <M extends string, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8 ]>, S & ToSchema<M, MergePath<BasePath, P>, I7, MergeTypedResponse<R>>, BasePath>; <M extends string, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9 ]>, S & ToSchema<M, MergePath<BasePath, P>, I8, MergeTypedResponse<R>>, BasePath>; <M extends string, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8>, H<E10, MergedPath, I9, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10 ]>, S & ToSchema<M, MergePath<BasePath, P>, I9, MergeTypedResponse<R>>, BasePath>; <M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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 ]>>(method: M, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8>, H<E10, MergedPath, I9>, H<E11, MergedPath, I10> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11 ]>, S & ToSchema<M, MergePath<BasePath, P>, I10, MergeTypedResponse<HandlerResponse<any>>>, BasePath>; <M extends string, P extends string, R extends HandlerResponse<any> = any, I extends Input = BlankInput>(method: M, path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, E2 extends Env = E>(methods: Ms, path: P, handler: H<E2, MergedPath, I, R>): HonoBase<IntersectNonAnyTypes<[ E, E2 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I2, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I3, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I4, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I5, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I6, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I7, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8, R> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I8, MergeTypedResponse<R>>, BasePath>; <Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8>, H<E10, MergedPath, I9> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I9, MergeTypedResponse<HandlerResponse<any>>>, BasePath>; <Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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 ]>>(methods: Ms, path: P, ...handlers: [ H<E2, MergedPath, I>, H<E3, MergedPath, I2>, H<E4, MergedPath, I3>, H<E5, MergedPath, I4>, H<E6, MergedPath, I5>, H<E7, MergedPath, I6>, H<E8, MergedPath, I7>, H<E9, MergedPath, I8>, H<E10, MergedPath, I9>, H<E11, MergedPath, I10> ]): HonoBase<IntersectNonAnyTypes<[ E, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11 ]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I10, MergeTypedResponse<HandlerResponse<any>>>, BasePath>; <P extends string, R extends HandlerResponse<any> = any, I extends Input = BlankInput>(methods: string[], path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): HonoBase<E, S & ToSchema<string, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>; <I extends Input = BlankInput, R extends HandlerResponse<any> = any>(methods: string | string[], paths: string[], ...handlers: H<E, any, I, R>[]): HonoBase<E, S & ToSchema<string, string, I, MergeTypedResponse<R>>, BasePath>; }
All
/**
* @module
* This module contains some type definitions for the Hono modules.
*/
import type { Context } from './context';
import type { HonoBase } from './hono-base';
import type { CustomHeader, RequestHeader } from './utils/headers';
import type { StatusCode } from './utils/http-status';
import type { IfAnyThenEmptyObject, IsAny, JSONValue, RemoveBlankRecord, Simplify, UnionToIntersection } from './utils/types';
export type Bindings = object;
export type Variables = object;
export type BlankEnv = {};
export type Env = {
Bindings?: Bindings;
Variables?: Variables;
};
export type Next = () => Promise<void>;
export type ExtractInput<I extends Input | Input["in"]> = I extends Input ? unknown extends I["in"] ? {} : I["in"] : I;
export type Input = {
in?: {};
out?: {};
outputFormat?: ResponseFormat;
};
export type BlankSchema = {};
export type BlankInput = {};
export interface RouterRoute {
path: string;
method: string;
handler: H;
}
export type HandlerResponse<O> = Response | TypedResponse<O> | Promise<Response | TypedResponse<O>>;
export type Handler<E extends Env = any, P extends string = any, I extends Input = BlankInput, R extends HandlerResponse<any> = any> = (c: Context<E, P, I>, next: Next) => R;
export type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void>;
export type H<E extends Env = any, P extends string = any, I extends Input = BlankInput, R extends HandlerResponse<any> = any> = Handler<E, P, I, R> | MiddlewareHandler<E, P, I>;
export type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response>;
export interface HTTPResponseError extends Error {
getResponse: () => Response;
}
export type ErrorHandler<E extends Env = any> = (err: Error | HTTPResponseError, c: Context<E>) => Response | Promise<Response>;
export interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> {
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<S>, I extends Input = BlankInput, R extends HandlerResponse<any> = any, E2 extends Env = E>(handler: H<E2, P, I, R>): HonoBase<IntersectNonAnyTypes<[
E,
E2
]>, S & ToSchema<M, P, I, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3
]>, S & ToSchema<M, P, I2, MergeTypedResponse<R>>, BasePath>;
<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>): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4
]>, S & ToSchema<M, P, I3, MergeTypedResponse<R>>, BasePath>;
<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>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I2, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5
]>, S & ToSchema<M, P, I4, MergeTypedResponse<R>>, BasePath>;
<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>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I3, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6
]>, S & ToSchema<M, P, I5, MergeTypedResponse<R>>, BasePath>;
<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: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4, R>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I4, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [
H<E2, P, I>,
H<E3, P, I2>,
H<E4, P, I3>,
H<E5, P, I4>,
H<E6, P, I5>,
H<E7, P, I6, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7
]>, S & ToSchema<M, P, I6, MergeTypedResponse<R>>, BasePath>;
<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: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5, R>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I5, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [
H<E2, P, I>,
H<E3, P, I2>,
H<E4, P, I3>,
H<E5, P, I4>,
H<E6, P, I5>,
H<E7, P, I6>,
H<E8, P, I7, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8
]>, S & ToSchema<M, P, I7, MergeTypedResponse<R>>, BasePath>;
<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: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6, R>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I6, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [
H<E2, P, I>,
H<E3, P, I2>,
H<E4, P, I3>,
H<E5, P, I4>,
H<E6, P, I5>,
H<E7, P, I6>,
H<E8, P, I7>,
H<E9, P, I8, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9
]>, S & ToSchema<M, P, I8, MergeTypedResponse<R>>, BasePath>;
<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: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7, R>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I7, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [
H<E2, P, I>,
H<E3, P, I2>,
H<E4, P, I3>,
H<E5, P, I4>,
H<E6, P, I5>,
H<E7, P, I6>,
H<E8, P, I7>,
H<E9, P, I8>,
H<E10, P, I9, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10
]>, S & ToSchema<M, P, I9, MergeTypedResponse<R>>, BasePath>;
<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: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8, R>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I8, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<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: [
H<E2, P, I>,
H<E3, P, I2>,
H<E4, P, I3>,
H<E5, P, I4>,
H<E6, P, I5>,
H<E7, P, I6>,
H<E8, P, I7>,
H<E9, P, I8>,
H<E10, P, I9>,
H<E11, P, I10, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10,
E11
]>, S & ToSchema<M, P, I10, MergeTypedResponse<R>>, BasePath>;
<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: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8>,
H<E10, MergedPath, I9, R>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I9, MergeTypedResponse<R>>, BasePath>;
<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: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8>,
H<E10, MergedPath, I9>,
H<E11, MergedPath, I10, R>
]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I10, MergeTypedResponse<R>>, BasePath>;
<P extends string = ExtractStringKey<S> extends never ? BasePath : ExtractStringKey<S>, I extends Input = BlankInput, R extends HandlerResponse<any> = any>(...handlers: H<E, P, I, R>[]): HonoBase<E, S & ToSchema<M, P, I, MergeTypedResponse<R>>, BasePath>;
<P extends string, I extends Input = BlankInput, R extends HandlerResponse<any> = any>(path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>;
<P extends string, R extends HandlerResponse<any> = any, I extends Input = BlankInput>(path: P): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>;
}
export interface MiddlewareHandlerInterface<E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/"> {
<E2 extends Env = E>(...handlers: MiddlewareHandler<E2, MergePath<BasePath, ExtractStringKey<S>>>[]): HonoBase<IntersectNonAnyTypes<[
E,
E2
]>, S, BasePath>;
<E2 extends Env = E>(handler: MiddlewareHandler<E2, MergePath<BasePath, ExtractStringKey<S>>>): HonoBase<IntersectNonAnyTypes<[
E,
E2
]>, S, BasePath>;
<E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[
E,
E2
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, E2 extends Env = E>(path: P, handler: MiddlewareHandler<E2, MergedPath>): HonoBase<IntersectNonAnyTypes<[
E,
E2
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[
E,
E2,
E3
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[
E,
E2
]>>(path: P, ...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[
E,
E2,
E3,
E4
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, E2 extends Env = E, E3 extends Env = E, E4 extends Env = IntersectNonAnyTypes<[
E,
E2,
E3
]>>(path: P, ...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<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
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, E2 extends Env = E, E3 extends Env = E, E4 extends Env = E, E5 extends Env = IntersectNonAnyTypes<[
E,
E2,
E3,
E4
]>>(path: P, ...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<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
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<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
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>,
MiddlewareHandler<E8, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<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
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>,
MiddlewareHandler<E8, P>,
MiddlewareHandler<E9, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>,
MiddlewareHandler<E8, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<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
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>,
MiddlewareHandler<E8, P>,
MiddlewareHandler<E9, P>,
MiddlewareHandler<E10, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>,
MiddlewareHandler<E8, P>,
MiddlewareHandler<E9, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<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
]>, P extends string = MergePath<BasePath, ExtractStringKey<S>>>(...handlers: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>,
MiddlewareHandler<E8, P>,
MiddlewareHandler<E9, P>,
MiddlewareHandler<E10, P>,
MiddlewareHandler<E11, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10,
E11
]>, S, BasePath>;
<P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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: [
MiddlewareHandler<E2, P>,
MiddlewareHandler<E3, P>,
MiddlewareHandler<E4, P>,
MiddlewareHandler<E5, P>,
MiddlewareHandler<E6, P>,
MiddlewareHandler<E7, P>,
MiddlewareHandler<E8, P>,
MiddlewareHandler<E9, P>,
MiddlewareHandler<E10, P>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10
]>, ChangePathOfSchema<S, MergedPath>, BasePath>;
<P extends string, E2 extends Env = E>(path: P, ...handlers: MiddlewareHandler<E2, MergePath<BasePath, P>>[]): HonoBase<E, S, BasePath>;
}
export interface OnHandlerInterface<E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/"> {
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, E2 extends Env = E>(method: M, path: P, handler: H<E2, MergedPath, I, R>): HonoBase<IntersectNonAnyTypes<[
E,
E2
]>, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>;
<M extends string, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3
]>, S & ToSchema<M, MergePath<BasePath, P>, I2, MergeTypedResponse<R>>, BasePath>;
<M extends string, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4
]>, S & ToSchema<M, MergePath<BasePath, P>, I3, MergeTypedResponse<R>>, BasePath>;
<M extends string, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5
]>, S & ToSchema<M, MergePath<BasePath, P>, I4, MergeTypedResponse<R>>, BasePath>;
<M extends string, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6
]>, S & ToSchema<M, MergePath<BasePath, P>, I5, MergeTypedResponse<R>>, BasePath>;
<M extends string, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7
]>, S & ToSchema<M, MergePath<BasePath, P>, I6, MergeTypedResponse<R>>, BasePath>;
<M extends string, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8
]>, S & ToSchema<M, MergePath<BasePath, P>, I7, MergeTypedResponse<R>>, BasePath>;
<M extends string, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9
]>, S & ToSchema<M, MergePath<BasePath, P>, I8, MergeTypedResponse<R>>, BasePath>;
<M extends string, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8>,
H<E10, MergedPath, I9, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10
]>, S & ToSchema<M, MergePath<BasePath, P>, I9, MergeTypedResponse<R>>, BasePath>;
<M extends string, P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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
]>>(method: M, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8>,
H<E10, MergedPath, I9>,
H<E11, MergedPath, I10>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10,
E11
]>, S & ToSchema<M, MergePath<BasePath, P>, I10, MergeTypedResponse<HandlerResponse<any>>>, BasePath>;
<M extends string, P extends string, R extends HandlerResponse<any> = any, I extends Input = BlankInput>(method: M, path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): HonoBase<E, S & ToSchema<M, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, R extends HandlerResponse<any> = any, I extends Input = BlankInput, E2 extends Env = E>(methods: Ms, path: P, handler: H<E2, MergedPath, I, R>): HonoBase<IntersectNonAnyTypes<[
E,
E2
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I2, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I3, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I4, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I5, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I6, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I7, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8, R>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I8, MergeTypedResponse<R>>, BasePath>;
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8>,
H<E10, MergedPath, I9>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I9, MergeTypedResponse<HandlerResponse<any>>>, BasePath>;
<Ms extends string[], P extends string, MergedPath extends MergePath<BasePath, P> = MergePath<BasePath, P>, 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
]>>(methods: Ms, path: P, ...handlers: [
H<E2, MergedPath, I>,
H<E3, MergedPath, I2>,
H<E4, MergedPath, I3>,
H<E5, MergedPath, I4>,
H<E6, MergedPath, I5>,
H<E7, MergedPath, I6>,
H<E8, MergedPath, I7>,
H<E9, MergedPath, I8>,
H<E10, MergedPath, I9>,
H<E11, MergedPath, I10>
]): HonoBase<IntersectNonAnyTypes<[
E,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10,
E11
]>, S & ToSchema<Ms[number], MergePath<BasePath, P>, I10, MergeTypedResponse<HandlerResponse<any>>>, BasePath>;
<P extends string, R extends HandlerResponse<any> = any, I extends Input = BlankInput>(methods: string[], path: P, ...handlers: H<E, MergePath<BasePath, P>, I, R>[]): HonoBase<E, S & ToSchema<string, MergePath<BasePath, P>, I, MergeTypedResponse<R>>, BasePath>;
<I extends Input = BlankInput, R extends HandlerResponse<any> = any>(methods: string | string[], paths: string[], ...handlers: H<E, any, I, R>[]): HonoBase<E, S & ToSchema<string, string, I, MergeTypedResponse<R>>, BasePath>;
}
type ExtractStringKey<S> = keyof S & string;
export type ToSchema<M extends string, P extends string, I extends Input | Input["in"], RorO> = Simplify<{
[K in P]: {
[K2 in M as AddDollar<K2>]: Simplify<{
input: AddParam<ExtractInput<I>, P>;
} & (IsAny<RorO> extends true ? {
output: {};
outputFormat: ResponseFormat;
status: StatusCode;
} : RorO extends TypedResponse<infer T, infer U, infer F> ? {
output: unknown extends T ? {} : T;
outputFormat: I extends {
outputFormat: string;
} ? I["outputFormat"] : F;
status: U;
} : {
output: unknown extends RorO ? {} : RorO;
outputFormat: unknown extends RorO ? "json" : I extends {
outputFormat: string;
} ? I["outputFormat"] : "json";
status: StatusCode;
})>;
};
}>;
export type Schema = {
[Path: string]: {
[Method: `$${Lowercase<string>}`]: Endpoint;
};
};
type ChangePathOfSchema<S extends Schema, Path extends string> = keyof S extends never ? {
[K in Path]: {};
} : {
[K in keyof S as Path]: S[K];
};
export type Endpoint = {
input: any;
output: any;
outputFormat: ResponseFormat;
status: StatusCode;
};
type ExtractParams<Path extends string> = string extends Path ? Record<string, string> : Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
[K in Param | keyof ExtractParams<`/${Rest}`>]: string;
} : Path extends `${infer _Start}:${infer Param}` ? {
[K in Param]: string;
} : never;
type FlattenIfIntersect<T> = T extends infer O ? {
[K in keyof O]: O[K];
} : never;
export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> = {
[P in keyof OrigSchema as MergePath<SubPath, P & string>]: [
OrigSchema[P]
] extends [
Record<string, Endpoint>
] ? {
[M in keyof OrigSchema[P]]: MergeEndpointParamsWithPath<OrigSchema[P][M], SubPath>;
} : never;
};
type MergeEndpointParamsWithPath<T extends Endpoint, SubPath extends string> = T extends unknown ? {
input: T["input"] extends {
param: infer _;
} ? ExtractParams<SubPath> extends never ? T["input"] : FlattenIfIntersect<T["input"] & {
param: {
[K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}` ? Prefix : K]: string;
};
}> : RemoveBlankRecord<ExtractParams<SubPath>> extends never ? T["input"] : T["input"] & {
param: {
[K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}` ? Prefix : K]: string;
};
};
output: T["output"];
outputFormat: T["outputFormat"];
status: T["status"];
} : never;
export type AddParam<I, P extends string> = ParamKeys<P> extends never ? I : I extends {
param: infer _;
} ? I : I & {
param: UnionToIntersection<ParamKeyToRecord<ParamKeys<P>>>;
};
type AddDollar<T extends string> = `$${Lowercase<T>}`;
export type MergePath<A extends string, B extends string> = B extends "" ? MergePath<A, "/"> : 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}`;
export type KnownResponseFormat = "json" | "text" | "redirect";
export type ResponseFormat = KnownResponseFormat | string;
export type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : ResponseFormat> = {
_data: T;
_status: U;
_format: F;
};
type MergeTypedResponse<T> = T extends Promise<infer T2> ? T2 extends TypedResponse ? T2 : TypedResponse : T extends TypedResponse ? T : TypedResponse;
export type FormValue = string | Blob;
export type ParsedFormValue = string | File;
export type ValidationTargets<T extends FormValue = ParsedFormValue, P extends string = string> = {
json: any;
form: Record<string, T | T[]>;
query: Record<string, string | string[]>;
param: Record<P, P extends `${infer _}?` ? string | undefined : string>;
header: Record<RequestHeader | CustomHeader, string>;
cookie: Record<string, string>;
};
type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Name}{${infer Rest}` ? Rest extends `${infer _Pattern}?` ? `${Name}?` : Name : NameWithPattern;
type ParamKey<Component> = Component extends `:${infer NameWithPattern}` ? ParamKeyName<NameWithPattern> : never;
export type ParamKeys<Path> = Path extends `${infer Component}/${infer Rest}` ? ParamKey<Component> | ParamKeys<Rest> : ParamKey<Path>;
export type ParamKeyToRecord<T extends string> = T extends `${infer R}?` ? Record<R, string | undefined> : {
[K in T]: string;
};
export type InputToDataByTarget<T extends Input["out"], Target extends keyof ValidationTargets> = T extends {
[K in Target]: infer R;
} ? R : never;
export type RemoveQuestion<T> = T extends `${infer R}?` ? R : T;
export type ExtractSchema<T> = UnionToIntersection<T extends HonoBase<infer _, infer S, any> ? S : never>;
type EnvOrEmpty<T> = T extends Env ? (Env extends T ? {} : T) : T;
export type IntersectNonAnyTypes<T extends any[]> = T extends [
infer Head,
...infer Rest
] ? IfAnyThenEmptyObject<EnvOrEmpty<Head>> & IntersectNonAnyTypes<Rest> : {};
export declare abstract class FetchEventLike {
abstract readonly request: Request;
abstract respondWith(promise: Response | Promise<Response>): void;
abstract passThroughOnException(): void;
abstract waitUntil(promise: Promise<void>): void;
}
export {};
dist/types/helper/conninfo/index.d.ts
All
/**
* @module
* ConnInfo Helper for Hono.
*/
export type { AddressType, NetAddrInfo, ConnInfo, GetConnInfo } from './types';
dist/types/middleware/jwt/index.d.ts
All
import type { JwtVariables } from './jwt';
export type { JwtVariables };
export { jwt, verify, decode, sign } from './jwt';
declare module '../..' {
interface ContextVariableMap extends JwtVariables {
}
}
dist/types/router/smart-router/index.d.ts
All
/**
* @module
* SmartRouter for Hono.
*/
export { SmartRouter } from './router';
dist/types/adapter/cloudflare-pages/index.d.ts
All
/**
* @module
* Cloudflare Pages Adapter for Hono.
*/
export { handle, handleMiddleware, serveStatic } from './handler';
export type { EventContext } from './handler';
dist/types/validator/index.d.ts
All
/**
* @module
* Validator for Hono.
*/
export { validator } from './validator';
export type { ValidationFunction } from './validator';
dist/types/jsx/jsx-runtime.d.ts
Functions
jsxAttr
export declare const jsxAttr: (key: string, v: string | Promise<string> | Record<string, string | number | null | undefined | boolean>) => HtmlEscapedString | Promise<HtmlEscapedString>;
jsxEscape
export declare const jsxEscape: (value: string) => string;
All
/**
* @module
* This module provides Hono's JSX runtime.
*/
export { jsxDEV as jsx, Fragment } from './jsx-dev-runtime';
export { jsxDEV as jsxs } from './jsx-dev-runtime';
export type { JSX } from './jsx-dev-runtime';
import { html } from '../helper/html';
import type { HtmlEscapedString } from '../utils/html';
export { html as jsxTemplate };
export declare const jsxAttr: (key: string, v: string | Promise<string> | Record<string, string | number | null | undefined | boolean>) => HtmlEscapedString | Promise<HtmlEscapedString>;
export declare const jsxEscape: (value: string) => string;
dist/types/router/linear-router/index.d.ts
All
/**
* @module
* LinearRouter for Hono.
*/
export { LinearRouter } from './router';
dist/types/adapter/netlify/index.d.ts
All
/**
* @module
* Netlify Adapter for Hono.
*/
export * from './mod';
dist/types/router/reg-exp-router/index.d.ts
All
/**
* @module
* RegExpRouter for Hono.
*/
export { RegExpRouter } from './router';
dist/types/jsx/dom/jsx-runtime.d.ts
All
/**
* @module
* This module provides the `hono/jsx/dom` runtime.
*/
export { jsxDEV as jsx, Fragment } from './jsx-dev-runtime';
export { jsxDEV as jsxs } from './jsx-dev-runtime';
dist/types/adapter/service-worker/index.d.ts
All
/**
* Service Worker Adapter for Hono.
* @module
*/
export { handle } from './handler';
All
/**
* @module
* The HTTP Client for Hono.
*/
export { hc } from './client';
export type { InferResponseType, InferRequestType, Fetch, ClientRequestOptions, ClientRequest, ClientResponse, } from './types';
dist/types/middleware/request-id/index.d.ts
All
import type { RequestIdVariables } from './request-id';
export type { RequestIdVariables };
export { requestId } from './request-id';
declare module '../..' {
interface ContextVariableMap extends RequestIdVariables {
}
}
dist/types/router/trie-router/index.d.ts
All
/**
* @module
* TrieRouter for Hono.
*/
export { TrieRouter } from './router';
dist/types/adapter/vercel/index.d.ts
All
/**
* @module
* Vercel Adapter for Hono.
*/
export { handle } from './handler';
export { getConnInfo } from './conninfo';
dist/types/helper/css/index.d.ts
Types
CssClassName
type CssClassName = HtmlEscapedString & CssClassNameCommon;
Interfaces
CssType
interface CssType { (strings: TemplateStringsArray, ...values: CssVariableType[]): Promise<string>; }
CxType
interface CxType { (...args: (CssClassName | Promise<string> | string | boolean | null | undefined)[]): Promise<string>; }
KeyframesType
interface KeyframesType { (strings: TemplateStringsArray, ...values: CssVariableType[]): CssClassNameCommon; }
ViewTransitionType
interface ViewTransitionType { (strings: TemplateStringsArray, ...values: CssVariableType[]): Promise<string>; (content: Promise<string>): Promise<string>; (): Promise<string>; }
StyleType
interface StyleType { (args?: { children?: Promise<string>; nonce?: string; }): HtmlEscapedString; }
DefaultContextType
interface DefaultContextType { css: CssType; cx: CxType; keyframes: KeyframesType; viewTransition: ViewTransitionType; Style: StyleType; }
Functions
createCssContext
/** * @experimental * `createCssContext` is an experimental feature. * The API might be changed. */ export declare const createCssContext: ({ id }: { id: Readonly<string>; }) => DefaultContextType;
All
/**
* @module
* css Helper for Hono.
*/
import type { HtmlEscapedString } from '../../utils/html';
import type { CssClassName as CssClassNameCommon, CssVariableType } from './common';
export { rawCssString } from './common';
type CssClassName = HtmlEscapedString & CssClassNameCommon;
interface CssType {
(strings: TemplateStringsArray, ...values: CssVariableType[]): Promise<string>;
}
interface CxType {
(...args: (CssClassName | Promise<string> | string | boolean | null | undefined)[]): Promise<string>;
}
interface KeyframesType {
(strings: TemplateStringsArray, ...values: CssVariableType[]): CssClassNameCommon;
}
interface ViewTransitionType {
(strings: TemplateStringsArray, ...values: CssVariableType[]): Promise<string>;
(content: Promise<string>): Promise<string>;
(): Promise<string>;
}
interface StyleType {
(args?: {
children?: Promise<string>;
nonce?: string;
}): HtmlEscapedString;
}
/**
* @experimental
* `createCssContext` is an experimental feature.
* The API might be changed.
*/
export declare const createCssContext: ({ id }: {
id: Readonly<string>;
}) => DefaultContextType;
interface DefaultContextType {
css: CssType;
cx: CxType;
keyframes: KeyframesType;
viewTransition: ViewTransitionType;
Style: StyleType;
}
/**
* @experimental
* `css` is an experimental feature.
* The API might be changed.
*/
export declare const css: CssType;
/**
* @experimental
* `cx` is an experimental feature.
* The API might be changed.
*/
export declare const cx: CxType;
/**
* @experimental
* `keyframes` is an experimental feature.
* The API might be changed.
*/
export declare const keyframes: KeyframesType;
/**
* @experimental
* `viewTransition` is an experimental feature.
* The API might be changed.
*/
export declare const viewTransition: ViewTransitionType;
/**
* @experimental
* `Style` is an experimental feature.
* The API might be changed.
*/
export declare const Style: StyleType;
dist/types/helper/accepts/index.d.ts
All
/**
* @module
* Accepts Helper for Hono.
*/
export { accepts } from './accepts';
Functions
createElement
declare const createElement: (tag: string | ((props: Props) => JSXNode), props: Props | null, ...children: Child[]) => JSXNode;
cloneElement
declare const cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Props, ...children: Child[]) => T;
memo
declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
All
/**
* @module
* This module provides APIs for `hono/jsx/dom`.
*/
import { isValidElement, reactAPICompatVersion } from '../base';
import type { Child, DOMAttributes, JSX, JSXNode, Props, FC } from '../base';
import { Children } from '../children';
import { useContext } from '../context';
import { createRef, forwardRef, startTransition, startViewTransition, use, useCallback, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, useViewTransition } from '../hooks';
import { ErrorBoundary, Suspense } from './components';
import { createContext } from './context';
import { useActionState, useFormStatus, useOptimistic } from './hooks';
import { Fragment } from './jsx-runtime';
import { createPortal, flushSync } from './render';
export { render } from './render';
declare const createElement: (tag: string | ((props: Props) => JSXNode), props: Props | null, ...children: Child[]) => JSXNode;
declare const cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Props, ...children: Child[]) => T;
declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
export { reactAPICompatVersion as version, createElement as jsx, useState, useEffect, useRef, useCallback, use, startTransition, useTransition, useDeferredValue, startViewTransition, useViewTransition, useMemo, useLayoutEffect, useInsertionEffect, useReducer, useId, useDebugValue, createRef, forwardRef, useImperativeHandle, useSyncExternalStore, useFormStatus, useActionState, useOptimistic, Suspense, ErrorBoundary, createContext, useContext, memo, isValidElement, createElement, cloneElement, Children, Fragment, Fragment as StrictMode, DOMAttributes, flushSync, createPortal, };
declare const _default: {
version: string;
useState: {
<T>(initialState: T | (() => T)): [
T,
(newState: T | ((currentState: T) => T)) => void
];
<T = undefined>(): [
T | undefined,
(newState: T | ((currentState: T | undefined) => T | undefined) | undefined) => void
];
};
useEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
useRef: <T>(initialValue: T | null) => import("..").RefObject<T>;
useCallback: <T extends Function>(callback: T, deps: readonly unknown[]) => T;
use: <T>(promise: Promise<T>) => T;
startTransition: (callback: () => void) => void;
useTransition: () => [
boolean,
(callback: () => void | Promise<void>) => void
];
useDeferredValue: <T>(value: T, initialValue?: T) => T;
startViewTransition: (callback: () => void) => void;
useViewTransition: () => [
boolean,
(callback: () => void) => void
];
useMemo: <T>(factory: () => T, deps: readonly unknown[]) => T;
useLayoutEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
useInsertionEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
useReducer: <T, A>(reducer: (state: T, action: A) => T, initialArg: T, init?: (initialState: T) => T) => [
T,
(action: A) => void
];
useId: () => string;
useDebugValue: (_value: unknown, _formatter?: (value: unknown) => string) => void;
createRef: <T>() => import("..").RefObject<T>;
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("..").RefObject<T>) => JSX.Element) => ((props: P & {
ref?: import("..").RefObject<T>;
}) => JSX.Element);
useImperativeHandle: <T>(ref: import("..").RefObject<T>, createHandle: () => T, deps: readonly unknown[]) => void;
useSyncExternalStore: <T>(subscribe: (callback: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T) => T;
useFormStatus: () => {
pending: false;
data: null;
method: null;
action: null;
} | {
pending: true;
data: FormData;
method: "get" | "post";
action: string | ((formData: FormData) => void | Promise<void>);
};
useActionState: <T>(fn: Function, initialState: T, permalink?: string) => [
T,
Function
];
useOptimistic: <T, N>(state: T, updateState: (currentState: T, action: N) => T) => [
T,
(action: N) => void
];
Suspense: FC<import("..").PropsWithChildren<{
fallback: any;
}>>;
ErrorBoundary: FC<import("..").PropsWithChildren<{
fallback?: Child;
fallbackRender?: import("../components").FallbackRender;
onError?: import("../components").ErrorHandler;
}>>;
createContext: <T>(defaultValue: T) => import("..").Context<T>;
useContext: <T>(context: import("..").Context<T>) => T;
memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
isValidElement: (element: unknown) => element is JSXNode;
createElement: (tag: string | ((props: Props) => JSXNode), props: Props | null, ...children: Child[]) => JSXNode;
cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Props, ...children: Child[]) => T;
Children: {
map: (children: Child[], fn: (child: Child, index: number) => Child) => Child[];
forEach: (children: Child[], fn: (child: Child, index: number) => void) => void;
count: (children: Child[]) => number;
only: (_children: Child[]) => Child;
toArray: (children: Child) => Child[];
};
Fragment: (props: Record<string, unknown>) => JSXNode;
StrictMode: (props: Record<string, unknown>) => JSXNode;
flushSync: (callback: () => void) => void;
createPortal: (children: Child, container: HTMLElement, key?: string) => Child;
};
export default _default;
export type { Context } from '../context';
export type * from '../types';
dist/types/router/pattern-router/index.d.ts
All
/**
* @module
* PatternRouter for Hono.
*/
export { PatternRouter } from './router';
dist/types/middleware/secure-headers/index.d.ts
All
export type { ContentSecurityPolicyOptionHandler } from './secure-headers';
export { NONCE, secureHeaders } from './secure-headers';
import type { SecureHeadersVariables } from './secure-headers';
export type { SecureHeadersVariables };
declare module '../..' {
interface ContextVariableMap extends SecureHeadersVariables {
}
}
dist/types/adapter/lambda-edge/index.d.ts
All
/**
* @module
* Lambda@Edge Adapter for Hono.
*/
export { handle } from './handler';
export { getConnInfo } from './conninfo';
export type { Callback, CloudFrontConfig, CloudFrontRequest, CloudFrontResponse, CloudFrontEdgeEvent, } from './handler';
dist/types/adapter/aws-lambda/index.d.ts
All
/**
* @module
* AWS Lambda Adapter for Hono.
*/
export { handle, streamHandle } from './handler';
export type { APIGatewayProxyResult, LambdaEvent } from './handler';
export type { ApiGatewayRequestContext, ApiGatewayRequestContextV2, ALBRequestContext, LambdaContext, } from './types';
dist/types/helper/ssg/index.d.ts
All
/**
* @module
* SSG Helper for Hono.
*/
export * from './ssg';
export { X_HONO_DISABLE_SSG_HEADER_KEY, ssgParams, isSSGContext, disableSSG, onlySSG, } from './middleware';
All
/**
* @module
*
* Hono - Web Framework built on Web Standards
*
* @example
* ```ts
* import { Hono } from 'hono'
* const app = new Hono()
*
* app.get('/', (c) => c.text('Hono!'))
*
* export default app
* ```
*/
import { Hono } from './hono';
/**
* Types for environment variables, error handlers, handlers, middleware handlers, and more.
*/
export type { Env, ErrorHandler, Handler, MiddlewareHandler, Next, NotFoundHandler, ValidationTargets, Input, Schema, ToSchema, TypedResponse, } from './types';
/**
* Types for context, context variable map, context renderer, and execution context.
*/
export type { Context, ContextVariableMap, ContextRenderer, ExecutionContext } from './context';
/**
* Type for HonoRequest.
*/
export type { HonoRequest } from './request';
/**
* Types for inferring request and response types and client request options.
*/
export type { InferRequestType, InferResponseType, ClientRequestOptions } from './client';
/**
* Hono framework for building web applications.
*/
export { Hono };
dist/types/middleware/ip-restriction/index.d.ts
Types
GetIPAddr
/** * Function to get IP Address */ type GetIPAddr = GetConnInfo | ((c: Context) => string);
IPRestrictionRule
export type IPRestrictionRule = string | ((addr: { addr: string; type: AddressType; }) => boolean);
Interfaces
IPRestrictionRules
/** * Rules for IP Restriction Middleware */ export interface IPRestrictionRules { denyList?: IPRestrictionRule[]; allowList?: IPRestrictionRule[]; }
Functions
ipRestriction
/** * IP Restriction Middleware * * @param getIP function to get IP Address */ export declare const ipRestriction: (getIP: GetIPAddr, { denyList, allowList }: IPRestrictionRules, onError?: (remote: { addr: string; type: AddressType; }, c: Context) => Response | Promise<Response>) => MiddlewareHandler;
All
/**
* IP Restriction Middleware for Hono
* @module
*/
import type { Context, MiddlewareHandler } from '../..';
import type { AddressType, GetConnInfo } from '../../helper/conninfo';
/**
* Function to get IP Address
*/
type GetIPAddr = GetConnInfo | ((c: Context) => string);
export type IPRestrictionRule = string | ((addr: {
addr: string;
type: AddressType;
}) => boolean);
/**
* Rules for IP Restriction Middleware
*/
export interface IPRestrictionRules {
denyList?: IPRestrictionRule[];
allowList?: IPRestrictionRule[];
}
/**
* IP Restriction Middleware
*
* @param getIP function to get IP Address
*/
export declare const ipRestriction: (getIP: GetIPAddr, { denyList, allowList }: IPRestrictionRules, onError?: (remote: {
addr: string;
type: AddressType;
}, c: Context) => Response | Promise<Response>) => MiddlewareHandler;
export {};
dist/types/jsx/dom/server.d.ts
Interfaces
RenderToStringOptions
export interface RenderToStringOptions { identifierPrefix?: string; }
RenderToReadableStreamOptions
export interface RenderToReadableStreamOptions { identifierPrefix?: string; namespaceURI?: string; nonce?: string; bootstrapScriptContent?: string; bootstrapScripts?: string[]; bootstrapModules?: string[]; progressiveChunkSize?: number; signal?: AbortSignal; onError?: (error: unknown) => string | void; }
Functions
renderToString
/** * Render JSX element to string. * @param element JSX element to render. * @param options Options for rendering. * @returns Rendered string. */ declare const renderToString: (element: Child, options?: RenderToStringOptions) => string;
renderToReadableStream
/** * Render JSX element to readable stream. * @param element JSX element to render. * @param options Options for rendering. * @returns Rendered readable stream. */ declare const renderToReadableStream: (element: Child, options?: RenderToReadableStreamOptions) => Promise<ReadableStream<Uint8Array>>;
All
/**
* @module
* This module provides APIs for `hono/jsx/server`, which is compatible with `react-dom/server`.
*/
import type { Child } from '../base';
import version from './';
export interface RenderToStringOptions {
identifierPrefix?: string;
}
/**
* Render JSX element to string.
* @param element JSX element to render.
* @param options Options for rendering.
* @returns Rendered string.
*/
declare const renderToString: (element: Child, options?: RenderToStringOptions) => string;
export interface RenderToReadableStreamOptions {
identifierPrefix?: string;
namespaceURI?: string;
nonce?: string;
bootstrapScriptContent?: string;
bootstrapScripts?: string[];
bootstrapModules?: string[];
progressiveChunkSize?: number;
signal?: AbortSignal;
onError?: (error: unknown) => string | void;
}
/**
* Render JSX element to readable stream.
* @param element JSX element to render.
* @param options Options for rendering.
* @returns Rendered readable stream.
*/
declare const renderToReadableStream: (element: Child, options?: RenderToReadableStreamOptions) => Promise<ReadableStream<Uint8Array>>;
export { renderToString, renderToReadableStream, version };
declare const _default: {
renderToString: (element: Child, options?: RenderToStringOptions) => string;
renderToReadableStream: (element: Child, options?: RenderToReadableStreamOptions) => Promise<ReadableStream<Uint8Array>>;
version: {
version: string;
useState: {
<T>(initialState: T | (() => T)): [
T,
(newState: T | ((currentState: T) => T)) => void
];
<T = undefined>(): [
T | undefined,
(newState: T | ((currentState: T | undefined) => T | undefined) | undefined) => void
];
};
useEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
useRef: <T>(initialValue: T | null) => import("..").RefObject<T>;
useCallback: <T extends Function>(callback: T, deps: readonly unknown[]) => T;
use: <T>(promise: Promise<T>) => T;
startTransition: (callback: () => void) => void;
useTransition: () => [
boolean,
(callback: () => void | Promise<void>) => void
];
useDeferredValue: <T>(value: T, initialValue?: T) => T;
startViewTransition: (callback: () => void) => void;
useViewTransition: () => [
boolean,
(callback: () => void) => void
];
useMemo: <T>(factory: () => T, deps: readonly unknown[]) => T;
useLayoutEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
useInsertionEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
useReducer: <T, A>(reducer: (state: T, action: A) => T, initialArg: T, init?: (initialState: T) => T) => [
T,
(action: A) => void
];
useId: () => string;
useDebugValue: (_value: unknown, _formatter?: (value: unknown) => string) => void;
createRef: <T>() => import("..").RefObject<T>;
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("..").RefObject<T>) => import("../base").JSX.Element) => ((props: P & {
ref?: import("..").RefObject<T>;
}) => import("../base").JSX.Element);
useImperativeHandle: <T>(ref: import("..").RefObject<T>, createHandle: () => T, deps: readonly unknown[]) => void;
useSyncExternalStore: <T>(subscribe: (callback: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T) => T;
useFormStatus: () => {
pending: false;
data: null;
method: null;
action: null;
} | {
pending: true;
data: FormData;
method: "get" | "post";
action: string | ((formData: FormData) => void | Promise<void>);
};
useActionState: <T>(fn: Function, initialState: T, permalink?: string) => [
T,
Function
];
useOptimistic: <T, N>(state: T, updateState: (currentState: T, action: N) => T) => [
T,
(action: N) => void
];
Suspense: import("..").FC<import("..").PropsWithChildren<{
fallback: any;
}>>;
ErrorBoundary: import("..").FC<import("..").PropsWithChildren<{
fallback?: Child;
fallbackRender?: import("../components").FallbackRender;
onError?: import("../components").ErrorHandler;
}>>;
createContext: <T>(defaultValue: T) => import("..").Context<T>;
useContext: <T>(context: import("..").Context<T>) => T;
memo: <T>(component: import("..").FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => import("..").FC<T>;
isValidElement: (element: unknown) => element is import("..").JSXNode;
createElement: (tag: string | ((props: import("../base").Props) => import("..").JSXNode), props: import("../base").Props | null, ...children: Child[]) => import("..").JSXNode;
cloneElement: <T extends import("..").JSXNode | import("../base").JSX.Element>(element: T, props: import("../base").Props, ...children: Child[]) => T;
Children: {
map: (children: Child[], fn: (child: Child, index: number) => Child) => Child[];
forEach: (children: Child[], fn: (child: Child, index: number) => void) => void;
count: (children: Child[]) => number;
only: (_children: Child[]) => Child;
toArray: (children: Child) => Child[];
};
Fragment: (props: Record<string, unknown>) => import("..").JSXNode;
StrictMode: (props: Record<string, unknown>) => import("..").JSXNode;
flushSync: (callback: () => void) => void;
createPortal: (children: Child, container: HTMLElement, key?: string) => Child;
};
};
export default _default;
dist/types/middleware/pretty-json/index.d.ts
Interfaces
PrettyOptions
interface PrettyOptions { /** * Number of spaces for indentation. * @default 2 */ space?: number; /** * Query conditions for when to Pretty. * @default 'pretty' */ query?: string; }
Functions
prettyJSON
/** * Pretty JSON Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/pretty-json} * * @param options - The options for the pretty JSON middleware. * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * const app = new Hono() * * app.use(prettyJSON()) // With options: prettyJSON({ space: 4 }) * app.get('/', (c) => { * return c.json({ message: 'Hono!' }) * }) * ``` */ export declare const prettyJSON: (options?: PrettyOptions) => MiddlewareHandler;
All
/**
* @module
* Pretty JSON Middleware for Hono.
*/
import type { MiddlewareHandler } from '../../types';
interface PrettyOptions {
/**
* Number of spaces for indentation.
* @default 2
*/
space?: number;
/**
* Query conditions for when to Pretty.
* @default 'pretty'
*/
query?: string;
}
/**
* Pretty JSON Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/pretty-json}
*
* @param options - The options for the pretty JSON middleware.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(prettyJSON()) // With options: prettyJSON({ space: 4 })
* app.get('/', (c) => {
* return c.json({ message: 'Hono!' })
* })
* ```
*/
export declare const prettyJSON: (options?: PrettyOptions) => MiddlewareHandler;
export {};
dist/types/middleware/context-storage/index.d.ts
Functions
contextStorage
/** * Context Storage Middleware for Hono. * * @see {@link https://hono.dev/docs/middleware/builtin/context-storage} * * @returns {MiddlewareHandler} The middleware handler function. * * @example * ```ts * type Env = { * Variables: { * message: string * } * } * * const app = new Hono<Env>() * * app.use(contextStorage()) * * app.use(async (c, next) => { * c.set('message', 'Hono is cool!!) * await next() * }) * * app.get('/', async (c) => { c.text(getMessage()) }) * * const getMessage = () => { * return getContext<Env>().var.message * } * ``` */ export declare const contextStorage: () => MiddlewareHandler;
getContext
export declare const getContext: <E extends Env = Env>() => Context<E>;
All
/**
* @module
* Context Storage Middleware for Hono.
*/
import type { Context } from '../../context';
import type { Env, MiddlewareHandler } from '../../types';
/**
* Context Storage Middleware for Hono.
*
* @see {@link https://hono.dev/docs/middleware/builtin/context-storage}
*
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* type Env = {
* Variables: {
* message: string
* }
* }
*
* const app = new Hono<Env>()
*
* app.use(contextStorage())
*
* app.use(async (c, next) => {
* c.set('message', 'Hono is cool!!)
* await next()
* })
*
* app.get('/', async (c) => { c.text(getMessage()) })
*
* const getMessage = () => {
* return getContext<Env>().var.message
* }
* ```
*/
export declare const contextStorage: () => MiddlewareHandler;
export declare const getContext: <E extends Env = Env>() => Context<E>;
dist/types/middleware/timing/index.d.ts
All
import type { TimingVariables } from './timing';
export { TimingVariables };
export { timing, setMetric, startTime, endTime } from './timing';
declare module '../..' {
interface ContextVariableMap extends TimingVariables {
}
}
dist/types/jsx/jsx-dev-runtime.d.ts
Functions
jsxDEV
export declare function jsxDEV(tag: string | Function, props: Record<string, unknown>, key?: string): JSXNode;
All
/**
* @module
* This module provides Hono's JSX dev runtime.
*/
import type { JSXNode } from './base';
export { Fragment } from './base';
export type { JSX } from './base';
export declare function jsxDEV(tag: string | Function, props: Record<string, unknown>, key?: string): JSXNode;
dist/types/adapter/bun/index.d.ts
All
/**
* @module
* Bun Adapter for Hono.
*/
export { serveStatic } from './serve-static';
export { bunFileSystemModule, toSSG } from './ssg';
export { createBunWebSocket } from './websocket';
export { getConnInfo } from './conninfo';
All
/**
* @module
* JSX for Hono.
*/
import { Fragment, cloneElement, isValidElement, jsx, memo, reactAPICompatVersion } from './base';
import type { DOMAttributes } from './base';
import { Children } from './children';
import { ErrorBoundary } from './components';
import { createContext, useContext } from './context';
import { useActionState, useOptimistic } from './dom/hooks';
import { createRef, forwardRef, startTransition, startViewTransition, use, useCallback, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, useViewTransition } from './hooks';
import { Suspense } from './streaming';
export { reactAPICompatVersion as version, jsx, memo, Fragment, Fragment as StrictMode, isValidElement, jsx as createElement, cloneElement, ErrorBoundary, createContext, useContext, useState, useEffect, useRef, useCallback, useReducer, useId, useDebugValue, use, startTransition, useTransition, useDeferredValue, startViewTransition, useViewTransition, useMemo, useLayoutEffect, useInsertionEffect, createRef, forwardRef, useImperativeHandle, useSyncExternalStore, useActionState, useOptimistic, Suspense, Children, DOMAttributes, };
declare const _default: {
version: string;
memo: <T>(component: import("./base").FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => import("./base").FC<T>;
Fragment: ({ children, }: {
key?: string;
children?: import("./base").Child | import("../utils/html").HtmlEscapedString;
}) => import("../utils/html").HtmlEscapedString;
StrictMode: ({ children, }: {
key?: string;
children?: import("./base").Child | import("../utils/html").HtmlEscapedString;
}) => import("../utils/html").HtmlEscapedString;
isValidElement: (element: unknown) => element is import("./base").JSXNode;
createElement: (tag: string | Function, props: import("./base").Props | null, ...children: (string | number | import("../utils/html").HtmlEscapedString)[]) => import("./base").JSXNode;
cloneElement: <T extends import("./base").JSXNode | import("./base").JSX.Element>(element: T, props: Partial<import("./base").Props>, ...children: import("./base").Child[]) => T;
ErrorBoundary: import("./base").FC<import("./types").PropsWithChildren<{
fallback?: import("./base").Child;
fallbackRender?: import("./components").FallbackRender;
onError?: import("./components").ErrorHandler;
}>>;
createContext: <T>(defaultValue: T) => import("./context").Context<T>;
useContext: <T>(context: import("./context").Context<T>) => T;
useState: {
<T>(initialState: T | (() => T)): [
T,
(newState: T | ((currentState: T) => T)) => void
];
<T = undefined>(): [
T | undefined,
(newState: T | ((currentState: T | undefined) => T | undefined) | undefined) => void
];
};
useEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
useRef: <T>(initialValue: T | null) => import("./hooks").RefObject<T>;
useCallback: <T extends Function>(callback: T, deps: readonly unknown[]) => T;
useReducer: <T, A>(reducer: (state: T, action: A) => T, initialArg: T, init?: (initialState: T) => T) => [
T,
(action: A) => void
];
useId: () => string;
useDebugValue: (_value: unknown, _formatter?: (value: unknown) => string) => void;
use: <T>(promise: Promise<T>) => T;
startTransition: (callback: () => void) => void;
useTransition: () => [
boolean,
(callback: () => void | Promise<void>) => void
];
useDeferredValue: <T>(value: T, initialValue?: T) => T;
startViewTransition: (callback: () => void) => void;
useViewTransition: () => [
boolean,
(callback: () => void) => void
];
useMemo: <T>(factory: () => T, deps: readonly unknown[]) => T;
useLayoutEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
useInsertionEffect: (effect: () => void | (() => void), deps?: readonly unknown[]) => void;
createRef: <T>() => import("./hooks").RefObject<T>;
forwardRef: <T, P = {}>(Component: (props: P, ref?: import("./hooks").RefObject<T>) => import("./base").JSX.Element) => ((props: P & {
ref?: import("./hooks").RefObject<T>;
}) => import("./base").JSX.Element);
useImperativeHandle: <T>(ref: import("./hooks").RefObject<T>, createHandle: () => T, deps: readonly unknown[]) => void;
useSyncExternalStore: <T>(subscribe: (callback: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T) => T;
useActionState: <T>(fn: Function, initialState: T, permalink?: string) => [
T,
Function
];
useOptimistic: <T, N>(state: T, updateState: (currentState: T, action: N) => T) => [
T,
(action: N) => void
];
Suspense: import("./base").FC<import("./types").PropsWithChildren<{
fallback: any;
}>>;
Children: {
map: (children: import("./base").Child[], fn: (child: import("./base").Child, index: number) => import("./base").Child) => import("./base").Child[];
forEach: (children: import("./base").Child[], fn: (child: import("./base").Child, index: number) => void) => void;
count: (children: import("./base").Child[]) => number;
only: (_children: import("./base").Child[]) => import("./base").Child;
toArray: (children: import("./base").Child) => import("./base").Child[];
};
};
export default _default;
export type * from './types';
export type { JSX } from './intrinsic-elements';
dist/types/adapter/cloudflare-workers/index.d.ts
All
/**
* @module
* Cloudflare Workers Adapter for Hono.
*/
export { serveStatic } from './serve-static-module';
export { upgradeWebSocket } from './websocket';
export { getConnInfo } from './conninfo';
dist/types/adapter/deno/index.d.ts
All
/**
* @module
* Deno Adapter for Hono.
*/
export { serveStatic } from './serve-static';
export { toSSG, denoFileSystemModule } from './ssg';
export { upgradeWebSocket } from './websocket';
export { getConnInfo } from './conninfo';
dist/types/helper/streaming/index.d.ts
All
/**
* @module
* Streaming Helper for Hono.
*/
export { stream } from './stream';
export type { SSEMessage } from './sse';
export { streamSSE, SSEStreamingApi } from './sse';
export { streamText } from './text';