import type { LambdaEvent } from './handler' import { getProcessor, isContentEncodingBinary, isContentTypeBinary } from './handler' describe('isContentTypeBinary', () => { it('Should determine whether it is binary', () => { expect(isContentTypeBinary('image/png')).toBe(true)expect(isContentTypeBinary('font/woff2')).toBe(true)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('image/svg+xml')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('image/svg+xml; charset=UTF-8')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('text/plain')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('text/plain; charset=UTF-8')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('text/css')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('text/javascript')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('application/json')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('application/ld+json')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('application/json; charset=UTF-8')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
}) }) describe('isContentEncodingBinary', () => { it('Should determine whether it is compressed', () => { expect(isContentEncodingBinary('gzip')).toBe(true)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentEncodingBinary('compress')).toBe(true)
(alias) isContentEncodingBinary(contentEncoding: string | null): boolean import isContentEncodingBinary
expect(isContentEncodingBinary('deflate')).toBe(true)
(alias) isContentEncodingBinary(contentEncoding: string | null): boolean import isContentEncodingBinary
expect(isContentEncodingBinary('br')).toBe(true)
(alias) isContentEncodingBinary(contentEncoding: string | null): boolean import isContentEncodingBinary
expect(isContentEncodingBinary('deflate, gzip')).toBe(true)
(alias) isContentEncodingBinary(contentEncoding: string | null): boolean import isContentEncodingBinary
expect(isContentEncodingBinary('')).toBe(false)
(alias) isContentEncodingBinary(contentEncoding: string | null): boolean import isContentEncodingBinary
expect(isContentEncodingBinary('unknown')).toBe(false)
(alias) isContentEncodingBinary(contentEncoding: string | null): boolean import isContentEncodingBinary
}) }) describe('EventProcessor.createRequest', () => { it('Should return valid Request object from version 1.0 API Gateway event', () => { const event:
(alias) isContentEncodingBinary(contentEncoding: string | null): boolean import isContentEncodingBinary
LambdaEvent = {
const event: LambdaEvent
version: '1.0',
(alias) type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent import LambdaEvent
resource: '/my/path',
(property) APIGatewayProxyEvent.version: string
path: '/my/path',
(property) APIGatewayProxyEvent.resource: string
httpMethod: 'GET',
(property) path: string
headers: {
(property) httpMethod: string
'content-type': 'application/json', header1: 'value1',
(property) headers: { 'content-type': string; header1: string; header2: string; }
header2: 'value1',
(property) header1: string
}, multiValueHeaders: {
(property) header2: string
header1: ['value1'],
(property) multiValueHeaders: { header1: string[]; header2: string[]; }
header2: ['value1', 'value2', 'value3'],
(property) header1: string[]
}, queryStringParameters: {
(property) header2: string[]
parameter2: 'value',
(property) queryStringParameters: { parameter2: string; }
}, multiValueQueryStringParameters: {
(property) parameter2: string
parameter1: ['value1', 'value2'],
(property) multiValueQueryStringParameters: { parameter1: string[]; parameter2: string[]; }
parameter2: ['value'],
(property) parameter1: string[]
}, requestContext: {
(property) parameter2: string[]
accountId: '123456789012',
(property) requestContext: { accountId: string; apiId: string; authorizer: { claims: null; scopes: null; }; domainName: string; domainPrefix: string; extendedRequestId: string; httpMethod: string; identity: { sourceIp: string; userAgent: string; clientCert: { ...; }; }; ... 6 more ...; stage: string; }
apiId: 'id',
(property) accountId: string
authorizer: {
(property) apiId: string
claims: null,
(property) authorizer: { claims: null; scopes: null; }
scopes: null,
(property) claims?: unknown
}, domainName: 'id.execute-api.us-east-1.amazonaws.com',
(property) scopes?: unknown
domainPrefix: 'id',
(property) domainName: string
extendedRequestId: 'request-id',
(property) domainPrefix: string
httpMethod: 'GET',
(property) ApiGatewayRequestContext.extendedRequestId: string
identity: {
(property) ApiGatewayRequestContext.httpMethod: string
sourceIp: '192.0.2.1',
(property) ApiGatewayRequestContext.identity: Identity
userAgent: 'user-agent',
(property) Identity.sourceIp: string
clientCert: {
(property) Identity.userAgent: string
clientCertPem: 'CERT_CONTENT',
(property) Identity.clientCert?: ClientCert | undefined
subjectDN: 'www.example.com',
(property) ClientCert.clientCertPem: string
issuerDN: 'Example issuer',
(property) ClientCert.subjectDN: string
serialNumber: 'a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1',
(property) ClientCert.issuerDN: string
validity: {
(property) ClientCert.serialNumber: string
notBefore: 'May 28 12:30:02 2019 GMT',
(property) ClientCert.validity: { notBefore: string; notAfter: string; }
notAfter: 'Aug 5 09:36:04 2021 GMT',
(property) notBefore: string
}, }, }, path: '/my/path',
(property) notAfter: string
protocol: 'HTTP/1.1',
(property) ApiGatewayRequestContext.path: string
requestId: 'id=',
(property) ApiGatewayRequestContext.protocol: string
requestTime: '04/Mar/2020:19:15:17 +0000',
(property) requestId: string
requestTimeEpoch: 1583349317135,
(property) ApiGatewayRequestContext.requestTime: string
resourcePath: '/my/path',
(property) ApiGatewayRequestContext.requestTimeEpoch: number
stage: '$default',
(property) ApiGatewayRequestContext.resourcePath: string
}, pathParameters: {},
(property) stage: string
stageVariables: {},
(property) APIGatewayProxyEvent.pathParameters?: Record<string, string> | undefined
body: null,
(property) APIGatewayProxyEvent.stageVariables?: Record<string, string> | undefined
isBase64Encoded: false,
(property) body: null
} const processor =
(property) isBase64Encoded: false
getProcessor
const processor: EventProcessor<LambdaEvent>
(event)
(alias) getProcessor(event: LambdaEvent): EventProcessor<LambdaEvent> import getProcessor
const request =
const event: APIGatewayProxyEvent
processor
const request: Request
.createRequest
const processor: EventProcessor<LambdaEvent>
(event)
(method) EventProcessor<LambdaEvent>.createRequest(event: LambdaEvent): Request
expect(request
const event: APIGatewayProxyEvent
.method).toEqual('GET')
const request: Request
expect(request
(property) Request.method: string
Returns request's HTTP method, which is "GET" by default..url).toEqual(
const request: Request
'https://id.execute-api.us-east-1.amazonaws.com/my/path?parameter2=value' ) expect(Object
(property) Request.url: string
Returns the URL of request as a string..fromEntries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.fromEntries<string>(entries: Iterable<readonly [PropertyKey, string]>): { [k: string]: string; } (+1 overload)
Returns an object created by key-value entries for properties and methods@param
(requestentries
— An iterable object that contains key-value entries for properties and methods..headers)).toEqual({
const request: Request
'content-type': 'application/json', header1: 'value1',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.header2: 'value1, value2, value3',
(property) header1: string
}) }) it('Should return valid Request object from version 2.0 API Gateway event', () => { const event:
(property) header2: string
LambdaEvent = {
const event: LambdaEvent
version: '2.0',
(alias) type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent import LambdaEvent
routeKey: '$default',
(property) version: string
rawPath: '/my/path',
(property) APIGatewayProxyEventV2.routeKey: string
rawQueryString: 'parameter1=value1¶meter1=value2¶meter2=value',
(property) APIGatewayProxyEventV2.rawPath: string
cookies: ['cookie1', 'cookie2'],
(property) APIGatewayProxyEventV2.rawQueryString: string
headers: {
(property) APIGatewayProxyEventV2.cookies?: string[] | undefined
'content-type': 'application/json', header1: 'value1',
(property) headers: { 'content-type': string; header1: string; header2: string; }
header2: 'value1,value2',
(property) header1: string
}, queryStringParameters: {
(property) header2: string
parameter1: 'value1,value2',
(property) queryStringParameters: { parameter1: string; parameter2: string; }
parameter2: 'value',
(property) parameter1: string
}, requestContext: {
(property) parameter2: string
accountId: '123456789012',
(property) requestContext: { accountId: string; apiId: string; authentication: null; authorizer: {}; domainName: string; domainPrefix: string; http: { method: string; path: string; protocol: string; sourceIp: string; userAgent: string; }; ... 4 more ...; timeEpoch: number; }
apiId: 'api-id',
(property) accountId: string
authentication: null,
(property) apiId: string
authorizer: {},
(property) ApiGatewayRequestContextV2.authentication: null
domainName: 'id.execute-api.us-east-1.amazonaws.com',
(property) authorizer: {}
domainPrefix: 'id',
(property) domainName: string
http: {
(property) domainPrefix: string
method: 'POST',
(property) ApiGatewayRequestContextV2.http: { method: string; path: string; protocol: string; sourceIp: string; userAgent: string; }
path: '/my/path',
(property) method: string
protocol: 'HTTP/1.1',
(property) path: string
sourceIp: '192.0.2.1',
(property) protocol: string
userAgent: 'agent',
(property) sourceIp: string
}, requestId: 'id',
(property) userAgent: string
routeKey: '$default',
(property) requestId: string
stage: '$default',
(property) ApiGatewayRequestContextV2.routeKey: string
time: '12/Mar/2020:19:03:58 +0000',
(property) stage: string
timeEpoch: 1583348638390,
(property) ApiGatewayRequestContextV2.time: string
}, body: 'Hello from Lambda',
(property) ApiGatewayRequestContextV2.timeEpoch: number
pathParameters: {
(property) body: string
parameter1: 'value1',
(property) pathParameters: { parameter1: string; }
}, isBase64Encoded: false,
(property) parameter1: string
stageVariables: {
(property) isBase64Encoded: false
stageVariable1: 'value1',
(property) stageVariables: { stageVariable1: string; stageVariable2: string; }
stageVariable2: 'value2',
(property) stageVariable1: string
}, } const processor =
(property) stageVariable2: string
getProcessor
const processor: EventProcessor<LambdaEvent>
(event)
(alias) getProcessor(event: LambdaEvent): EventProcessor<LambdaEvent> import getProcessor
const request =
const event: APIGatewayProxyEventV2
processor
const request: Request
.createRequest
const processor: EventProcessor<LambdaEvent>
(event)
(method) EventProcessor<LambdaEvent>.createRequest(event: LambdaEvent): Request
expect(request
const event: APIGatewayProxyEventV2
.method).toEqual('POST')
const request: Request
expect(request
(property) Request.method: string
Returns request's HTTP method, which is "GET" by default..url).toEqual(
const request: Request
'https://id.execute-api.us-east-1.amazonaws.com/my/path?parameter1=value1¶meter1=value2¶meter2=value' ) expect(Object
(property) Request.url: string
Returns the URL of request as a string..fromEntries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.fromEntries<string>(entries: Iterable<readonly [PropertyKey, string]>): { [k: string]: string; } (+1 overload)
Returns an object created by key-value entries for properties and methods@param
(requestentries
— An iterable object that contains key-value entries for properties and methods..headers)).toEqual({
const request: Request
'content-type': 'application/json', cookie: 'cookie1; cookie2',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.header1: 'value1',
(property) cookie: string
header2: 'value1,value2',
(property) header1: string
}) }) })
(property) header2: string
import crypto from 'node:crypto' import type { Hono } from '../../hono' import type { Env, Schema } from '../../types' import { decodeBase64, encodeBase64 } from '../../utils/encode' import type { ALBRequestContext, ApiGatewayRequestContext, ApiGatewayRequestContextV2, Handler, LambdaContext, } from './types' // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore globalThis.crypto ??= cryptoexport type LambdaEvent =
var crypto: Crypto
MDN ReferenceAPIGatewayProxyEvent |
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
APIGatewayProxyEventV2 |
interface APIGatewayProxyEvent
ALBProxyEvent
interface APIGatewayProxyEventV2
// When calling HTTP API or Lambda directly through function urls export interface APIGatewayProxyEventV2 {
interface ALBProxyEvent
version: string
interface APIGatewayProxyEventV2
routeKey: string
(property) APIGatewayProxyEventV2.version: string
headers:
(property) APIGatewayProxyEventV2.routeKey: string
Record
(property) APIGatewayProxyEventV2.headers: Record<string, string | undefined>
multiValueHeaders?: undefined
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tcookies?: string[]
(property) APIGatewayProxyEventV2.multiValueHeaders?: undefined
rawPath: string
(property) APIGatewayProxyEventV2.cookies?: string[] | undefined
rawQueryString: string
(property) APIGatewayProxyEventV2.rawPath: string
body: string | null
(property) APIGatewayProxyEventV2.rawQueryString: string
isBase64Encoded: boolean
(property) APIGatewayProxyEventV2.body: string | null
requestContext:
(property) APIGatewayProxyEventV2.isBase64Encoded: boolean
ApiGatewayRequestContextV2
(property) APIGatewayProxyEventV2.requestContext: ApiGatewayRequestContextV2
queryStringParameters?: {
(alias) interface ApiGatewayRequestContextV2 import ApiGatewayRequestContextV2
[name: string]: string | undefined
(property) APIGatewayProxyEventV2.queryStringParameters?: { [name: string]: string | undefined; } | undefined
} pathParameters?: {
(parameter) name: string
[name: string]: string | undefined
(property) APIGatewayProxyEventV2.pathParameters?: { [name: string]: string | undefined; } | undefined
} stageVariables?: {
(parameter) name: string
[name: string]: string | undefined
(property) APIGatewayProxyEventV2.stageVariables?: { [name: string]: string | undefined; } | undefined
} } // When calling Lambda through an API Gateway export interface APIGatewayProxyEvent {
(parameter) name: string
version: string
interface APIGatewayProxyEvent
httpMethod: string
(property) APIGatewayProxyEvent.version: string
headers:
(property) APIGatewayProxyEvent.httpMethod: string
Record
(property) APIGatewayProxyEvent.headers: Record<string, string | undefined>
multiValueHeaders?: {
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T[headerKey: string]: string[]
(property) APIGatewayProxyEvent.multiValueHeaders?: { [headerKey: string]: string[]; } | undefined
} path: string
(parameter) headerKey: string
body: string | null
(property) APIGatewayProxyEvent.path: string
isBase64Encoded: boolean
(property) APIGatewayProxyEvent.body: string | null
queryStringParameters?:
(property) APIGatewayProxyEvent.isBase64Encoded: boolean
Record
(property) APIGatewayProxyEvent.queryStringParameters?: Record<string, string | undefined> | undefined
requestContext:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TApiGatewayRequestContext
(property) APIGatewayProxyEvent.requestContext: ApiGatewayRequestContext
resource: string
(alias) interface ApiGatewayRequestContext import ApiGatewayRequestContext
multiValueQueryStringParameters?: {
(property) APIGatewayProxyEvent.resource: string
[parameterKey: string]: string[]
(property) APIGatewayProxyEvent.multiValueQueryStringParameters?: { [parameterKey: string]: string[]; } | undefined
} pathParameters?:
(parameter) parameterKey: string
Record
(property) APIGatewayProxyEvent.pathParameters?: Record<string, string> | undefined
stageVariables?:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TRecord
(property) APIGatewayProxyEvent.stageVariables?: Record<string, string> | undefined
} // When calling Lambda through an Application Load Balancer export interface ALBProxyEvent {
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type ThttpMethod: string
interface ALBProxyEvent
headers?:
(property) ALBProxyEvent.httpMethod: string
Record
(property) ALBProxyEvent.headers?: Record<string, string | undefined> | undefined
multiValueHeaders?:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TRecord
(property) ALBProxyEvent.multiValueHeaders?: Record<string, string[] | undefined> | undefined
path: string
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tbody: string | null
(property) ALBProxyEvent.path: string
isBase64Encoded: boolean
(property) ALBProxyEvent.body: string | null
queryStringParameters?:
(property) ALBProxyEvent.isBase64Encoded: boolean
Record
(property) ALBProxyEvent.queryStringParameters?: Record<string, string | undefined> | undefined
multiValueQueryStringParameters?: {
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T[parameterKey: string]: string[]
(property) ALBProxyEvent.multiValueQueryStringParameters?: { [parameterKey: string]: string[]; } | undefined
} requestContext:
(parameter) parameterKey: string
ALBRequestContext
(property) ALBProxyEvent.requestContext: ALBRequestContext
} export interface APIGatewayProxyResult {
(alias) interface ALBRequestContext import ALBRequestContext
statusCode: number
interface APIGatewayProxyResult
statusDescription?: string
(property) APIGatewayProxyResult.statusCode: number
body: string
(property) APIGatewayProxyResult.statusDescription?: string | undefined
headers:
(property) APIGatewayProxyResult.body: string
Record
(property) APIGatewayProxyResult.headers: Record<string, string>
cookies?: string[]
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TmultiValueHeaders?: {
(property) APIGatewayProxyResult.cookies?: string[] | undefined
[headerKey: string]: string[]
(property) APIGatewayProxyResult.multiValueHeaders?: { [headerKey: string]: string[]; } | undefined
} isBase64Encoded: boolean
(parameter) headerKey: string
} const getRequestContext = (
(property) APIGatewayProxyResult.isBase64Encoded: boolean
event:
const getRequestContext: (event: LambdaEvent) => ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
LambdaEvent
(parameter) event: LambdaEvent
): ApiGatewayRequestContext |
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
ApiGatewayRequestContextV2 |
(alias) interface ApiGatewayRequestContext import ApiGatewayRequestContext
ALBRequestContext => {
(alias) interface ApiGatewayRequestContextV2 import ApiGatewayRequestContextV2
return event
(alias) interface ALBRequestContext import ALBRequestContext
.requestContext
(parameter) event: LambdaEvent
} const streamToNodeStream = async (
(property) requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
reader:
const streamToNodeStream: (reader: ReadableStreamDefaultReader<Uint8Array>, writer: NodeJS.WritableStream) => Promise<void>
ReadableStreamDefaultReader
(parameter) reader: ReadableStreamDefaultReader<Uint8Array>
<Uint8Array>,
interface ReadableStreamDefaultReader<R = any>
MDN Referencewriter:
interface Uint8Array
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.NodeJS.WritableStream
(parameter) writer: NodeJS.WritableStream
): Promise
type NodeJS.WritableStream = /*unresolved*/ any
=> { let readResult = await
interface Promise<T>
Represents the completion of an asynchronous operationreader
let readResult: ReadableStreamReadResult<Uint8Array>
.read()
(parameter) reader: ReadableStreamDefaultReader<Uint8Array>
while (!readResult
(method) ReadableStreamDefaultReader<Uint8Array>.read(): Promise<ReadableStreamReadResult<Uint8Array>>
MDN Reference.done) {
let readResult: ReadableStreamReadResult<Uint8Array>
writer.write
(property) done: boolean
(readResult
(parameter) writer: NodeJS.WritableStream
.value)
let readResult: ReadableStreamReadValueResult<Uint8Array>
readResult = await
(property) ReadableStreamReadValueResult<Uint8Array>.value: Uint8Array
reader
let readResult: ReadableStreamReadResult<Uint8Array>
.read()
(parameter) reader: ReadableStreamDefaultReader<Uint8Array>
} writer.end()
(method) ReadableStreamDefaultReader<Uint8Array>.read(): Promise<ReadableStreamReadResult<Uint8Array>>
MDN Reference} export const streamHandle = <
(parameter) writer: NodeJS.WritableStream
E extends
const streamHandle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => Handler
Env =
(type parameter) E in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): Handler
Env,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
S extends
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Schema = {},
(type parameter) S in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): Handler
BasePath extends string = '/'
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
>( app:
(type parameter) BasePath in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): Handler
Hono
(parameter) app: Hono<E, S, BasePath>
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E,BasePath
— The base path type.S,
(type parameter) E in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): Handler
BasePath>
(type parameter) S in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): Handler
): Handler => {
(type parameter) BasePath in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): Handler
// @ts-expect-error awslambda is not a standard API return awslambda.streamifyResponse( async (event:
(alias) type Handler<TEvent = any, TResult = any> = (event: TEvent, context: LambdaContext, callback: Callback<TResult>) => void | Promise<TResult> import Handler
LambdaEvent,
(parameter) event: LambdaEvent
responseStream:
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
NodeJS.WritableStream,
(parameter) responseStream: NodeJS.WritableStream
context:
type NodeJS.WritableStream = /*unresolved*/ any
LambdaContext) => {
(parameter) context: LambdaContext
const processor =
(alias) interface LambdaContext import LambdaContext
Handler context parameter. See AWS documentation.getProcessor
const processor: EventProcessor<LambdaEvent>
(event)
const getProcessor: (event: LambdaEvent) => EventProcessor<LambdaEvent>
try { const req =
(parameter) event: LambdaEvent
processor
const req: Request
.createRequest
const processor: EventProcessor<LambdaEvent>
(event)
(method) EventProcessor<LambdaEvent>.createRequest(event: LambdaEvent): Request
const requestContext =
(parameter) event: LambdaEvent
getRequestContext
const requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
(event)
const getRequestContext: (event: LambdaEvent) => ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
const res = await
(parameter) event: LambdaEvent
app
const res: Response
.fetch
(parameter) app: Hono<E, S, BasePath>
(property) Hono<E, S, BasePath>.fetch: (request: Request, Env?: {} | E["Bindings"] | undefined, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(req, {event,
const req: Request
requestContext,
(property) event: LambdaEvent
context,
(property) requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
}) const headers:
(property) context: LambdaContext
Record
const headers: Record<string, string>
= {} const cookies: string[] = []
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tres
const cookies: string[]
.headers
const res: Response
.forEach(
(property) Response.headers: Headers
MDN Reference(value,
(method) Headers.forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void
name) => {
(parameter) value: string
if (name === 'set-cookie') {
(parameter) name: string
cookies
(parameter) name: string
.push
const cookies: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(value)items
— New elements to add to the array.} else { headers
(parameter) value: string
[name] =
const headers: Record<string, string>
value
(parameter) name: string
} }) // Check content type const httpResponseMetadata = {
(parameter) value: string
statusCode:
const httpResponseMetadata: { statusCode: number; headers: Record<string, string>; cookies: string[]; }
res
(property) statusCode: number
.status,
const res: Response
headers,
(property) Response.status: number
MDN Referencecookies,
(property) headers: Record<string, string>
} // Update response stream // @ts-expect-error awslambda is not a standard API responseStream = awslambda.HttpResponseStream.from
(property) cookies: string[]
(responseStream,
(parameter) responseStream: NodeJS.WritableStream
httpResponseMetadata)
(parameter) responseStream: NodeJS.WritableStream
if (res
const httpResponseMetadata: { statusCode: number; headers: Record<string, string>; cookies: string[]; }
.body) {
const res: Response
await streamToNodeStream
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference(res
const streamToNodeStream: (reader: ReadableStreamDefaultReader<Uint8Array>, writer: NodeJS.WritableStream) => Promise<void>
.body
const res: Response
.getReader(),
(property) Body.body: ReadableStream<Uint8Array>
MDN ReferenceresponseStream)
(method) ReadableStream<Uint8Array>.getReader(): ReadableStreamDefaultReader<Uint8Array> (+2 overloads)
MDN Reference} else { responseStream.write('')
(parameter) responseStream: NodeJS.WritableStream
} } catch (error) {
(parameter) responseStream: NodeJS.WritableStream
console
(local var) error: unknown
.error('Error processing request:',
var console: Console
error)
(method) Console.error(...data: any[]): void
MDN ReferenceresponseStream.write('Internal Server Error')
(local var) error: unknown
} finally { responseStream.end()
(parameter) responseStream: NodeJS.WritableStream
} } ) } /** * Accepts events from API Gateway/ELB(`APIGatewayProxyEvent`) and directly through Function Url(`APIGatewayProxyEventV2`) */ export const handle =
(parameter) responseStream: NodeJS.WritableStream
<E extends
const handle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>)
Accepts events from API Gateway/ELB(APIGatewayProxyEvent
) and directly through Function Url(APIGatewayProxyEventV2
)Env =
(type parameter) E in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>)
Env,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
S extends
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Schema = {},
(type parameter) S in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>)
BasePath extends string = '/'>(
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
app:
(type parameter) BasePath in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>)
Hono
(parameter) app: Hono<E, S, BasePath>
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E,BasePath
— The base path type.S,
(type parameter) E in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>)
BasePath>
(type parameter) S in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>)
): ((event:
(type parameter) BasePath in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>): ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>)
LambdaEvent,
(parameter) event: LambdaEvent
lambdaContext?:
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
LambdaContext) =>
(parameter) lambdaContext: LambdaContext | undefined
Promise
(alias) interface LambdaContext import LambdaContext
Handler context parameter. See AWS documentation.<APIGatewayProxyResult>) => {
interface Promise<T>
Represents the completion of an asynchronous operationreturn async (event,
interface APIGatewayProxyResult
lambdaContext?) => {
(parameter) event: LambdaEvent
const processor =
(parameter) lambdaContext: LambdaContext | undefined
getProcessor
const processor: EventProcessor<LambdaEvent>
(event)
const getProcessor: (event: LambdaEvent) => EventProcessor<LambdaEvent>
const req =
(parameter) event: LambdaEvent
processor
const req: Request
.createRequest
const processor: EventProcessor<LambdaEvent>
(event)
(method) EventProcessor<LambdaEvent>.createRequest(event: LambdaEvent): Request
const requestContext =
(parameter) event: LambdaEvent
getRequestContext
const requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
(event)
const getRequestContext: (event: LambdaEvent) => ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
const res = await
(parameter) event: LambdaEvent
app
const res: Response
.fetch
(parameter) app: Hono<E, S, BasePath>
(property) Hono<E, S, BasePath>.fetch: (request: Request, Env?: {} | E["Bindings"] | undefined, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(req, {event,
const req: Request
requestContext,
(property) event: LambdaEvent
lambdaContext,
(property) requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
}) return processor
(property) lambdaContext: LambdaContext | undefined
.createResult
const processor: EventProcessor<LambdaEvent>
(event,
(method) EventProcessor<LambdaEvent>.createResult(event: LambdaEvent, res: Response): Promise<APIGatewayProxyResult>
res)
(parameter) event: LambdaEvent
} } abstract class EventProcessor
const res: Response
<E extends
class EventProcessor<E extends LambdaEvent>
LambdaEvent> {
(type parameter) E in EventProcessor<E extends LambdaEvent>
protected abstract getPath
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
(event:
(method) EventProcessor<E extends LambdaEvent>.getPath(event: E): string
E): string
(parameter) event: E extends LambdaEvent
protected abstract getMethod
(type parameter) E in EventProcessor<E extends LambdaEvent>
(event:
(method) EventProcessor<E extends LambdaEvent>.getMethod(event: E): string
E): string
(parameter) event: E extends LambdaEvent
protected abstract getQueryString
(type parameter) E in EventProcessor<E extends LambdaEvent>
(event:
(method) EventProcessor<E extends LambdaEvent>.getQueryString(event: E): string
E): string
(parameter) event: E extends LambdaEvent
protected abstract getHeaders
(type parameter) E in EventProcessor<E extends LambdaEvent>
(event:
(method) EventProcessor<E extends LambdaEvent>.getHeaders(event: E): Headers
E):
(parameter) event: E extends LambdaEvent
Headers
(type parameter) E in EventProcessor<E extends LambdaEvent>
protected abstract getCookies
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.(event:
(method) EventProcessor<E extends LambdaEvent>.getCookies(event: E, headers: Headers): void
E,
(parameter) event: E extends LambdaEvent
headers:
(type parameter) E in EventProcessor<E extends LambdaEvent>
Headers): void
(parameter) headers: Headers
protected abstract setCookiesToResult(
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.event:
(method) EventProcessor<E extends LambdaEvent>.setCookiesToResult(event: E, result: APIGatewayProxyResult, cookies: string[]): void
E,
(parameter) event: E extends LambdaEvent
result:
(type parameter) E in EventProcessor<E extends LambdaEvent>
APIGatewayProxyResult,
(parameter) result: APIGatewayProxyResult
cookies: string[]
interface APIGatewayProxyResult
): void createRequest
(parameter) cookies: string[]
(event:
(method) EventProcessor<E extends LambdaEvent>.createRequest(event: E): Request
E):
(parameter) event: E extends LambdaEvent
Request {
(type parameter) E in EventProcessor<E extends LambdaEvent>
const queryString = this
interface Request
This Fetch API interface represents a resource request..getQueryString
const queryString: string
(event)
(method) EventProcessor<E extends LambdaEvent>.getQueryString(event: E): string
const domainName =
(parameter) event: E extends LambdaEvent
event
const domainName: string | undefined
.requestContext && 'domainName' in
(parameter) event: LambdaEvent
event
(property) requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
.requestContext
(parameter) event: LambdaEvent
? event
(property) requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
.requestContext
(parameter) event: LambdaEvent
.domainName
(property) requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2
: event
(property) domainName: string
.headers?.['host'] ??
(parameter) event: LambdaEvent
event
(property) headers?: Record<string, string | undefined> | undefined
.multiValueHeaders?.['host']?.[0]
(parameter) event: LambdaEvent
const path = this
(property) multiValueHeaders?: { [headerKey: string]: string[]; } | Record<string, string[] | undefined> | undefined
.getPath
const path: string
(event)
(method) EventProcessor<E extends LambdaEvent>.getPath(event: E): string
const urlPath = `https://$
(parameter) event: E extends LambdaEvent
{domainName}$
const urlPath: string
{path}`
const domainName: string | undefined
const url =
const path: string
queryString ? `$
const url: string
{urlPath}?$
const queryString: string
{queryString}` :
const urlPath: string
urlPath
const queryString: string
const headers = this
const urlPath: string
.getHeaders
const headers: Headers
(event)
(method) EventProcessor<E extends LambdaEvent>.getHeaders(event: E): Headers
const method = this
(parameter) event: E extends LambdaEvent
.getMethod
const method: string
(event)
(method) EventProcessor<E extends LambdaEvent>.getMethod(event: E): string
const requestInit:
(parameter) event: E extends LambdaEvent
RequestInit = {
const requestInit: RequestInit
headers,
interface RequestInit
method,
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.} if (event
(property) RequestInit.method?: string | undefined
A string to set request's method..body) {
(parameter) event: LambdaEvent
requestInit
(property) body: string | null
.body =
const requestInit: RequestInit
event
(property) RequestInit.body?: BodyInit | null | undefined
A BodyInit object or null to set request's body..isBase64Encoded ?
(parameter) event: LambdaEvent
decodeBase64
(property) isBase64Encoded: boolean
(event
(alias) decodeBase64(str: string): Uint8Array import decodeBase64
.body) :
(parameter) event: LambdaEvent
event
(property) body: string
.body
(parameter) event: LambdaEvent
} return new Request
(property) body: string
(url,
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.requestInit)
const url: string
} async createResult
const requestInit: RequestInit
(event:
(method) EventProcessor<E extends LambdaEvent>.createResult(event: E, res: Response): Promise<APIGatewayProxyResult>
E,
(parameter) event: E extends LambdaEvent
res:
(type parameter) E in EventProcessor<E extends LambdaEvent>
Response):
(parameter) res: Response
Promise
interface Response
This Fetch API interface represents the response to a request.<APIGatewayProxyResult> {
interface Promise<T>
Represents the completion of an asynchronous operationconst contentType =
interface APIGatewayProxyResult
res
const contentType: string | null
.headers
(parameter) res: Response
.get('content-type')
(property) Response.headers: Headers
MDN Referencelet isBase64Encoded =
(method) Headers.get(name: string): string | null
MDN ReferencecontentType &&
let isBase64Encoded: boolean
isContentTypeBinary
const contentType: string | null
(contentType) ? true : false
const isContentTypeBinary: (contentType: string) => boolean
if (!isBase64Encoded) {
const contentType: string
const contentEncoding =
let isBase64Encoded: boolean
res
const contentEncoding: string | null
.headers
(parameter) res: Response
.get('content-encoding')
(property) Response.headers: Headers
MDN ReferenceisBase64Encoded =
(method) Headers.get(name: string): string | null
MDN ReferenceisContentEncodingBinary
let isBase64Encoded: boolean
(contentEncoding)
const isContentEncodingBinary: (contentEncoding: string | null) => boolean
} const body =
const contentEncoding: string | null
isBase64Encoded ?
const body: string
encodeBase64(await
let isBase64Encoded: boolean
res
(alias) encodeBase64(buf: ArrayBufferLike): string import encodeBase64
.arrayBuffer()) : await
(parameter) res: Response
res
(method) Body.arrayBuffer(): Promise<ArrayBuffer>
MDN Reference.text()
(parameter) res: Response
const result:
(method) Body.text(): Promise<string>
MDN ReferenceAPIGatewayProxyResult = {
const result: APIGatewayProxyResult
body:
interface APIGatewayProxyResult
body,
(property) APIGatewayProxyResult.body: string
headers: {},
const body: string
multiValueHeaders:
(property) APIGatewayProxyResult.headers: Record<string, string>
event
(property) APIGatewayProxyResult.multiValueHeaders?: { [headerKey: string]: string[]; } | undefined
.multiValueHeaders ? {} : undefined,
(parameter) event: LambdaEvent
statusCode:
(property) multiValueHeaders?: { [headerKey: string]: string[]; } | Record<string, string[] | undefined> | undefined
res
(property) APIGatewayProxyResult.statusCode: number
.status,
(parameter) res: Response
isBase64Encoded,
(property) Response.status: number
MDN Reference} this.setCookies
(property) APIGatewayProxyResult.isBase64Encoded: boolean
(event,
(method) EventProcessor<E extends LambdaEvent>.setCookies(event: E, res: Response, result: APIGatewayProxyResult): void
res,
(parameter) event: E extends LambdaEvent
result)
(parameter) res: Response
res
const result: APIGatewayProxyResult
.headers
(parameter) res: Response
.forEach(
(property) Response.headers: Headers
MDN Reference(value,
(method) Headers.forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void
key) => {
(parameter) value: string
result
(parameter) key: string
.headers
const result: APIGatewayProxyResult
[key] =
(property) APIGatewayProxyResult.headers: Record<string, string>
value
(parameter) key: string
if (event
(parameter) value: string
.multiValueHeaders &&
(parameter) event: LambdaEvent
result
(property) multiValueHeaders?: { [headerKey: string]: string[]; } | Record<string, string[] | undefined> | undefined
.multiValueHeaders) {
const result: APIGatewayProxyResult
result
(property) APIGatewayProxyResult.multiValueHeaders?: { [headerKey: string]: string[]; } | undefined
.multiValueHeaders
const result: APIGatewayProxyResult
[key] =
(property) APIGatewayProxyResult.multiValueHeaders?: { [headerKey: string]: string[]; }
[value]
(parameter) key: string
} }) return result
(parameter) value: string
} setCookies
const result: APIGatewayProxyResult
(event:
(method) EventProcessor<E extends LambdaEvent>.setCookies(event: E, res: Response, result: APIGatewayProxyResult): void
E,
(parameter) event: E extends LambdaEvent
res:
(type parameter) E in EventProcessor<E extends LambdaEvent>
Response,
(parameter) res: Response
result:
interface Response
This Fetch API interface represents the response to a request.APIGatewayProxyResult) {
(parameter) result: APIGatewayProxyResult
if (res
interface APIGatewayProxyResult
.headers
(parameter) res: Response
.has('set-cookie')) {
(property) Response.headers: Headers
MDN Referenceconst cookies =
(method) Headers.has(name: string): boolean
MDN Referenceres
const cookies: string[]
.headers
(parameter) res: Response
.getSetCookie
(property) Response.headers: Headers
MDN Reference? res
(method) Headers.getSetCookie(): string[]
MDN Reference.headers
(parameter) res: Response
.getSetCookie()
(property) Response.headers: Headers
MDN Reference: Array
(method) Headers.getSetCookie(): string[]
MDN Reference.from
var Array: ArrayConstructor
(method) ArrayConstructor.from<[string, string]>(iterable: Iterable<[string, string]> | ArrayLike<[string, string]>): [string, string][] (+3 overloads)
Creates an array from an iterable object.@param
(resiterable
— An iterable object to convert to an array..headers
(parameter) res: Response
.entries())
(property) Response.headers: Headers
MDN Reference.filter((
(method) Headers.entries(): HeadersIterator<[string, string]>
Returns an iterator allowing to go through all key/value pairs contained in this object.
(method) Array<[string, string]>.filter(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): [string, string][] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.@param
predicate
— A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@param
[k]) =>thisArg
— An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.k === 'set-cookie')
(parameter) k: string
.map(([,
(parameter) k: string
(method) Array<[string, string]>.map<string>(callbackfn: (value: [string, string], index: number, array: [string, string][]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
v]) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.v)
(parameter) v: string
if (Array
(parameter) v: string
.isArray
var Array: ArrayConstructor
(cookies)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
this.setCookiesToResult
const cookies: string[]
(event,
(method) EventProcessor<E extends LambdaEvent>.setCookiesToResult(event: E, result: APIGatewayProxyResult, cookies: string[]): void
result,
(parameter) event: E extends LambdaEvent
cookies)
(parameter) result: APIGatewayProxyResult
res
const cookies: string[]
.headers
(parameter) res: Response
.delete('set-cookie')
(property) Response.headers: Headers
MDN Reference} } } } class EventV2Processor extends
(method) Headers.delete(name: string): void
MDN ReferenceEventProcessor
class EventV2Processor
<APIGatewayProxyEventV2> {
class EventProcessor<E extends LambdaEvent>
protected getPath
interface APIGatewayProxyEventV2
(event:
(method) EventV2Processor.getPath(event: APIGatewayProxyEventV2): string
APIGatewayProxyEventV2): string {
(parameter) event: APIGatewayProxyEventV2
return event
interface APIGatewayProxyEventV2
.rawPath
(parameter) event: APIGatewayProxyEventV2
} protected getMethod
(property) APIGatewayProxyEventV2.rawPath: string
(event:
(method) EventV2Processor.getMethod(event: APIGatewayProxyEventV2): string
APIGatewayProxyEventV2): string {
(parameter) event: APIGatewayProxyEventV2
return event
interface APIGatewayProxyEventV2
.requestContext
(parameter) event: APIGatewayProxyEventV2
.http
(property) APIGatewayProxyEventV2.requestContext: ApiGatewayRequestContextV2
.method
(property) ApiGatewayRequestContextV2.http: { method: string; path: string; protocol: string; sourceIp: string; userAgent: string; }
} protected getQueryString
(property) method: string
(event:
(method) EventV2Processor.getQueryString(event: APIGatewayProxyEventV2): string
APIGatewayProxyEventV2): string {
(parameter) event: APIGatewayProxyEventV2
return event
interface APIGatewayProxyEventV2
.rawQueryString
(parameter) event: APIGatewayProxyEventV2
} protected getCookies
(property) APIGatewayProxyEventV2.rawQueryString: string
(event:
(method) EventV2Processor.getCookies(event: APIGatewayProxyEventV2, headers: Headers): void
APIGatewayProxyEventV2,
(parameter) event: APIGatewayProxyEventV2
headers:
interface APIGatewayProxyEventV2
Headers): void {
(parameter) headers: Headers
if (Array
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence..isArray
var Array: ArrayConstructor
(event
(method) ArrayConstructor.isArray(arg: any): arg is any[]
.cookies)) {
(parameter) event: APIGatewayProxyEventV2
headers
(property) APIGatewayProxyEventV2.cookies?: string[] | undefined
.set('Cookie',
(parameter) headers: Headers
event
(method) Headers.set(name: string, value: string): void
MDN Reference.cookies
(parameter) event: APIGatewayProxyEventV2
.join('; '))
(property) APIGatewayProxyEventV2.cookies?: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} } protected setCookiesToResult(separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma._:
(method) EventV2Processor.setCookiesToResult(_: APIGatewayProxyEventV2, result: APIGatewayProxyResult, cookies: string[]): void
APIGatewayProxyEventV2,
(parameter) _: APIGatewayProxyEventV2
result:
interface APIGatewayProxyEventV2
APIGatewayProxyResult,
(parameter) result: APIGatewayProxyResult
cookies: string[]
interface APIGatewayProxyResult
): void { result
(parameter) cookies: string[]
.cookies =
(parameter) result: APIGatewayProxyResult
cookies
(property) APIGatewayProxyResult.cookies?: string[] | undefined
} protected getHeaders
(parameter) cookies: string[]
(event:
(method) EventV2Processor.getHeaders(event: APIGatewayProxyEventV2): Headers
APIGatewayProxyEventV2):
(parameter) event: APIGatewayProxyEventV2
Headers {
interface APIGatewayProxyEventV2
const headers = new
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.Headers()
const headers: Headers
this.getCookies
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.(event,
(method) EventV2Processor.getCookies(event: APIGatewayProxyEventV2, headers: Headers): void
headers)
(parameter) event: APIGatewayProxyEventV2
if (event
const headers: Headers
.headers) {
(parameter) event: APIGatewayProxyEventV2
for (const [k,
(property) APIGatewayProxyEventV2.headers: Record<string, string | undefined>
v] of
const k: string
Object
const v: string | undefined
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | undefined>(o: { [s: string]: string | undefined; } | ArrayLike<string | undefined>): [string, string | undefined][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..headers)) {
(parameter) event: APIGatewayProxyEventV2
if (v) {
(property) APIGatewayProxyEventV2.headers: Record<string, string | undefined>
headers
const v: string | undefined
.set
const headers: Headers
(k,
(method) Headers.set(name: string, value: string): void
MDN Referencev)
const k: string
} } } return headers
const v: string
} } const v2Processor:
const headers: Headers
EventV2Processor = new
const v2Processor: EventV2Processor
EventV2Processor()
class EventV2Processor
class EventV1Processor extends
constructor EventV2Processor<APIGatewayProxyEventV2>(): EventV2Processor
EventProcessor
class EventV1Processor
<Exclude
class EventProcessor<E extends LambdaEvent>
<LambdaEvent,
type Exclude<T, U> = T extends U ? never : T
Exclude from T those types that are assignable to UAPIGatewayProxyEventV2>> {
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
protected getPath
interface APIGatewayProxyEventV2
(event:
(method) EventV1Processor.getPath(event: Exclude<LambdaEvent, APIGatewayProxyEventV2>): string
Exclude
(parameter) event: APIGatewayProxyEvent | ALBProxyEvent
<LambdaEvent,
type Exclude<T, U> = T extends U ? never : T
Exclude from T those types that are assignable to UAPIGatewayProxyEventV2>): string {
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
return event
interface APIGatewayProxyEventV2
.path
(parameter) event: APIGatewayProxyEvent | ALBProxyEvent
} protected getMethod
(property) path: string
(event:
(method) EventV1Processor.getMethod(event: Exclude<LambdaEvent, APIGatewayProxyEventV2>): string
Exclude
(parameter) event: APIGatewayProxyEvent | ALBProxyEvent
<LambdaEvent,
type Exclude<T, U> = T extends U ? never : T
Exclude from T those types that are assignable to UAPIGatewayProxyEventV2>): string {
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
return event
interface APIGatewayProxyEventV2
.httpMethod
(parameter) event: APIGatewayProxyEvent | ALBProxyEvent
} protected getQueryString
(property) httpMethod: string
(event:
(method) EventV1Processor.getQueryString(event: Exclude<LambdaEvent, APIGatewayProxyEventV2>): string
Exclude
(parameter) event: APIGatewayProxyEvent | ALBProxyEvent
<LambdaEvent,
type Exclude<T, U> = T extends U ? never : T
Exclude from T those types that are assignable to UAPIGatewayProxyEventV2>): string {
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
return Object
interface APIGatewayProxyEventV2
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | undefined>(o: { [s: string]: string | undefined; } | ArrayLike<string | undefined>): [string, string | undefined][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..queryStringParameters || {})
(parameter) event: APIGatewayProxyEvent | ALBProxyEvent
.filter(([,
(property) queryStringParameters?: Record<string, string | undefined> | undefined
(method) Array<[string, string | undefined]>.filter(predicate: (value: [string, string | undefined], index: number, array: [string, string | undefined][]) => unknown, thisArg?: any): [string, string | undefined][] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.@param
predicate
— A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@param
value]) =>thisArg
— An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.value)
(parameter) value: string | undefined
.map((
(parameter) value: string | undefined
(method) Array<[string, string | undefined]>.map<string>(callbackfn: (value: [string, string | undefined], index: number, array: [string, string | undefined][]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
[key,thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.value]) => `$
(parameter) key: string
{key}=$
(parameter) value: string | undefined
{value}`)
(parameter) key: string
.join('&')
(parameter) value: string | undefined
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} protected getCookies(separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.// eslint-disable-next-line @typescript-eslint/no-unused-vars event:
(method) EventV1Processor.getCookies(event: Exclude<LambdaEvent, APIGatewayProxyEventV2>, headers: Headers): void
Exclude
(parameter) event: APIGatewayProxyEvent | ALBProxyEvent
<LambdaEvent,
type Exclude<T, U> = T extends U ? never : T
Exclude from T those types that are assignable to UAPIGatewayProxyEventV2>,
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
// eslint-disable-next-line @typescript-eslint/no-unused-vars headers:
interface APIGatewayProxyEventV2
Headers
(parameter) headers: Headers
): void { // nop } protected getHeaders
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.(event:
(method) EventV1Processor.getHeaders(event: APIGatewayProxyEvent): Headers
APIGatewayProxyEvent):
(parameter) event: APIGatewayProxyEvent
Headers {
interface APIGatewayProxyEvent
const headers = new
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.Headers()
const headers: Headers
this.getCookies
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.(event,
(method) EventV1Processor.getCookies(event: Exclude<LambdaEvent, APIGatewayProxyEventV2>, headers: Headers): void
headers)
(parameter) event: APIGatewayProxyEvent
if (event
const headers: Headers
.headers) {
(parameter) event: APIGatewayProxyEvent
for (const [k,
(property) APIGatewayProxyEvent.headers: Record<string, string | undefined>
v] of
const k: string
Object
const v: string | undefined
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | undefined>(o: { [s: string]: string | undefined; } | ArrayLike<string | undefined>): [string, string | undefined][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..headers)) {
(parameter) event: APIGatewayProxyEvent
if (v) {
(property) APIGatewayProxyEvent.headers: Record<string, string | undefined>
headers
const v: string | undefined
.set
const headers: Headers
(k,
(method) Headers.set(name: string, value: string): void
MDN Referencev)
const k: string
} } } if (event
const v: string
.multiValueHeaders) {
(parameter) event: APIGatewayProxyEvent
for (const [k,
(property) APIGatewayProxyEvent.multiValueHeaders?: { [headerKey: string]: string[]; } | undefined
values] of
const k: string
Object
const values: string[]
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string[]>(o: { [s: string]: string[]; } | ArrayLike<string[]>): [string, string[]][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..multiValueHeaders)) {
(parameter) event: APIGatewayProxyEvent
if (values) {
(property) APIGatewayProxyEvent.multiValueHeaders?: { [headerKey: string]: string[]; }
// avoid duplicating already set headers const foundK =
const values: string[]
headers
const foundK: string | null
.get
const headers: Headers
(k)
(method) Headers.get(name: string): string | null
MDN Referencevalues
const k: string
.forEach(
const values: string[]
(method) Array<string>.forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(v) => (thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.!foundK ||
(parameter) v: string
!foundK
const foundK: string | null
.includes
const foundK: string
(method) String.includes(searchString: string, position?: number): boolean
Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.@param
searchString
— search string@param
(v)) &&position
— If position is undefined, 0 is assumed, so as to search all of the String.headers
(parameter) v: string
.append
const headers: Headers
(k,
(method) Headers.append(name: string, value: string): void
MDN Referencev))
const k: string
} } } return headers
(parameter) v: string
} protected setCookiesToResult(
const headers: Headers
_:
(method) EventV1Processor.setCookiesToResult(_: APIGatewayProxyEvent, result: APIGatewayProxyResult, cookies: string[]): void
APIGatewayProxyEvent,
(parameter) _: APIGatewayProxyEvent
result:
interface APIGatewayProxyEvent
APIGatewayProxyResult,
(parameter) result: APIGatewayProxyResult
cookies: string[]
interface APIGatewayProxyResult
): void { result
(parameter) cookies: string[]
.multiValueHeaders = {
(parameter) result: APIGatewayProxyResult
'set-cookie': cookies,
(property) APIGatewayProxyResult.multiValueHeaders?: { [headerKey: string]: string[]; } | undefined
} } } const v1Processor:
(parameter) cookies: string[]
EventV1Processor = new
const v1Processor: EventV1Processor
EventV1Processor()
class EventV1Processor
class ALBProcessor extends
constructor EventV1Processor<APIGatewayProxyEvent | ALBProxyEvent>(): EventV1Processor
EventProcessor
class ALBProcessor
<ALBProxyEvent> {
class EventProcessor<E extends LambdaEvent>
protected getHeaders
interface ALBProxyEvent
(event:
(method) ALBProcessor.getHeaders(event: ALBProxyEvent): Headers
ALBProxyEvent):
(parameter) event: ALBProxyEvent
Headers {
interface ALBProxyEvent
const headers = new
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.Headers()
const headers: Headers
// if multiValueHeaders is present the ALB will use it instead of the headers field // https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers if (event
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence..multiValueHeaders) {
(parameter) event: ALBProxyEvent
for (const [key,
(property) ALBProxyEvent.multiValueHeaders?: Record<string, string[] | undefined> | undefined
values] of
const key: string
Object
const values: string[] | undefined
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string[] | undefined>(o: { [s: string]: string[] | undefined; } | ArrayLike<string[] | undefined>): [string, string[] | undefined][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..multiValueHeaders)) {
(parameter) event: ALBProxyEvent
if (values &&
(property) ALBProxyEvent.multiValueHeaders?: Record<string, string[] | undefined>
Array
const values: string[] | undefined
.isArray
var Array: ArrayConstructor
(values)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
// https://www.rfc-editor.org/rfc/rfc9110.html#name-common-rules-for-defining-f headers
const values: string[]
.set
const headers: Headers
(key,
(method) Headers.set(name: string, value: string): void
MDN Referencevalues
const key: string
.join('; '))
const values: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} } } else { for (const [key,separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.value] of
const key: string
Object
const value: string | undefined
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | undefined>(o: { [s: string]: string | undefined; } | ArrayLike<string | undefined>): [string, string | undefined][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..headers ?? {})) {
(parameter) event: ALBProxyEvent
if (value) {
(property) ALBProxyEvent.headers?: Record<string, string | undefined> | undefined
headers
const value: string | undefined
.set
const headers: Headers
(key,
(method) Headers.set(name: string, value: string): void
MDN Referencevalue)
const key: string
} } } return headers
const value: string
} protected getPath
const headers: Headers
(event:
(method) ALBProcessor.getPath(event: ALBProxyEvent): string
ALBProxyEvent): string {
(parameter) event: ALBProxyEvent
return event
interface ALBProxyEvent
.path
(parameter) event: ALBProxyEvent
} protected getMethod
(property) ALBProxyEvent.path: string
(event:
(method) ALBProcessor.getMethod(event: ALBProxyEvent): string
ALBProxyEvent): string {
(parameter) event: ALBProxyEvent
return event
interface ALBProxyEvent
.httpMethod
(parameter) event: ALBProxyEvent
} protected getQueryString
(property) ALBProxyEvent.httpMethod: string
(event:
(method) ALBProcessor.getQueryString(event: ALBProxyEvent): string
ALBProxyEvent): string {
(parameter) event: ALBProxyEvent
// In the case of ALB Integration either queryStringParameters or multiValueQueryStringParameters can be present not both /* In other cases like when using the serverless framework, the event object does contain both queryStringParameters and multiValueQueryStringParameters: Below is an example event object for this URL: /payment/b8c55e69?select=amount&select=currency { ... queryStringParameters: { select: 'currency' }, multiValueQueryStringParameters: { select: [ 'amount', 'currency' ] }, } The expected results is for select to be an array with two items. However the pre-fix code is only returning one item ('currency') in the array. A simple fix would be to invert the if statement and check the multiValueQueryStringParameters first. */ if (event
interface ALBProxyEvent
.multiValueQueryStringParameters) {
(parameter) event: ALBProxyEvent
return Object
(property) ALBProxyEvent.multiValueQueryStringParameters?: { [parameterKey: string]: string[]; } | undefined
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string[]>(o: { [s: string]: string[]; } | ArrayLike<string[]>): [string, string[]][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..multiValueQueryStringParameters || {})
(parameter) event: ALBProxyEvent
.filter(([,
(property) ALBProxyEvent.multiValueQueryStringParameters?: { [parameterKey: string]: string[]; }
(method) Array<[string, string[]]>.filter(predicate: (value: [string, string[]], index: number, array: [string, string[]][]) => unknown, thisArg?: any): [string, string[]][] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.@param
predicate
— A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@param
value]) =>thisArg
— An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.value)
(parameter) value: string[]
.map((
(parameter) value: string[]
(method) Array<[string, string[]]>.map<string>(callbackfn: (value: [string, string[]], index: number, array: [string, string[]][]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
[key,thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.value]) => `$
(parameter) key: string
{key}=$
(parameter) value: string[]
{value
(parameter) key: string
.join(`&$
(parameter) value: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
{key}=`)}`)separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma..join('&')
(parameter) key: string
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} else { return Objectseparator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma..entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | undefined>(o: { [s: string]: string | undefined; } | ArrayLike<string | undefined>): [string, string | undefined][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..queryStringParameters || {})
(parameter) event: ALBProxyEvent
.filter(([,
(property) ALBProxyEvent.queryStringParameters?: Record<string, string | undefined> | undefined
(method) Array<[string, string | undefined]>.filter(predicate: (value: [string, string | undefined], index: number, array: [string, string | undefined][]) => unknown, thisArg?: any): [string, string | undefined][] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.@param
predicate
— A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@param
value]) =>thisArg
— An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.value)
(parameter) value: string | undefined
.map((
(parameter) value: string | undefined
(method) Array<[string, string | undefined]>.map<string>(callbackfn: (value: [string, string | undefined], index: number, array: [string, string | undefined][]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
[key,thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.value]) => `$
(parameter) key: string
{key}=$
(parameter) value: string | undefined
{value}`)
(parameter) key: string
.join('&')
(parameter) value: string | undefined
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} } protected getCookiesseparator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.(event:
(method) ALBProcessor.getCookies(event: ALBProxyEvent, headers: Headers): void
ALBProxyEvent,
(parameter) event: ALBProxyEvent
headers:
interface ALBProxyEvent
Headers): void {
(parameter) headers: Headers
let cookie
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.if (event
let cookie: any
.multiValueHeaders) {
(parameter) event: ALBProxyEvent
cookie =
(property) ALBProxyEvent.multiValueHeaders?: Record<string, string[] | undefined> | undefined
event
let cookie: any
.multiValueHeaders['cookie']?
(parameter) event: ALBProxyEvent
.join('; ')
(property) ALBProxyEvent.multiValueHeaders?: Record<string, string[] | undefined>
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} else { cookie =separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.event
let cookie: any
.headers ?
(parameter) event: ALBProxyEvent
event
(property) ALBProxyEvent.headers?: Record<string, string | undefined> | undefined
.headers['cookie'] : undefined
(parameter) event: ALBProxyEvent
} if (cookie) {
(property) ALBProxyEvent.headers?: Record<string, string | undefined>
headers
let cookie: string | undefined
.append('Cookie',
(parameter) headers: Headers
cookie)
(method) Headers.append(name: string, value: string): void
MDN Reference} } protected setCookiesToResult(
let cookie: string
event:
(method) ALBProcessor.setCookiesToResult(event: ALBProxyEvent, result: APIGatewayProxyResult, cookies: string[]): void
ALBProxyEvent,
(parameter) event: ALBProxyEvent
result:
interface ALBProxyEvent
APIGatewayProxyResult,
(parameter) result: APIGatewayProxyResult
cookies: string[]
interface APIGatewayProxyResult
): void { // when multi value headers is enabled if (event
(parameter) cookies: string[]
.multiValueHeaders &&
(parameter) event: ALBProxyEvent
result
(property) ALBProxyEvent.multiValueHeaders?: Record<string, string[] | undefined> | undefined
.multiValueHeaders) {
(parameter) result: APIGatewayProxyResult
result
(property) APIGatewayProxyResult.multiValueHeaders?: { [headerKey: string]: string[]; } | undefined
.multiValueHeaders['set-cookie'] =
(parameter) result: APIGatewayProxyResult
cookies
(property) APIGatewayProxyResult.multiValueHeaders?: { [headerKey: string]: string[]; }
} else { // otherwise serialize the set-cookie result
(parameter) cookies: string[]
.headers['set-cookie'] =
(parameter) result: APIGatewayProxyResult
cookies
(property) APIGatewayProxyResult.headers: Record<string, string>
.join(', ')
(parameter) cookies: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} } } const albProcessor:separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.ALBProcessor = new
const albProcessor: ALBProcessor
ALBProcessor()
class ALBProcessor
export const getProcessor =
constructor ALBProcessor<ALBProxyEvent>(): ALBProcessor
(event:
const getProcessor: (event: LambdaEvent) => EventProcessor<LambdaEvent>
LambdaEvent):
(parameter) event: LambdaEvent
EventProcessor
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
<LambdaEvent> => {
class EventProcessor<E extends LambdaEvent>
if (isProxyEventALB
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
(event)) {
const isProxyEventALB: (event: LambdaEvent) => event is ALBProxyEvent
return albProcessor
(parameter) event: LambdaEvent
} if (isProxyEventV2
const albProcessor: ALBProcessor
(event)) {
const isProxyEventV2: (event: LambdaEvent) => event is APIGatewayProxyEventV2
return v2Processor
(parameter) event: APIGatewayProxyEvent | APIGatewayProxyEventV2
} return v1Processor
const v2Processor: EventV2Processor
} const isProxyEventALB =
const v1Processor: EventV1Processor
(event:
const isProxyEventALB: (event: LambdaEvent) => event is ALBProxyEvent
LambdaEvent):
(parameter) event: LambdaEvent
event is
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
ALBProxyEvent => {
(parameter) event: LambdaEvent
return Object
interface ALBProxyEvent
.hasOwn
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.hasOwn(o: object, v: PropertyKey): boolean
Determines whether an object has a property with the specified name.@param
o
— An object.@param
(eventv
— A property name..requestContext, 'elb')
(parameter) event: LambdaEvent
} const isProxyEventV2 =
(property) requestContext: ApiGatewayRequestContext | ApiGatewayRequestContextV2 | ALBRequestContext
(event:
const isProxyEventV2: (event: LambdaEvent) => event is APIGatewayProxyEventV2
LambdaEvent):
(parameter) event: LambdaEvent
event is
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent
APIGatewayProxyEventV2 => {
(parameter) event: LambdaEvent
return Object
interface APIGatewayProxyEventV2
.hasOwn
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.hasOwn(o: object, v: PropertyKey): boolean
Determines whether an object has a property with the specified name.@param
o
— An object.@param
(event, 'rawPath')v
— A property name.} export const isContentTypeBinary =
(parameter) event: LambdaEvent
(contentType: string) => {
const isContentTypeBinary: (contentType: string) => boolean
return !/^(text\/(plain|html|css|javascript|csv).*|application\/(.*json|.*xml).*|image\/svg\+xml.*)$/.test(
(parameter) contentType: string
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
contentTypestring
— String on which to perform the search.) } export const isContentEncodingBinary =
(parameter) contentType: string
(contentEncoding: string | null) => {
const isContentEncodingBinary: (contentEncoding: string | null) => boolean
if (contentEncoding === null) {
(parameter) contentEncoding: string | null
return false } return /^(gzip|deflate|compress|br)/.test
(parameter) contentEncoding: string | null
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
(contentEncoding)string
— String on which to perform the search.}
(parameter) contentEncoding: string
/** * @module * AWS Lambda Adapter for Hono. */ export { handle,streamHandle } from './handler'
(alias) const handle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>) export handle
Accepts events from API Gateway/ELB(APIGatewayProxyEvent
) and directly through Function Url(APIGatewayProxyEventV2
)export type { APIGatewayProxyResult,
(alias) const streamHandle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => Handler export streamHandle
LambdaEvent } from './handler'
(alias) interface APIGatewayProxyResult export APIGatewayProxyResult
export type { ApiGatewayRequestContext,
(alias) type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | ALBProxyEvent export LambdaEvent
ApiGatewayRequestContextV2,
(alias) interface ApiGatewayRequestContext export ApiGatewayRequestContext
ALBRequestContext,
(alias) interface ApiGatewayRequestContextV2 export ApiGatewayRequestContextV2
LambdaContext,
(alias) interface ALBRequestContext export ALBRequestContext
} from './types'
(alias) interface LambdaContext export LambdaContext
Handler context parameter. See AWS documentation.
/* eslint-disable @typescript-eslint/no-explicit-any */ export interface CognitoIdentity {cognitoIdentityId: string
interface CognitoIdentity
cognitoIdentityPoolId: string
(property) CognitoIdentity.cognitoIdentityId: string
} export interface ClientContext {
(property) CognitoIdentity.cognitoIdentityPoolId: string
client:
interface ClientContext
ClientContextClient
(property) ClientContext.client: ClientContextClient
Custom?: any
interface ClientContextClient
env:
(property) ClientContext.Custom?: any
ClientContextEnv
(property) ClientContext.env: ClientContextEnv
} export interface ClientContextClient {
interface ClientContextEnv
installationId: string
interface ClientContextClient
appTitle: string
(property) ClientContextClient.installationId: string
appVersionName: string
(property) ClientContextClient.appTitle: string
appVersionCode: string
(property) ClientContextClient.appVersionName: string
appPackageName: string
(property) ClientContextClient.appVersionCode: string
} export interface ClientContextEnv {
(property) ClientContextClient.appPackageName: string
platformVersion: string
interface ClientContextEnv
platform: string
(property) ClientContextEnv.platformVersion: string
make: string
(property) ClientContextEnv.platform: string
model: string
(property) ClientContextEnv.make: string
locale: string
(property) ClientContextEnv.model: string
} /** * {@link Handler} context parameter. * See {@link https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html AWS documentation}. */ export interface LambdaContext {
(property) ClientContextEnv.locale: string
callbackWaitsForEmptyEventLoop: boolean
interface LambdaContext
Handler context parameter. See AWS documentation.functionName: string
(property) LambdaContext.callbackWaitsForEmptyEventLoop: boolean
functionVersion: string
(property) LambdaContext.functionName: string
invokedFunctionArn: string
(property) LambdaContext.functionVersion: string
memoryLimitInMB: string
(property) LambdaContext.invokedFunctionArn: string
awsRequestId: string
(property) LambdaContext.memoryLimitInMB: string
logGroupName: string
(property) LambdaContext.awsRequestId: string
logStreamName: string
(property) LambdaContext.logGroupName: string
identity?:
(property) LambdaContext.logStreamName: string
CognitoIdentity | undefined
(property) LambdaContext.identity?: CognitoIdentity | undefined
clientContext?:
interface CognitoIdentity
ClientContext | undefined
(property) LambdaContext.clientContext?: ClientContext | undefined
getRemainingTimeInMillis(): number
interface ClientContext
} type Callback
(method) LambdaContext.getRemainingTimeInMillis(): number
<TResult = any> =
type Callback<TResult = any> = (error?: Error | string | null, result?: TResult) => void
(error?:
(type parameter) TResult in type Callback<TResult = any>
Error | string | null,
(parameter) error: string | Error | null | undefined
result?:
interface Error
TResult) => void
(parameter) result: TResult | undefined
export type Handler
(type parameter) TResult in type Callback<TResult = any>
<TEvent = any,
type Handler<TEvent = any, TResult = any> = (event: TEvent, context: LambdaContext, callback: Callback<TResult>) => void | Promise<TResult>
TResult = any> = (
(type parameter) TEvent in type Handler<TEvent = any, TResult = any>
event:
(type parameter) TResult in type Handler<TEvent = any, TResult = any>
TEvent,
(parameter) event: TEvent = any
context:
(type parameter) TEvent in type Handler<TEvent = any, TResult = any>
LambdaContext,
(parameter) context: LambdaContext
callback:
interface LambdaContext
Handler context parameter. See AWS documentation.Callback
(parameter) callback: Callback<TResult>
<TResult>
type Callback<TResult = any> = (error?: Error | string | null, result?: TResult) => void
) => void | Promise
(type parameter) TResult in type Handler<TEvent = any, TResult = any>
<TResult>
interface Promise<T>
Represents the completion of an asynchronous operationinterface ClientCert {
(type parameter) TResult in type Handler<TEvent = any, TResult = any>
clientCertPem: string
interface ClientCert
subjectDN: string
(property) ClientCert.clientCertPem: string
issuerDN: string
(property) ClientCert.subjectDN: string
serialNumber: string
(property) ClientCert.issuerDN: string
validity: {
(property) ClientCert.serialNumber: string
notBefore: string
(property) ClientCert.validity: { notBefore: string; notAfter: string; }
notAfter: string
(property) notBefore: string
} } interface Identity {
(property) notAfter: string
accessKey?: string
interface Identity
accountId?: string
(property) Identity.accessKey?: string | undefined
caller?: string
(property) Identity.accountId?: string | undefined
cognitoAuthenticationProvider?: string
(property) Identity.caller?: string | undefined
cognitoAuthenticationType?: string
(property) Identity.cognitoAuthenticationProvider?: string | undefined
cognitoIdentityId?: string
(property) Identity.cognitoAuthenticationType?: string | undefined
cognitoIdentityPoolId?: string
(property) Identity.cognitoIdentityId?: string | undefined
principalOrgId?: string
(property) Identity.cognitoIdentityPoolId?: string | undefined
sourceIp: string
(property) Identity.principalOrgId?: string | undefined
user?: string
(property) Identity.sourceIp: string
userAgent: string
(property) Identity.user?: string | undefined
userArn?: string
(property) Identity.userAgent: string
clientCert?:
(property) Identity.userArn?: string | undefined
ClientCert
(property) Identity.clientCert?: ClientCert | undefined
} export interface ApiGatewayRequestContext {
interface ClientCert
accountId: string
interface ApiGatewayRequestContext
apiId: string
(property) ApiGatewayRequestContext.accountId: string
authorizer: {
(property) ApiGatewayRequestContext.apiId: string
claims?: unknown
(property) ApiGatewayRequestContext.authorizer: { claims?: unknown; scopes?: unknown; }
scopes?: unknown
(property) claims?: unknown
} domainName: string
(property) scopes?: unknown
domainPrefix: string
(property) ApiGatewayRequestContext.domainName: string
extendedRequestId: string
(property) ApiGatewayRequestContext.domainPrefix: string
httpMethod: string
(property) ApiGatewayRequestContext.extendedRequestId: string
identity:
(property) ApiGatewayRequestContext.httpMethod: string
Identity
(property) ApiGatewayRequestContext.identity: Identity
path: string
interface Identity
protocol: string
(property) ApiGatewayRequestContext.path: string
requestId: string
(property) ApiGatewayRequestContext.protocol: string
requestTime: string
(property) ApiGatewayRequestContext.requestId: string
requestTimeEpoch: number
(property) ApiGatewayRequestContext.requestTime: string
resourceId?: string
(property) ApiGatewayRequestContext.requestTimeEpoch: number
resourcePath: string
(property) ApiGatewayRequestContext.resourceId?: string | undefined
stage: string
(property) ApiGatewayRequestContext.resourcePath: string
} interface Authorizer {
(property) ApiGatewayRequestContext.stage: string
iam?: {
interface Authorizer
accessKey: string
(property) Authorizer.iam?: { accessKey: string; accountId: string; callerId: string; cognitoIdentity: null; principalOrgId: null; userArn: string; userId: string; } | undefined
accountId: string
(property) accessKey: string
callerId: string
(property) accountId: string
cognitoIdentity: null
(property) callerId: string
principalOrgId: null
(property) cognitoIdentity: null
userArn: string
(property) principalOrgId: null
userId: string
(property) userArn: string
} } export interface ApiGatewayRequestContextV2 {
(property) userId: string
accountId: string
interface ApiGatewayRequestContextV2
apiId: string
(property) ApiGatewayRequestContextV2.accountId: string
authentication: null
(property) ApiGatewayRequestContextV2.apiId: string
authorizer:
(property) ApiGatewayRequestContextV2.authentication: null
Authorizer
(property) ApiGatewayRequestContextV2.authorizer: Authorizer
domainName: string
interface Authorizer
domainPrefix: string
(property) ApiGatewayRequestContextV2.domainName: string
http: {
(property) ApiGatewayRequestContextV2.domainPrefix: string
method: string
(property) ApiGatewayRequestContextV2.http: { method: string; path: string; protocol: string; sourceIp: string; userAgent: string; }
path: string
(property) method: string
protocol: string
(property) path: string
sourceIp: string
(property) protocol: string
userAgent: string
(property) sourceIp: string
} requestId: string
(property) userAgent: string
routeKey: string
(property) ApiGatewayRequestContextV2.requestId: string
stage: string
(property) ApiGatewayRequestContextV2.routeKey: string
time: string
(property) ApiGatewayRequestContextV2.stage: string
timeEpoch: number
(property) ApiGatewayRequestContextV2.time: string
} export interface ALBRequestContext {
(property) ApiGatewayRequestContextV2.timeEpoch: number
elb: {
interface ALBRequestContext
targetGroupArn: string
(property) ALBRequestContext.elb: { targetGroupArn: string; }
} }
(property) targetGroupArn: string
import { Context } from '../../context' import type { AddressType } from '../../helper/conninfo' import { getConnInfo } from './conninfo' const createRandomBunServer = ({address =
const createRandomBunServer: ({ address, port, family, }?: { address?: string; port?: number; family?: AddressType | string; }) => { address: string; port: number; server: { requestIP(): { address: string; family: string; port: number; }; }; }
Math
(parameter) address: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString(),
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
port =radix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers.Math
(parameter) port: number
.floor
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.
(method) Math.floor(x: number): number
Returns the greatest integer less than or equal to its numeric argument.@param
(Mathx
— A numeric expression..random() * (65535 + 1)),
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.family = 'IPv6',
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.}: { address?: string
(parameter) family: string
port?: number
(property) address?: string | undefined
family?:
(property) port?: number | undefined
AddressType | string
(property) family?: string | undefined
} = {}) => { return { address,
(alias) type AddressType = "IPv6" | "IPv4" | undefined import AddressType
port,
(property) address: string
server: {
(property) port: number
requestIP() {
(property) server: { requestIP(): { address: string; family: string; port: number; }; }
return { address,
(method) requestIP(): { address: string; family: string; port: number; }
family,
(property) address: string
port,
(property) family: string
} }, }, } } describe('getConnInfo', () => { it('Should info is valid', () => { const { port,
(property) port: number
server,
const port: number
address } =
const server: { requestIP(): { address: string; family: string; port: number; }; }
createRandomBunServer()
const address: string
const c = new
const createRandomBunServer: ({ address, port, family, }?: { address?: string; port?: number; family?: AddressType | string; }) => { address: string; port: number; server: { requestIP(): { address: string; family: string; port: number; }; }; }
Context(new
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.server })
(property) env: any
Bindings for the environment.const info =
const server: { requestIP(): { address: string; family: string; port: number; }; }
getConnInfo
const info: ConnInfo
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
Get ConnInfo with Bun@param
c
— Context@returns — ConnInfo
(c)expect(info
const c: Context<any, any, {}>
.remote
const info: ConnInfo
.port).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(port)
(property) port?: number | undefined
Transport port numberexpect(info
const port: number
.remote
const info: ConnInfo
.address).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(address)
(property) address?: string | undefined
Host name such as IP Addrexpect(info
const address: string
.remote
const info: ConnInfo
.addressType).toBe('IPv6')
(property) ConnInfo.remote: NetAddrInfo
Remote informationexpect(info
(property) addressType?: AddressType
Host name type.remote
const info: ConnInfo
.transport).toBeUndefined()
(property) ConnInfo.remote: NetAddrInfo
Remote information}) it('Should getConnInfo works when env is { server: server }', () => { const { port,
(property) transport?: "tcp" | "udp" | undefined
Transport protocol typeserver,
const port: number
address } =
const server: { requestIP(): { address: string; family: string; port: number; }; }
createRandomBunServer()
const address: string
const c = new
const createRandomBunServer: ({ address, port, family, }?: { address?: string; port?: number; family?: AddressType | string; }) => { address: string; port: number; server: { requestIP(): { address: string; family: string; port: number; }; }; }
Context(new
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.server } })
(property) env: any
Bindings for the environment.const info =
(property) server: { requestIP(): { address: string; family: string; port: number; }; }
getConnInfo
const info: ConnInfo
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
Get ConnInfo with Bun@param
c
— Context@returns — ConnInfo
(c)expect(info
const c: Context<any, any, {}>
.remote
const info: ConnInfo
.port).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(port)
(property) port?: number | undefined
Transport port numberexpect(info
const port: number
.remote
const info: ConnInfo
.address).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(address)
(property) address?: string | undefined
Host name such as IP Addrexpect(info
const address: string
.remote
const info: ConnInfo
.addressType).toBe('IPv6')
(property) ConnInfo.remote: NetAddrInfo
Remote informationexpect(info
(property) addressType?: AddressType
Host name type.remote
const info: ConnInfo
.transport).toBeUndefined()
(property) ConnInfo.remote: NetAddrInfo
Remote information}) it('should return undefined when addressType is invalid string', () => { const { server } =
(property) transport?: "tcp" | "udp" | undefined
Transport protocol typecreateRandomBunServer({
const server: { requestIP(): { address: string; family: string; port: number; }; }
family: 'invalid' })
const createRandomBunServer: ({ address, port, family, }?: { address?: string; port?: number; family?: AddressType | string; }) => { address: string; port: number; server: { requestIP(): { address: string; family: string; port: number; }; }; }
const c = new
(property) family?: string | undefined
Context(new
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.server } })
(property) env: any
Bindings for the environment.const info =
(property) server: { requestIP(): { address: string; family: string; port: number; }; }
getConnInfo
const info: ConnInfo
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
Get ConnInfo with Bun@param
c
— Context@returns — ConnInfo
(c)expect(info
const c: Context<any, any, {}>
.remote
const info: ConnInfo
.addressType).toBeUndefined()
(property) ConnInfo.remote: NetAddrInfo
Remote information}) it('Should throw error when user did not give server', () => { const c = new
(property) addressType?: AddressType
Host name typeContext(new
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env: {} })
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.expect(() => getConnInfo
(property) env: any
Bindings for the environment.
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
Get ConnInfo with Bun@param
c
— Context@returns — ConnInfo
(c)).toThrowError(TypeError)
const c: Context<any, any, {}>
}) it('Should throw error when requestIP is not function', () => { const c = new
var TypeError: TypeErrorConstructor
Context(new
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.requestIP: 0,
(property) env: any
Bindings for the environment.}, }) expect(() => getConnInfo
(property) requestIP: number
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
Get ConnInfo with Bun@param
c
— Context@returns — ConnInfo
(c)).toThrowError(TypeError)
const c: Context<any, any, {}>
}) })
var TypeError: TypeErrorConstructor
import type { Context } from '../..' import type { GetConnInfo } from '../../helper/conninfo' import { getBunServer } from './server' /** * Get ConnInfo with Bun * @param c Context * @returns ConnInfo */ export const getConnInfo:
const getConnInfo: GetConnInfo
Get ConnInfo with Bun@param
c
— Context@returns — ConnInfo
GetConnInfo =(c:
(alias) type GetConnInfo = (c: Context) => ConnInfo import GetConnInfo
Helper type
(parameter) c: Context<any, any, {}>
Context@param
Context) => {c
— Contextconst server =
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
getBunServer
const server: BunServer | undefined
(alias) getBunServer(c: Context): BunServer | undefined import getBunServer
Get Bun Server Object from Context@param
c
— Context@returns — Bun Server
(c)
(parameter) c: Context<any, any, {}>
Context@param
if (!server) {c
— Contextthrow new TypeError('env has to include the 2nd argument of fetch.')
const server: BunServer | undefined
} if (typeof server
var TypeError: TypeErrorConstructor new (message?: string, options?: ErrorOptions) => TypeError (+3 overloads)
.requestIP !== 'function') {
const server: BunServer
throw new TypeError('server.requestIP is not a function.')
(property) BunServer.requestIP?: ((req: Request) => { address: string; family: string; port: number; }) | undefined
} const info =
var TypeError: TypeErrorConstructor new (message?: string, options?: ErrorOptions) => TypeError (+3 overloads)
server
const info: { address: string; family: string; port: number; }
.requestIP
const server: BunServer
(c
(property) BunServer.requestIP?: (req: Request) => { address: string; family: string; port: number; }
(parameter) c: Context<any, any, {}>
Context@param
.reqc
— Context.raw)
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
return { remote: {
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
address:
(property) ConnInfo.remote: NetAddrInfo
Remote informationinfo
(property) address: string
.address,
const info: { address: string; family: string; port: number; }
addressType:
(property) address: string
info
(property) addressType: "IPv6" | "IPv4" | undefined
.family === 'IPv6' ||
const info: { address: string; family: string; port: number; }
info
(property) family: string
.family === 'IPv4' ?
const info: { address: string; family: string; port: number; }
info
(property) family: string
.family : undefined,
const info: { address: string; family: string; port: number; }
port:
(property) family: "IPv6" | "IPv4"
info
(property) port?: number | undefined
Transport port number.port,
const info: { address: string; family: string; port: number; }
}, } }
(property) port: number
/** * @module * Bun Adapter for Hono. */ export { serveStatic } from './serve-static'export { bunFileSystemModule,
(alias) const serveStatic: <E extends Env = Env>(options: ServeStaticOptions<E>) => MiddlewareHandler export serveStatic
(alias) const bunFileSystemModule: FileSystemModule export bunFileSystemModule
@experimental
toSSG } from './ssg'
bunFileSystemModule
is an experimental feature. The API might be changed.
(alias) const toSSG: ToSSGAdaptorInterface<Env, {}, "/"> export toSSG
@experimental
export { createBunWebSocket } from './websocket'
toSSG
is an experimental feature. The API might be changed.export { getConnInfo } from './conninfo'
(alias) const createBunWebSocket: <T>() => CreateWebSocket<T> export createBunWebSocket
(alias) const getConnInfo: GetConnInfo export getConnInfo
Get ConnInfo with Bun@param
c
— Context@returns — ConnInfo
/* eslint-disable @typescript-eslint/ban-ts-comment */ import { stat } from 'node:fs/promises' import { serveStatic as baseServeStatic } from '../../middleware/serve-static' import type { ServeStaticOptions } from '../../middleware/serve-static' import type { Env, MiddlewareHandler } from '../../types' export const serveStatic =<E extends
const serveStatic: <E extends Env = Env>(options: ServeStaticOptions<E>) => MiddlewareHandler
Env =
(type parameter) E in <E extends Env = Env>(options: ServeStaticOptions<E>): MiddlewareHandler
Env>(
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
options:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
ServeStaticOptions
(parameter) options: ServeStaticOptions<E>
<E>
(alias) 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>; } import ServeStaticOptions
): MiddlewareHandler => {
(type parameter) E in <E extends Env = Env>(options: ServeStaticOptions<E>): MiddlewareHandler
return async function serveStatic
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
(c,
(local function) serveStatic(c: Context<any, string, {}>, next: Next): Promise<void | Response>
next) {
(parameter) c: Context<any, string, {}>
const getContent = async
(parameter) next: Next
(path: string) => {
const getContent: (path: string) => Promise<any>
path =
(parameter) path: string
path
(parameter) path: string
.startsWith('/') ?
(parameter) path: string
path : `./$
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.{path}`
(parameter) path: string
// @ts-ignore const file = Bun.file
(parameter) path: string
(path)
const file: any
return (await file.exists()) ?
(parameter) path: string
file : null
const file: any
} const pathResolve =
const file: any
(path: string) => {
const pathResolve: (path: string) => string
return path
(parameter) path: string
.startsWith('/') ?
(parameter) path: string
path : `./$
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.{path}`
(parameter) path: string
} const isDir = async
(parameter) path: string
(path: string) => {
const isDir: (path: string) => Promise<any>
let isDir
(parameter) path: string
try { const stats = await stat
let isDir: any
(path)
const stats: any
isDir =
(parameter) path: string
stats.isDirectory()
let isDir: any
} catch {} return isDir
const stats: any
} return baseServeStatic({
let isDir: any
...options,
(alias) baseServeStatic<E>(options: ServeStaticOptions<E> & { getContent: (path: string, c: Context<E, any, {}>) => Promise<Data | Response | null>; pathResolve?: (path: string) => string; isDir?: (path: string) => boolean | undefined | Promise<boolean | undefined>; }): MiddlewareHandler import baseServeStatic
This middleware is not directly used by the user. Create a wrapper specifyinggetContent()
by the environment such as Deno or Bun.getContent,
(parameter) options: ServeStaticOptions<E>
pathResolve,
(property) getContent: (path: string, c: Context<E, any, {}>) => Promise<Data | Response | null>
isDir,
(property) pathResolve?: ((path: string) => string) | undefined
})(c,
(property) isDir?: ((path: string) => boolean | undefined | Promise<boolean | undefined>) | undefined
next)
(parameter) c: Context<any, string, {}>
} }
(parameter) next: Next
import { Context } from '../../context' import { getBunServer } from './server' import type { BunServer } from './server' describe('getBunServer', () => { it('Should success to pick Server', () => { const server = {} asBunServer
const server: BunServer
expect(getBunServer(new
(alias) interface BunServer import BunServer
Bun Server Object
(alias) getBunServer(c: Context): BunServer | undefined import getBunServer
Get Bun Server Object from Context@param
c
— Context@returns — Bun Server
Context(new
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.server }))).toBe(
(property) env: any
Bindings for the environment.server
const server: BunServer
) expect(getBunServer(new
const server: BunServer
(alias) getBunServer(c: Context): BunServer | undefined import getBunServer
Get Bun Server Object from Context@param
c
— Context@returns — Bun Server
Context(new
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.server } }))).toBe(
(property) env: any
Bindings for the environment.server
(property) server: BunServer
) }) })
const server: BunServer
/** * Getting Bun Server Object for Bun adapters * @module */ import type { Context } from '../../context' /** * Bun Server Object */ export interface BunServer {requestIP?:
interface BunServer
Bun Server Object(req:
(property) BunServer.requestIP?: ((req: Request) => { address: string; family: string; port: number; }) | undefined
Request) => {
(parameter) req: Request
address: string
interface Request
This Fetch API interface represents a resource request.family: string
(property) address: string
port: number
(property) family: string
} upgrade
(property) port: number
<T>(
(method) BunServer.upgrade<T>(req: Request, options?: { data: T; }): boolean
req:
(type parameter) T in BunServer.upgrade<T>(req: Request, options?: { data: T; }): boolean
Request,
(parameter) req: Request
options?: {
interface Request
This Fetch API interface represents a resource request.data:
(parameter) options: { data: T; } | undefined
T
(property) data: T
} ): boolean } /** * Get Bun Server Object from Context * @param c Context * @returns Bun Server */ export const getBunServer =
(type parameter) T in BunServer.upgrade<T>(req: Request, options?: { data: T; }): boolean
const getBunServer: (c: Context) => BunServer | undefined
Get Bun Server Object from Context@param
c
— Context@returns — Bun Server
(c:
(parameter) c: Context<any, any, {}>
Context@param
Context):c
— ContextBunServer | undefined =>
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
('server' in c
interface BunServer
Bun Server Object
(parameter) c: Context<any, any, {}>
Context@param
.env ?c
— Context
(property) Context<any, any, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
c
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
(parameter) c: Context<any, any, {}>
Context@param
.env.server :c
— Context
(property) Context<any, any, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
c
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
(parameter) c: Context<any, any, {}>
Context@param
.env) asc
— Context
(property) Context<any, any, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
BunServer | undefined
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
interface BunServer
Bun Server Object
/* eslint-disable @typescript-eslint/ban-ts-comment */ import { toSSG as baseToSSG } from '../../helper/ssg' import type { FileSystemModule, ToSSGAdaptorInterface } from '../../helper/ssg' // @ts-ignore const { write } = Bun/** * @experimental * `bunFileSystemModule` is an experimental feature. * The API might be changed. */ export const bunFileSystemModule:
const write: any
const bunFileSystemModule: FileSystemModule
@experimental
FileSystemModule = {
bunFileSystemModule
is an experimental feature. The API might be changed.
(alias) interface FileSystemModule import FileSystemModule
@experimental
writeFile: async
FileSystemModule
is an experimental feature. The API might be changed.(path,
(method) FileSystemModule.writeFile(path: string, data: string | Uint8Array): Promise<void>
data) => {
(parameter) path: string
await write
(parameter) data: string | Uint8Array
(path,
const write: any
data)
(parameter) path: string
}, mkdir: async () => {},
(parameter) data: string | Uint8Array
} /** * @experimental * `toSSG` is an experimental feature. * The API might be changed. */ export const toSSG:
(method) FileSystemModule.mkdir(path: string, options: { recursive: boolean; }): Promise<void | string>
const toSSG: ToSSGAdaptorInterface<Env, {}, "/">
@experimental
ToSSGAdaptorInterface = async
toSSG
is an experimental feature. The API might be changed.
(alias) interface ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/"> import ToSSGAdaptorInterface
@experimental
(app,
ToSSGAdaptorInterface
is an experimental feature. The API might be changed.options) => {
(parameter) app: Hono<Env, {}, "/">
return baseToSSG
(parameter) options: ToSSGOptions | undefined
(alias) baseToSSG(app: Hono<any, any, any>, fsModule: FileSystemModule, options?: ToSSGOptions): Promise<ToSSGResult> import baseToSSG
@experimental
(app,
toSSG
is an experimental feature. The API might be changed.bunFileSystemModule,
(parameter) app: Hono<Env, {}, "/">
const bunFileSystemModule: FileSystemModule
@experimental
options)
bunFileSystemModule
is an experimental feature. The API might be changed.}
(parameter) options: ToSSGOptions | undefined
import { createWSMessageEvent } from '../../helper/websocket' import type { UpgradeWebSocket, WSContext, WSEvents, WSMessageReceive, } from '../../helper/websocket' import { getBunServer } from './server' interface BunServerWebSocket<T> {
interface BunServerWebSocket<T>
send
(type parameter) T in BunServerWebSocket<T>
(data: string |
(method) BunServerWebSocket<T>.send(data: string | ArrayBufferLike, compress?: boolean): void
ArrayBufferLike,
(parameter) data: string | ArrayBufferLike
compress?: boolean): void
type ArrayBufferLike = ArrayBuffer | SharedArrayBuffer
close
(parameter) compress: boolean | undefined
(code?: number,
(method) BunServerWebSocket<T>.close(code?: number, reason?: string): void
reason?: string): void
(parameter) code: number | undefined
data:
(parameter) reason: string | undefined
T
(property) BunServerWebSocket<T>.data: T
readyState: 0 | 1 | 2 | 3
(type parameter) T in BunServerWebSocket<T>
} interface BunWebSocketHandler
(property) BunServerWebSocket<T>.readyState: 0 | 2 | 1 | 3
<T> {
interface BunWebSocketHandler<T>
open
(type parameter) T in BunWebSocketHandler<T>
(ws:
(method) BunWebSocketHandler<T>.open(ws: BunServerWebSocket<T>): void
BunServerWebSocket
(parameter) ws: BunServerWebSocket<T>
<T>): void
interface BunServerWebSocket<T>
close
(type parameter) T in BunWebSocketHandler<T>
(ws:
(method) BunWebSocketHandler<T>.close(ws: BunServerWebSocket<T>, code?: number, reason?: string): void
BunServerWebSocket
(parameter) ws: BunServerWebSocket<T>
<T>,
interface BunServerWebSocket<T>
code?: number,
(type parameter) T in BunWebSocketHandler<T>
reason?: string): void
(parameter) code: number | undefined
message
(parameter) reason: string | undefined
(ws:
(method) BunWebSocketHandler<T>.message(ws: BunServerWebSocket<T>, message: string | Uint8Array): void
BunServerWebSocket
(parameter) ws: BunServerWebSocket<T>
<T>,
interface BunServerWebSocket<T>
message: string |
(type parameter) T in BunWebSocketHandler<T>
Uint8Array): void
(parameter) message: string | Uint8Array
} interface CreateWebSocket
interface Uint8Array
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.<T> {
interface CreateWebSocket<T>
upgradeWebSocket:
(type parameter) T in CreateWebSocket<T>
UpgradeWebSocket
(property) CreateWebSocket<T>.upgradeWebSocket: UpgradeWebSocket<T>
<T>
(alias) type UpgradeWebSocket<T = unknown, U = any> = (createEvents: (c: Context) => WSEvents<T> | Promise<WSEvents<T>>, options?: U) => MiddlewareHandler<any, string, { outputFormat: "ws"; }> import UpgradeWebSocket
Upgrade WebSocket Typewebsocket:
(type parameter) T in CreateWebSocket<T>
BunWebSocketHandler
(property) CreateWebSocket<T>.websocket: BunWebSocketHandler<BunWebSocketData>
<BunWebSocketData>
interface BunWebSocketHandler<T>
} export interface BunWebSocketData {
interface BunWebSocketData
connId: number
interface BunWebSocketData
url:
(property) BunWebSocketData.connId: number
URL
(property) BunWebSocketData.url: URL
protocol: string
interface URL
The URL interface represents an object providing static methods used for creating object URLs.} const createWSContext =
(property) BunWebSocketData.protocol: string
(ws:
const createWSContext: (ws: BunServerWebSocket<BunWebSocketData>) => WSContext
BunServerWebSocket
(parameter) ws: BunServerWebSocket<BunWebSocketData>
<BunWebSocketData>):
interface BunServerWebSocket<T>
WSContext => {
interface BunWebSocketData
return { send:
(alias) type WSContext<T = unknown> = { send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void; raw?: T; binaryType: BinaryType; readyState: WSReadyState; url: URL | null; protocol: string | null; close(code?: number, reason?: string): void; } import WSContext
(source,
(method) send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void
options) => {
(parameter) source: string | ArrayBuffer | Uint8Array
const sendingData =
(parameter) options: { compress: boolean; } | undefined
typeof source === 'string' ?
const sendingData: string | ArrayBuffer
source :
(parameter) source: string | ArrayBuffer | Uint8Array
source instanceof
(parameter) source: string
Uint8Array ?
(parameter) source: ArrayBuffer | Uint8Array
source
var Uint8Array: Uint8ArrayConstructor
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised..buffer :
(parameter) source: Uint8Array
source
(property) Uint8Array.buffer: ArrayBufferLike
The ArrayBuffer instance referenced by the array.ws
(parameter) source: ArrayBuffer
.send
(parameter) ws: BunServerWebSocket<BunWebSocketData>
(sendingData,
(method) BunServerWebSocket<BunWebSocketData>.send(data: string | ArrayBufferLike, compress?: boolean): void
options?
const sendingData: string | ArrayBuffer
.compress)
(parameter) options: { compress: boolean; } | undefined
}, raw:
(property) compress: boolean | undefined
ws,
(property) raw?: unknown
binaryType: 'arraybuffer',
(parameter) ws: BunServerWebSocket<BunWebSocketData>
readyState:
(property) binaryType: BinaryType
ws
(property) readyState: WSReadyState
.readyState,
(parameter) ws: BunServerWebSocket<BunWebSocketData>
url:
(property) BunServerWebSocket<T>.readyState: 0 | 2 | 1 | 3
ws
(property) url: URL | null
.data
(parameter) ws: BunServerWebSocket<BunWebSocketData>
.url,
(property) BunServerWebSocket<BunWebSocketData>.data: BunWebSocketData
protocol:
(property) BunWebSocketData.url: URL
ws
(property) protocol: string | null
.data
(parameter) ws: BunServerWebSocket<BunWebSocketData>
.protocol,
(property) BunServerWebSocket<BunWebSocketData>.data: BunWebSocketData
close
(property) BunWebSocketData.protocol: string
(code,
(method) close(code?: number, reason?: string): void
reason) {
(parameter) code: number | undefined
ws
(parameter) reason: string | undefined
.close
(parameter) ws: BunServerWebSocket<BunWebSocketData>
(code,
(method) BunServerWebSocket<BunWebSocketData>.close(code?: number, reason?: string): void
reason)
(parameter) code: number | undefined
}, } } export const createBunWebSocket =
(parameter) reason: string | undefined
<T>():
const createBunWebSocket: <T>() => CreateWebSocket<T>
CreateWebSocket
(type parameter) T in <T>(): CreateWebSocket<T>
<T> => {
interface CreateWebSocket<T>
const websocketConns:
(type parameter) T in <T>(): CreateWebSocket<T>
WSEvents[] = []
const websocketConns: WSEvents<unknown>[]
// eslint-disable-next-line @typescript-eslint/no-explicit-any const upgradeWebSocket:
(alias) interface WSEvents<T = unknown> import WSEvents
WebSocket Event Listeners typeUpgradeWebSocket
const upgradeWebSocket: UpgradeWebSocket<any>
= (createEvents) => {
(alias) type UpgradeWebSocket<T = unknown, U = any> = (createEvents: (c: Context) => WSEvents<T> | Promise<WSEvents<T>>, options?: U) => MiddlewareHandler<any, string, { outputFormat: "ws"; }> import UpgradeWebSocket
Upgrade WebSocket Typereturn async (c,
(parameter) createEvents: (c: Context) => WSEvents<any> | Promise<WSEvents<any>>
next) => {
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
const server =
(parameter) next: Next
getBunServer
const server: BunServer | undefined
(alias) getBunServer(c: Context): BunServer | undefined import getBunServer
Get Bun Server Object from Context@param
c
— Context@returns — Bun Server
(c)if (!server) {
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
throw new TypeError('env has to include the 2nd argument of fetch.')
const server: BunServer | undefined
} const connId =
var TypeError: TypeErrorConstructor new (message?: string, options?: ErrorOptions) => TypeError (+3 overloads)
websocketConns
const connId: number
.push(await
const websocketConns: WSEvents<unknown>[]
(method) Array<WSEvents<unknown>>.push(...items: WSEvents<unknown>[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
createEventsitems
— New elements to add to the array.(c)) - 1
(parameter) createEvents: (c: Context) => WSEvents<any> | Promise<WSEvents<any>>
const upgradeResult =
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
server
const upgradeResult: boolean
.upgrade
const server: BunServer
<BunWebSocketData>
(method) BunServer.upgrade<BunWebSocketData>(req: Request, options?: { data: BunWebSocketData; } | undefined): boolean
(c
interface BunWebSocketData
.req
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
.raw, {
(property) Context<any, string, { outputFormat: "ws"; }>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
data: {
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
connId,
(property) data: BunWebSocketData
url: new
(property) BunWebSocketData.connId: number
URL
(property) BunWebSocketData.url: URL
(c
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs..req
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
.url),
(property) Context<any, string, { outputFormat: "ws"; }>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<string, unknown>.url: string
.url()
can get the request url strings.@see — https://hono.dev/docs/api/request#url
@example
protocol:
ts app.get('/about/me', (c) => { const url = c.req.url // `http://localhost:8787/about/me` ... })
c
(property) BunWebSocketData.protocol: string
.req
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
.url,
(property) Context<any, string, { outputFormat: "ws"; }>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<string, unknown>.url: string
.url()
can get the request url strings.@see — https://hono.dev/docs/api/request#url
@example
}, }) if (upgradeResult) {
ts app.get('/about/me', (c) => { const url = c.req.url // `http://localhost:8787/about/me` ... })
return new Response(null)
const upgradeResult: boolean
} await next() // Failed
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.} } const websocket:
(parameter) next: () => Promise<void>
BunWebSocketHandler
const websocket: BunWebSocketHandler<BunWebSocketData>
<BunWebSocketData> = {
interface BunWebSocketHandler<T>
open
interface BunWebSocketData
(ws) {
(method) BunWebSocketHandler<BunWebSocketData>.open(ws: BunServerWebSocket<BunWebSocketData>): void
const websocketListeners =
(parameter) ws: BunServerWebSocket<BunWebSocketData>
websocketConns
const websocketListeners: WSEvents<unknown>
[ws
const websocketConns: WSEvents<unknown>[]
.data
(parameter) ws: BunServerWebSocket<BunWebSocketData>
.connId]
(property) BunServerWebSocket<BunWebSocketData>.data: BunWebSocketData
if (websocketListeners
(property) BunWebSocketData.connId: number
.onOpen) {
const websocketListeners: WSEvents<unknown>
websocketListeners
(property) WSEvents<unknown>.onOpen?: ((evt: Event, ws: WSContext<unknown>) => void) | undefined
.onOpen(new
const websocketListeners: WSEvents<unknown>
Event('open'),
(property) WSEvents<unknown>.onOpen?: (evt: Event, ws: WSContext<unknown>) => void
createWSContext
var Event: new (type: string, eventInitDict?: EventInit) => Event
An event which takes place in the DOM.(ws))
const createWSContext: (ws: BunServerWebSocket<BunWebSocketData>) => WSContext
} }, close
(parameter) ws: BunServerWebSocket<BunWebSocketData>
(ws,
(method) BunWebSocketHandler<BunWebSocketData>.close(ws: BunServerWebSocket<BunWebSocketData>, code?: number, reason?: string): void
code,
(parameter) ws: BunServerWebSocket<BunWebSocketData>
reason) {
(parameter) code: number | undefined
const websocketListeners =
(parameter) reason: string | undefined
websocketConns
const websocketListeners: WSEvents<unknown>
[ws
const websocketConns: WSEvents<unknown>[]
.data
(parameter) ws: BunServerWebSocket<BunWebSocketData>
.connId]
(property) BunServerWebSocket<BunWebSocketData>.data: BunWebSocketData
if (websocketListeners
(property) BunWebSocketData.connId: number
.onClose) {
const websocketListeners: WSEvents<unknown>
websocketListeners
(property) WSEvents<unknown>.onClose?: ((evt: CloseEvent, ws: WSContext<unknown>) => void) | undefined
.onClose(
const websocketListeners: WSEvents<unknown>
new CloseEvent('close', {
(property) WSEvents<unknown>.onClose?: (evt: CloseEvent, ws: WSContext<unknown>) => void
code,
var CloseEvent: new (type: string, eventInitDict?: CloseEventInit) => CloseEvent
A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute.reason,
(property) CloseEventInit.code?: number | undefined
}), createWSContext
(property) CloseEventInit.reason?: string | undefined
(ws)
const createWSContext: (ws: BunServerWebSocket<BunWebSocketData>) => WSContext
) } }, message
(parameter) ws: BunServerWebSocket<BunWebSocketData>
(ws,
(method) BunWebSocketHandler<BunWebSocketData>.message(ws: BunServerWebSocket<BunWebSocketData>, message: string | Uint8Array): void
message) {
(parameter) ws: BunServerWebSocket<BunWebSocketData>
const websocketListeners =
(parameter) message: string | Uint8Array
websocketConns
const websocketListeners: WSEvents<unknown>
[ws
const websocketConns: WSEvents<unknown>[]
.data
(parameter) ws: BunServerWebSocket<BunWebSocketData>
.connId]
(property) BunServerWebSocket<BunWebSocketData>.data: BunWebSocketData
if (websocketListeners
(property) BunWebSocketData.connId: number
.onMessage) {
const websocketListeners: WSEvents<unknown>
const normalizedReceiveData =
(property) WSEvents<unknown>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<unknown>) => void) | undefined
typeof message === 'string' ?
const normalizedReceiveData: string | ArrayBuffer
message :
(parameter) message: string | Uint8Array
(message
(parameter) message: string
.buffer satisfies
(parameter) message: Uint8Array
WSMessageReceive)
(property) Uint8Array.buffer: ArrayBufferLike
The ArrayBuffer instance referenced by the array.websocketListeners
(alias) type WSMessageReceive = string | Blob | ArrayBufferLike import WSMessageReceive
.onMessage(
const websocketListeners: WSEvents<unknown>
createWSMessageEvent
(property) WSEvents<unknown>.onMessage?: (evt: MessageEvent<WSMessageReceive>, ws: WSContext<unknown>) => void
(normalizedReceiveData),
(alias) createWSMessageEvent(source: WSMessageReceive): MessageEvent<WSMessageReceive> import createWSMessageEvent
createWSContext
const normalizedReceiveData: string | ArrayBuffer
(ws)
const createWSContext: (ws: BunServerWebSocket<BunWebSocketData>) => WSContext
) } }, } return { upgradeWebSocket,
(parameter) ws: BunServerWebSocket<BunWebSocketData>
websocket,
(property) CreateWebSocket<T>.upgradeWebSocket: UpgradeWebSocket<T>
} }
(property) CreateWebSocket<T>.websocket: BunWebSocketHandler<BunWebSocketData>
import { getCookie } from '../../helper/cookie' import { Hono } from '../../hono' import { HTTPException } from '../../http-exception' import type { EventContext } from './handler' import { handle, handleMiddleware, serveStatic } from './handler' type Env = {Bindings: {
type Env = { Bindings: { TOKEN: string; }; }
TOKEN: string
(property) Bindings: { TOKEN: string; }
} } function createEventContext(
(property) TOKEN: string
context:
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
Partial
(parameter) context: Partial<EventContext<{ TOKEN: string; }>>
<EventContext
type Partial<T> = { [P in keyof T]?: T[P] | undefined; }
Make all properties in T optional<Env['Bindings']>>
(alias) type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>> = { request: Request; functionPath: string; waitUntil: (promise: Promise<unknown>) => void; passThroughOnException: () => void; next: (input?: Request | string, init?: RequestInit) => Promise<Response>; env: Env & { ASSETS: { fetch: typeof fetch; }; }; params: Params<...>; data: Data; } import EventContext
): EventContext
type Env = { Bindings: { TOKEN: string; }; }
<Env['Bindings']> {
(alias) type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>> = { request: Request; functionPath: string; waitUntil: (promise: Promise<unknown>) => void; passThroughOnException: () => void; next: (input?: Request | string, init?: RequestInit) => Promise<Response>; env: Env & { ASSETS: { fetch: typeof fetch; }; }; params: Params<...>; data: Data; } import EventContext
return { data: {},
type Env = { Bindings: { TOKEN: string; }; }
env: {
(property) data: Record<string, unknown>
...context
(property) env: { TOKEN: string; } & { ASSETS: { fetch: typeof fetch; }; }
.env,
(parameter) context: Partial<EventContext<{ TOKEN: string; }>>
ASSETS: {
(property) env?: ({ TOKEN: string; } & { ASSETS: { fetch: typeof fetch; }; }) | undefined
fetch: vi.fn(), ..
(property) ASSETS: { fetch: typeof fetch; }
.context
(property) fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
.env?
(parameter) context: Partial<EventContext<{ TOKEN: string; }>>
.ASSETS },
(property) env?: ({ TOKEN: string; } & { ASSETS: { fetch: typeof fetch; }; }) | undefined
TOKEN:
(property) ASSETS: { fetch: typeof fetch; } | undefined
context
(property) TOKEN: string
.env?
(parameter) context: Partial<EventContext<{ TOKEN: string; }>>
.TOKEN ?? 'HONOISCOOL',
(property) env?: ({ TOKEN: string; } & { ASSETS: { fetch: typeof fetch; }; }) | undefined
}, functionPath: '_worker.js',
(property) TOKEN: string | undefined
next: vi.fn(),
(property) functionPath: string
params: {},
(property) next: (input?: Request | string, init?: RequestInit) => Promise<Response>
passThroughOnException: vi.fn(),
(property) params: Params<any>
request: new
(property) passThroughOnException: () => void
Request('http://localhost/api/foo'),
(property) request: Request
waitUntil: vi.fn(),
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request....context,
(property) waitUntil: (promise: Promise<unknown>) => void
} } describe('Adapter for Cloudflare Pages', () => { it('Should return 200 response', async () => { const request = new
(parameter) context: Partial<EventContext<{ TOKEN: string; }>>
Request('http://localhost/api/foo')
const request: Request
const env = {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.ASSETS: {
const env: { ASSETS: { fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>; }; TOKEN: string; }
fetch },
(property) ASSETS: { fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>; }
TOKEN: 'HONOISCOOL',
(property) fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
} const waitUntil = vi.fn()
(property) TOKEN: string
const passThroughOnException = vi.fn()
const waitUntil: any
const eventContext =
const passThroughOnException: any
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
env,
(property) request?: Request | undefined
waitUntil,
(property) env?: ({ TOKEN: string; } & { ASSETS: { fetch: typeof fetch; }; }) | undefined
passThroughOnException,
(property) waitUntil?: ((promise: Promise<unknown>) => void) | undefined
}) const app = new
(property) passThroughOnException?: (() => void) | undefined
Hono
const app: Hono<Env, BlankSchema, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance.const appFetchSpy = vi.spyOn
type Env = { Bindings: { TOKEN: string; }; }
(app, 'fetch')
const appFetchSpy: any
app
const app: Hono<Env, BlankSchema, "/">
.get('/api/foo',
const app: Hono<Env, BlankSchema, "/">
(c) => {
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/api/foo", "/api/foo", JSONRespondReturn<{ TOKEN: string; requestURL: string; }, StatusCode>, BlankInput, Env>(path: "/api/foo", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<Env, "/api/foo", BlankInput>
.json({
(parameter) c: Context<Env, "/api/foo", BlankInput>
TOKEN:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ TOKEN: string; requestURL: string; }, StatusCode>(object: { TOKEN: string; requestURL: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
c
(property) TOKEN: string
.env
(parameter) c: Context<Env, "/api/foo", BlankInput>
(property) Context<Env, "/api/foo", BlankInput>.env: { TOKEN: string; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
.TOKEN,
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
requestURL:
(property) TOKEN: string
c
(property) requestURL: string
.req
(parameter) c: Context<Env, "/api/foo", BlankInput>
.url })
(property) Context<Env, "/api/foo", BlankInput>.req: HonoRequest<"/api/foo", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.url: string
.url()
can get the request url strings.@see — https://hono.dev/docs/api/request#url
@example
}) const handler =
ts app.get('/about/me', (c) => { const url = c.req.url // `http://localhost:8787/about/me` ... })
handle
const handler: PagesFunction<{ TOKEN: string; }, any, Record<string, unknown>>
(app)
(alias) handle<Env, BlankSchema, "/">(app: Hono<Env, BlankSchema, "/">): PagesFunction<{ TOKEN: string; }, any, Record<string, unknown>> import handle
const res = await
const app: Hono<Env, BlankSchema, "/">
handler
const res: Response
(eventContext)
const handler: (context: EventContext<{ TOKEN: string; }, any, Record<string, unknown>>) => Response | Promise<Response>
expect(appFetchSpy).toHaveBeenCalledWith(
const eventContext: EventContext<{ TOKEN: string; }>
request,
const appFetchSpy: any
{ ...env,
const request: Request
eventContext },
const env: { ASSETS: { fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>; }; TOKEN: string; }
{ waitUntil,
(property) eventContext: EventContext<{ TOKEN: string; }>
passThroughOnException }
(property) waitUntil: any
) expect(res
(property) passThroughOnException: any
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
TOKEN: 'HONOISCOOL',
(method) Body.json(): Promise<any>
MDN ReferencerequestURL: 'http://localhost/api/foo',
(property) TOKEN: string
}) }) it('Should not use `basePath()` if path argument is not passed', async () => { const request = new
(property) requestURL: string
Request('http://localhost/api/error')
const request: Request
const eventContext =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request })
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
const app = new
(property) request?: Request | undefined
Hono()
const app: Hono<BlankEnv, BlankSchema, "/api">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.basePath('/api')options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/api">(path: "/api"): Hono<BlankEnv, BlankSchema, "/api">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
app
ts const api = new Hono().basePath('/api')
.onError(
const app: Hono<BlankEnv, BlankSchema, "/api">
(property) Hono<BlankEnv, BlankSchema, "/api">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/api">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(e) => {
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
throw e
(parameter) e: Error | HTTPResponseError
}) app
(parameter) e: Error | HTTPResponseError
.get('/error', () => {
const app: Hono<BlankEnv, BlankSchema, "/api">
throw new Error('Custom Error')
(property) Hono<BlankEnv, BlankSchema, "/api">.get: HandlerInterface <"/error", "/api/error", never, BlankInput, BlankEnv>(path: "/error", handler: H<BlankEnv, "/api/error", BlankInput, never>) => Hono<...> (+22 overloads)
}) const handler =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
handle
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(app)
(alias) handle<BlankEnv, BlankSchema, "" | "/api">(app: Hono<BlankEnv, BlankSchema, "" | "/api">): PagesFunction<unknown, any, Record<string, unknown>> import handle
// It does throw the error if app is NOT "subApp" expect(() => handler
const app: Hono<BlankEnv, BlankSchema, "/api">
(eventContext)).toThrowError('Custom Error')
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
}) }) describe('Middleware adapter for Cloudflare Pages', () => { it('Should return the middleware response', async () => { const request = new
const eventContext: EventContext<{ TOKEN: string; }>
Request('http://localhost/api/foo', {
const request: Request
headers: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Cookie: 'my_cookie=1234',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) const next = vi.fn().mockResolvedValue
(property) Cookie: string
(Response
const next: any
.json('From Cloudflare Pages'))
var Response: { new (body?: BodyInit | null, init?: ResponseInit): Response; prototype: Response; error(): Response; json(data: any, init?: ResponseInit): Response; redirect(url: string | URL, status?: number): Response; }
This Fetch API interface represents the response to a request.const eventContext =
(method) json(data: any, init?: ResponseInit): Response
MDN ReferencecreateEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
const handler =
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
handleMiddleware(async
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(c,
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
next) => {
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
const cookie =
(parameter) next: Next
getCookie
const cookie: string | undefined
(c, 'my_cookie')
(alias) getCookie(c: Context, key: string): string | undefined (+2 overloads) import getCookie
await next()
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
return c
(parameter) next: () => Promise<void>
.json({
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
cookie,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ cookie: string | undefined; response: any; }, StatusCode>(object: { cookie: string | undefined; response: any; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
response: await
(property) cookie: string | undefined
c
(property) response: any
.res
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
(property) Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.json() })_res
— The Response object to set.}) const res = await
(method) Body.json(): Promise<any>
MDN Referencehandler
const res: Response
(eventContext)
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
expect(await res
const next: any
.json()).toEqual({
const res: Response
cookie: '1234',
(method) Body.json(): Promise<any>
MDN Referenceresponse: 'From Cloudflare Pages',
(property) cookie: string
}) }) it('Should return the middleware response when exceptions are handled', async () => { const request = new
(property) response: string
Request('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(async
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(c,
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
next) => {
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
await next()
(parameter) next: Next
return c
(parameter) next: () => Promise<void>
.json({
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
error:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ error: string | undefined; }, StatusCode>(object: { error: string | undefined; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
c
(property) error: string | undefined
.error?
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
.message })
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
}) const next = vi.fn().mockRejectedValue(new
(property) Error.message: string | undefined
Error('Error from next()'))
const next: any
const eventContext =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
const res = await
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
handler
const res: Response
(eventContext)
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
expect(await res
const next: any
.json()).toEqual({
const res: Response
error: 'Error from next()',
(method) Body.json(): Promise<any>
MDN Reference}) }) it('Should return the middleware response if next() is not called', async () => { const request = new
(property) error: string
Request('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(async
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(c) => {
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
return c
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
.json({
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
response: 'Skip Cloudflare Pages' })
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ response: string; }, StatusCode>(object: { response: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
}) const next = vi.fn()
(property) response: string
const eventContext =
const next: any
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
const res = await
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
handler
const res: Response
(eventContext)
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).not.toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
expect(await res
const next: any
.json()).toEqual({
const res: Response
response: 'Skip Cloudflare Pages',
(method) Body.json(): Promise<any>
MDN Reference}) }) it('Should return the Pages response if the middleware does not return a response', async () => { const request = new
(property) response: string
Request('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(c,
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
next) =>
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
next())
(parameter) next: Next
const next = vi.fn().mockResolvedValue
(parameter) next: () => Promise<void>
(Response
const next: any
.json('From Cloudflare Pages'))
var Response: { new (body?: BodyInit | null, init?: ResponseInit): Response; prototype: Response; error(): Response; json(data: any, init?: ResponseInit): Response; redirect(url: string | URL, status?: number): Response; }
This Fetch API interface represents the response to a request.const eventContext =
(method) json(data: any, init?: ResponseInit): Response
MDN ReferencecreateEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
const res = await
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
handler
const res: Response
(eventContext)
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
expect(await res
const next: any
.json()).toEqual('From Cloudflare Pages')
const res: Response
}) it('Should handle a HTTPException by returning error.getResponse()', async () => { const request = new
(method) Body.json(): Promise<any>
MDN ReferenceRequest('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(() => {
const handler: PagesFunction<unknown, any, Record<string, unknown>>
const res = new
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
Response('Unauthorized', {
const res: Response
status: 401 })
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.throw new HTTPException(401, {
(property) ResponseInit.status?: number | undefined
(alias) new HTTPException(status?: StatusCode, options?: HTTPExceptionOptions): HTTPException import HTTPException
Creates an instance ofHTTPException
.@param
status
— HTTP status code for the exception. Defaults to 500.@param
res })options
— Additional options for the exception.}) const next = vi.fn()
(property) res?: Response | undefined
const eventContext =
const next: any
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
const res = await
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
handler
const res: Response
(eventContext)
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).not.toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
expect(res
const next: any
.status).toBe(401)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Unauthorized')
const res: Response
}) it('Should handle an HTTPException thrown by next()', async () => { const request = new
(method) Body.text(): Promise<string>
MDN ReferenceRequest('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(c,
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
next) =>
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
next())
(parameter) next: Next
const next = vi
(parameter) next: () => Promise<void>
.fn() .mockRejectedValue(new HTTPException(401, {
const next: any
(alias) new HTTPException(status?: StatusCode, options?: HTTPExceptionOptions): HTTPException import HTTPException
Creates an instance ofHTTPException
.@param
status
— HTTP status code for the exception. Defaults to 500.@param
res:options
— Additional options for the exception.Response
(property) res?: Response | undefined
.json('Unauthorized') }))
var Response: { new (body?: BodyInit | null, init?: ResponseInit): Response; prototype: Response; error(): Response; json(data: any, init?: ResponseInit): Response; redirect(url: string | URL, status?: number): Response; }
This Fetch API interface represents the response to a request.const eventContext =
(method) json(data: any, init?: ResponseInit): Response
MDN ReferencecreateEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
const res = await
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
handler
const res: Response
(eventContext)
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
expect(await res
const next: any
.json()).toEqual('Unauthorized')
const res: Response
}) it('Should handle an Error thrown by next()', async () => { const request = new
(method) Body.json(): Promise<any>
MDN ReferenceRequest('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(c,
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
next) =>
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
next())
(parameter) next: Next
const next = vi.fn().mockRejectedValue(new
(parameter) next: () => Promise<void>
Error('Error from next()'))
const next: any
const eventContext =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
await expect(handler
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
(eventContext)).rejects.toThrowError('Error from next()')
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
}) it('Should handle a non-Error thrown by next()', async () => { const request = new
const next: any
Request('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(c,
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
next) =>
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
next())
(parameter) next: Next
const next = vi.fn().mockRejectedValue('Error from next()')
(parameter) next: () => Promise<void>
const eventContext =
const next: any
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
await expect(handler
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
(eventContext)).rejects.toThrowError('Error from next()')
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
}) it('Should rethrow an Error', async () => { const request = new
const next: any
Request('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(() => {
const handler: PagesFunction<unknown, any, Record<string, unknown>>
throw new Error('Something went wrong')
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
}) const next = vi.fn()
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
const eventContext =
const next: any
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
await expect(handler
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
(eventContext)).rejects.toThrowError('Something went wrong')
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).not.toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
}) it('Should rethrow non-Error exceptions', async () => { const request = new
const next: any
Request('http://localhost/api/foo')
const request: Request
const handler =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handleMiddleware(() =>
const handler: PagesFunction<unknown, any, Record<string, unknown>>
Promise
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
.reject('Something went wrong'))
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
(method) PromiseConstructor.reject<void | Response>(reason?: any): Promise<void | Response>
Creates a new rejected promise for the provided reason.@param
reason
— The reason the promise was rejected.@returns — A new rejected Promise.
const next = vi.fn()const eventContext =
const next: any
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
next })
(property) request?: Request | undefined
await expect(handler
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
(eventContext)).rejects.toThrowError('Something went wrong')
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(next).not.toHaveBeenCalled()
const eventContext: EventContext<{ TOKEN: string; }>
}) it('Should set the data in eventContext.data', async () => { const next = vi.fn()
const next: any
const eventContext =
const next: any
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
next })
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
const handler =
(property) next?: ((input?: Request | string, init?: RequestInit) => Promise<Response>) | undefined
handleMiddleware(async
const handler: PagesFunction<unknown, any, Record<string, unknown>>
(c,
(alias) handleMiddleware<{}, any, {}>(middleware: MiddlewareHandler<{ Bindings: { eventContext: EventContext; }; }, any, {}>): PagesFunction<unknown, any, Record<string, unknown>> import handleMiddleware
next) => {
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
c
(parameter) next: Next
.env
(parameter) c: Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>
(property) Context<{ Bindings: { eventContext: EventContext; }; }, any, {}>.env: { eventContext: EventContext; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
.eventContext
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
.data.user = 'Joe'
(property) eventContext: EventContext<{}, any, Record<string, unknown>>
await next()
(property) data: Record<string, unknown>
}) expect(eventContext
(parameter) next: () => Promise<void>
.data.user).toBeUndefined()
const eventContext: EventContext<{ TOKEN: string; }>
await handler
(property) data: Record<string, unknown>
(eventContext)
const handler: (context: EventContext<unknown, any, Record<string, unknown>>) => Response | Promise<Response>
expect(eventContext
const eventContext: EventContext<{ TOKEN: string; }>
.data.user).toBe('Joe')
const eventContext: EventContext<{ TOKEN: string; }>
}) }) describe('serveStatic()', () => { it('Should pass the raw request to ASSETS.fetch', async () => { const assetsFetch = vi.fn().mockResolvedValue(new
(property) data: Record<string, unknown>
Response('foo.png'))
const assetsFetch: any
const request = new
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.Request('http://localhost/foo.png')
const request: Request
const env = {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.ASSETS: {
const env: { ASSETS: { fetch: any; }; TOKEN: string; }
fetch:
(property) ASSETS: { fetch: any; }
assetsFetch },
(property) fetch: any
TOKEN: 'HONOISCOOL',
const assetsFetch: any
} const eventContext =
(property) TOKEN: string
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
env })
(property) request?: Request | undefined
const app = new
(property) env?: ({ TOKEN: string; } & { ASSETS: { fetch: typeof fetch; }; }) | undefined
Hono
const app: Hono<Env, BlankSchema, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance.app
type Env = { Bindings: { TOKEN: string; }; }
.use
const app: Hono<Env, BlankSchema, "/">
(serveStatic())
(property) Hono<Env, BlankSchema, "/">.use: MiddlewareHandlerInterface <any>(...handlers: MiddlewareHandler<any, never, {}>[]) => Hono<Env, BlankSchema, "/"> (+20 overloads)
(alias) serveStatic(): MiddlewareHandler import serveStatic
@description
const handler =
serveStatic()
is for advanced mode: https://developers.cloudflare.com/pages/platform/functions/advanced-mode/#set-up-a-functionhandle
const handler: PagesFunction<{ TOKEN: string; }, any, Record<string, unknown>>
(app)
(alias) handle<Env, BlankSchema, "/">(app: Hono<Env, BlankSchema, "/">): PagesFunction<{ TOKEN: string; }, any, Record<string, unknown>> import handle
const res = await
const app: Hono<Env, BlankSchema, "/">
handler
const res: Response
(eventContext)
const handler: (context: EventContext<{ TOKEN: string; }, any, Record<string, unknown>>) => Response | Promise<Response>
expect(assetsFetch).toHaveBeenCalledWith
const eventContext: EventContext<{ TOKEN: string; }>
(request)
const assetsFetch: any
expect(res
const request: Request
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('foo.png')
const res: Response
}) it('Should respond with 404 if ASSETS.fetch returns a 404 response', async () => { const assetsFetch = vi.fn().mockResolvedValue(new
(method) Body.text(): Promise<string>
MDN ReferenceResponse(null, {
const assetsFetch: any
status: 404 }))
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.const request = new
(property) ResponseInit.status?: number | undefined
Request('http://localhost/foo.png')
const request: Request
const env = {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.ASSETS: {
const env: { ASSETS: { fetch: any; }; TOKEN: string; }
fetch:
(property) ASSETS: { fetch: any; }
assetsFetch },
(property) fetch: any
TOKEN: 'HONOISCOOL',
const assetsFetch: any
} const eventContext =
(property) TOKEN: string
createEventContext({
const eventContext: EventContext<{ TOKEN: string; }>
request,
function createEventContext(context: Partial<EventContext<Env["Bindings"]>>): EventContext<Env["Bindings"]>
env })
(property) request?: Request | undefined
const app = new
(property) env?: ({ TOKEN: string; } & { ASSETS: { fetch: typeof fetch; }; }) | undefined
Hono
const app: Hono<Env, BlankSchema, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance.app
type Env = { Bindings: { TOKEN: string; }; }
.use
const app: Hono<Env, BlankSchema, "/">
(serveStatic())
(property) Hono<Env, BlankSchema, "/">.use: MiddlewareHandlerInterface <any>(...handlers: MiddlewareHandler<any, never, {}>[]) => Hono<Env, BlankSchema, "/"> (+20 overloads)
(alias) serveStatic(): MiddlewareHandler import serveStatic
@description
const handler =
serveStatic()
is for advanced mode: https://developers.cloudflare.com/pages/platform/functions/advanced-mode/#set-up-a-functionhandle
const handler: PagesFunction<{ TOKEN: string; }, any, Record<string, unknown>>
(app)
(alias) handle<Env, BlankSchema, "/">(app: Hono<Env, BlankSchema, "/">): PagesFunction<{ TOKEN: string; }, any, Record<string, unknown>> import handle
const res = await
const app: Hono<Env, BlankSchema, "/">
handler
const res: Response
(eventContext)
const handler: (context: EventContext<{ TOKEN: string; }, any, Record<string, unknown>>) => Response | Promise<Response>
expect(assetsFetch).toHaveBeenCalledWith
const eventContext: EventContext<{ TOKEN: string; }>
(request)
const assetsFetch: any
expect(res
const request: Request
.status).toBe(404)
const res: Response
}) })
(property) Response.status: number
MDN Reference
import { Context } from '../../context' import type { Hono } from '../../hono' import { HTTPException } from '../../http-exception' import type { BlankSchema, Env, Input, MiddlewareHandler, Schema } from '../../types' // Ref: https://github.com/cloudflare/workerd/blob/main/types/defines/pages.d.ts // eslint-disable-next-line @typescript-eslint/no-explicit-any type Params<P extends string = any> =
type Params<P extends string = any> = { [P in P]: string | string[]; }
Record
(type parameter) P in type Params<P extends string = any>
<P, string | string[]>
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T// eslint-disable-next-line @typescript-eslint/no-explicit-any export type EventContext
(type parameter) P in type Params<P extends string = any>
<Env = {},
type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>> = { request: Request; functionPath: string; waitUntil: (promise: Promise<unknown>) => void; passThroughOnException: () => void; next: (input?: Request | string, init?: RequestInit) => Promise<Response>; env: Env & { ASSETS: { fetch: typeof fetch; }; }; params: Params<P>; data: Data; }
P extends string = any,
(type parameter) Env in type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>>
Data =
(type parameter) P in type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>>
Record
(type parameter) Data in type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>>
> = { request:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TRequest
(property) request: Request
functionPath: string
interface Request
This Fetch API interface represents a resource request.waitUntil:
(property) functionPath: string
(promise:
(property) waitUntil: (promise: Promise<unknown>) => void
Promise
(parameter) promise: Promise<unknown>
) => void passThroughOnException: () => void
interface Promise<T>
Represents the completion of an asynchronous operationnext:
(property) passThroughOnException: () => void
(input?:
(property) next: (input?: Request | string, init?: RequestInit) => Promise<Response>
Request | string,
(parameter) input: string | Request | undefined
init?:
interface Request
This Fetch API interface represents a resource request.RequestInit) =>
(parameter) init: RequestInit | undefined
Promise
interface RequestInit
<Response>
interface Promise<T>
Represents the completion of an asynchronous operationenv:
interface Response
This Fetch API interface represents the response to a request.Env & {
(property) env: Env & { ASSETS: { fetch: typeof fetch; }; }
ASSETS: {
(type parameter) Env in type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>>
fetch: typeof
(property) ASSETS: { fetch: typeof fetch; }
fetch } }
(property) fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
params:
function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
MDN ReferenceParams
(property) params: Params<P>
<P>
type Params<P extends string = any> = { [P in P]: string | string[]; }
data:
(type parameter) P in type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>>
Data
(property) data: Data = Record<string, unknown>
} declare type PagesFunction<
(type parameter) Data in type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>>
Env = unknown,
type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>
// eslint-disable-next-line @typescript-eslint/no-explicit-any Params extends string = any,
(type parameter) Env in type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>>
Data extends
(type parameter) Params in type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>>
Record
(type parameter) Data in type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>>
= Record
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T> = (context:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TEventContext
(parameter) context: EventContext<Env, Params, Data>
<Env,
type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>> = { request: Request; functionPath: string; waitUntil: (promise: Promise<unknown>) => void; passThroughOnException: () => void; next: (input?: Request | string, init?: RequestInit) => Promise<Response>; env: Env & { ASSETS: { fetch: typeof fetch; }; }; params: Params<P>; data: Data; }
Params,
(type parameter) Env in type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>>
Data>) =>
(type parameter) Params in type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>>
Response |
(type parameter) Data in type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>>
Promise
interface Response
This Fetch API interface represents the response to a request.<Response>
interface Promise<T>
Represents the completion of an asynchronous operationexport const handle =
interface Response
This Fetch API interface represents the response to a request.<E extends
const handle: <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => PagesFunction<E["Bindings"]>
Env =
(type parameter) E in <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>): PagesFunction<E["Bindings"]>
Env,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
S extends
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Schema =
(type parameter) S in <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>): PagesFunction<E["Bindings"]>
BlankSchema,
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
BasePath extends string = '/'>(
(alias) type BlankSchema = {} import BlankSchema
app:
(type parameter) BasePath in <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>): PagesFunction<E["Bindings"]>
Hono
(parameter) app: Hono<E, S, BasePath>
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E,BasePath
— The base path type.S,
(type parameter) E in <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>): PagesFunction<E["Bindings"]>
BasePath>
(type parameter) S in <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>): PagesFunction<E["Bindings"]>
): PagesFunction
(type parameter) BasePath in <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>): PagesFunction<E["Bindings"]>
<E['Bindings']> =>
type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>
(eventContext) => {
(type parameter) E in <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>): PagesFunction<E["Bindings"]>
return app
(parameter) eventContext: EventContext<E["Bindings"], any, Record<string, unknown>>
.fetch(
(parameter) app: Hono<E, S, BasePath>
(property) Hono<E, S, BasePath>.fetch: (request: Request, Env?: {} | E["Bindings"] | undefined, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
eventContext.request,
(parameter) eventContext: EventContext<E["Bindings"], any, Record<string, unknown>>
{ ...eventContext
(property) request: Request
.env,
(parameter) eventContext: EventContext<E["Bindings"], any, Record<string, unknown>>
eventContext },
(property) env: E["Bindings"] & { ASSETS: { fetch: typeof fetch; }; }
{ waitUntil:
(property) eventContext: EventContext<E["Bindings"], any, Record<string, unknown>>
(method) ExecutionContext.waitUntil(promise: Promise<unknown>): void
Extends the lifetime of the event callback until the promise is settled.@param
eventContextpromise
— A promise to wait for..waitUntil,
(parameter) eventContext: EventContext<E["Bindings"], any, Record<string, unknown>>
passThroughOnException:
(property) waitUntil: (promise: Promise<unknown>) => void
eventContext
(method) ExecutionContext.passThroughOnException(): void
Allows the event to be passed through to subsequent event listeners..passThroughOnException,
(parameter) eventContext: EventContext<E["Bindings"], any, Record<string, unknown>>
} ) } // eslint-disable-next-line @typescript-eslint/no-explicit-any export function handleMiddleware
(property) passThroughOnException: () => void
<E extends
function handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<E["Bindings"]>
Env = {},
(type parameter) E in handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<E["Bindings"]>
P extends string = any,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
I extends
(type parameter) P in handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<E["Bindings"]>
Input = {}>(
(type parameter) I in handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<E["Bindings"]>
middleware:
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
MiddlewareHandler<
(parameter) middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>
E & {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
Bindings: {
(type parameter) E in handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<E["Bindings"]>
eventContext:
(property) Bindings: { eventContext: EventContext; }
EventContext
(property) eventContext: EventContext<{}, any, Record<string, unknown>>
} }, P,
type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>> = { request: Request; functionPath: string; waitUntil: (promise: Promise<unknown>) => void; passThroughOnException: () => void; next: (input?: Request | string, init?: RequestInit) => Promise<Response>; env: Env & { ASSETS: { fetch: typeof fetch; }; }; params: Params<P>; data: Data; }
I
(type parameter) P in handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<E["Bindings"]>
> ): PagesFunction
(type parameter) I in handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<E["Bindings"]>
<E['Bindings']> {
type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>
return async (executionCtx) => {
(type parameter) E in handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<E["Bindings"]>
const context = new
(parameter) executionCtx: EventContext<E["Bindings"], any, Record<string, unknown>>
Context
const context: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(executionCtxoptions
— Optional configuration options for the context..request, {
(parameter) executionCtx: EventContext<E["Bindings"], any, Record<string, unknown>>
env: { ..
(property) request: Request
.executionCtx
(property) env: any
Bindings for the environment..env,
(parameter) executionCtx: EventContext<E["Bindings"], any, Record<string, unknown>>
eventContext:
(property) env: object & { ASSETS: { fetch: typeof fetch; }; }
executionCtx },
(property) eventContext: EventContext<E["Bindings"], any, Record<string, unknown>>
executionCtx,
(parameter) executionCtx: EventContext<E["Bindings"], any, Record<string, unknown>>
}) let response:
(property) executionCtx?: FetchEventLike | ExecutionContext | undefined
Execution context for the request.Response | void = undefined
let response: void | Response
try { response = await
interface Response
This Fetch API interface represents the response to a request.middleware
let response: void | Response
(context, async () => {
(parameter) middleware: (c: Context<E & { Bindings: { eventContext: EventContext; }; }, P, I>, next: Next) => Promise<Response | void>
try { context
const context: Context<any, any, {}>
.res = await
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
executionCtx_res
— The Response object to set..next()
(parameter) executionCtx: EventContext<E["Bindings"], any, Record<string, unknown>>
} catch (error) {
(property) next: (input?: Request | string, init?: RequestInit) => Promise<Response>
if (error instanceof
(local var) error: unknown
Error) {
(local var) error: unknown
context
var Error: ErrorConstructor
.error =
const context: Context<any, any, {}>
(property) Context<any, any, {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
error
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
} else { throw error
(local var) error: Error
} } }) } catch (error) {
(local var) error: unknown
if (error instanceof
(local var) error: unknown
Error) {
(local var) error: unknown
context
var Error: ErrorConstructor
.error =
const context: Context<any, any, {}>
(property) Context<any, any, {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
error
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
} else { throw error
(local var) error: Error
} } if (response) {
(local var) error: unknown
return response
let response: void | Response
} if (context
let response: Response
.error instanceof
const context: Context<any, any, {}>
(property) Context<any, any, {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
HTTPException) {
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
(alias) class HTTPException import HTTPException
HTTPException
must be used when a fatal error such as authentication failure occurs.@see — https://hono.dev/docs/api/exception
@param
status
— status code of HTTPException@param
options
— options of HTTPException@param
options.res
— response of options of HTTPException@param
options.message
— message of options of HTTPException@param
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() }) ```
return context.error
const context: Context<any, any, {}>
(property) Context<any, any, {}>.error: HTTPException
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
.getResponse()
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
(method) HTTPException.getResponse(): Response
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.
} if (context.error) {
const context: Context<any, any, {}>
(property) Context<any, any, {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
throw context
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
.error
const context: Context<any, any, {}>
(property) Context<any, any, {}>.error: Error
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
} return context
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
} } declare abstract class FetcherLike {_res
— The Response object to set.fetch
class FetcherLike
(input:
(method) FetcherLike.fetch(input: RequestInfo, init?: RequestInit): Promise<Response>
RequestInfo,
(parameter) input: RequestInfo
init?:
type RequestInfo = string | Request
RequestInit):
(parameter) init: RequestInit | undefined
Promise
interface RequestInit
<Response>
interface Promise<T>
Represents the completion of an asynchronous operation} /** * * @description `serveStatic()` is for advanced mode: * https://developers.cloudflare.com/pages/platform/functions/advanced-mode/#set-up-a-function * */ export const serveStatic = ():
interface Response
This Fetch API interface represents the response to a request.
const serveStatic: () => MiddlewareHandler
@description
MiddlewareHandler => {
serveStatic()
is for advanced mode: https://developers.cloudflare.com/pages/platform/functions/advanced-mode/#set-up-a-functionreturn async (c) => {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
const env =
(parameter) c: Context<any, string, {}>
c
const env: { ASSETS: FetcherLike; }
.env as {
(parameter) c: Context<any, string, {}>
(property) Context<any, string, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
ASSETS:
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
FetcherLike }
(property) ASSETS: FetcherLike
const res = await
class FetcherLike
env
const res: Response
.ASSETS
const env: { ASSETS: FetcherLike; }
.fetch
(property) ASSETS: FetcherLike
(c
(method) FetcherLike.fetch(input: RequestInfo, init?: RequestInit): Promise<Response>
.req
(parameter) c: Context<any, string, {}>
.raw)
(property) Context<any, string, {}>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
if (res
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.status === 404) {
const res: Response
return c
(property) Response.status: number
MDN Reference.notFound()
(parameter) c: Context<any, string, {}>
(property) Context<any, string, {}>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
} return res
ts app.get('/notfound', (c) => { return c.notFound() })
} }
const res: Response
/** * @module * Cloudflare Pages Adapter for Hono. */ export { handle,handleMiddleware,
(alias) const handle: <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => PagesFunction<E["Bindings"], any, Record<string, unknown>> export handle
serveStatic } from './handler'
(alias) function handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & { Bindings: { eventContext: EventContext; }; }, P, I>): PagesFunction<...> export handleMiddleware
(alias) const serveStatic: () => MiddlewareHandler export serveStatic
@description
export type { EventContext } from './handler'
serveStatic()
is for advanced mode: https://developers.cloudflare.com/pages/platform/functions/advanced-mode/#set-up-a-function
(alias) type EventContext<Env = {}, P extends string = any, Data = Record<string, unknown>> = { request: Request; functionPath: string; waitUntil: (promise: Promise<unknown>) => void; passThroughOnException: () => void; next: (input?: Request | string, init?: RequestInit) => Promise<Response>; env: Env & { ASSETS: { fetch: typeof fetch; }; }; params: Params<...>; data: Data; } export EventContext
import { Context } from '../../context' import { getConnInfo } from './conninfo' describe('getConnInfo', () => { it('Should getConnInfo works', () => { const address =Math
const address: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString()
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
const req = newradix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers.Request('http://localhost/', {
const req: Request
headers: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.'cf-connecting-ip': address,
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) const c = new
const address: string
Context
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const info =
const req: Request
getConnInfo
const info: ConnInfo
(c)
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
expect(info
const c: Context<any, any, {}>
.remote
const info: ConnInfo
.address).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(address)
(property) address?: string | undefined
Host name such as IP Addrexpect(info
const address: string
.remote
const info: ConnInfo
.addressType).toBeUndefined()
(property) ConnInfo.remote: NetAddrInfo
Remote information}) })
(property) addressType?: AddressType
Host name type
import type { GetConnInfo } from '../../helper/conninfo' export const getConnInfo:GetConnInfo =
const getConnInfo: GetConnInfo
(c) => ({
(alias) type GetConnInfo = (c: Context) => ConnInfo import GetConnInfo
Helper typeremote: {
(parameter) c: Context<any, any, {}>
address:
(property) ConnInfo.remote: NetAddrInfo
Remote informationc
(property) address: string | undefined
.req
(parameter) c: Context<any, any, {}>
.header('cf-connecting-ip'),
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
}, })
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
/** * @module * Cloudflare Workers Adapter for Hono. */ export { serveStatic } from './serve-static-module'export { upgradeWebSocket } from './websocket'
(alias) const serveStatic: <E extends Env = Env>(options: Omit<ServeStaticOptions<E>, "namespace">) => MiddlewareHandler export serveStatic
export { getConnInfo } from './conninfo'
(alias) const upgradeWebSocket: UpgradeWebSocket<WebSocket> export upgradeWebSocket
(alias) const getConnInfo: GetConnInfo export getConnInfo
// For ES module mode import type { Env, MiddlewareHandler } from '../../types' import type { ServeStaticOptions } from './serve-static' import { serveStatic } from './serve-static' const module =<E extends
const module: <E extends Env = Env>(options: Omit<ServeStaticOptions<E>, "namespace">) => MiddlewareHandler
Env =
(type parameter) E in <E extends Env = Env>(options: Omit<ServeStaticOptions<E>, "namespace">): MiddlewareHandler
Env>(
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
options:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Omit
(parameter) options: Omit<ServeStaticOptions<E>, "namespace">
<ServeStaticOptions
type Omit<T, K extends keyof any> = { [P in Exclude<keyof T, K>]: T[P]; }
Construct a type with the properties of T except for those in type K.<E>, 'namespace'>
(alias) type ServeStaticOptions<E extends Env = Env> = ServeStaticOptions<E> & { namespace?: unknown; manifest: object | string; } import ServeStaticOptions
): MiddlewareHandler => {
(type parameter) E in <E extends Env = Env>(options: Omit<ServeStaticOptions<E>, "namespace">): MiddlewareHandler
return serveStatic
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
(alias) serveStatic<E>(options: ServeStaticOptions<E>): MiddlewareHandler import serveStatic
@deprecated
<E>
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.(options)
(type parameter) E in <E extends Env = Env>(options: Omit<ServeStaticOptions<E>, "namespace">): MiddlewareHandler
} export { module as
(parameter) options: Omit<ServeStaticOptions<E>, "namespace">
serveStatic }
const module: <E extends Env = Env>(options: Omit<ServeStaticOptions<E>, "namespace">) => MiddlewareHandler
(alias) const serveStatic: <E extends Env = Env>(options: Omit<ServeStaticOptions<E>, "namespace">) => MiddlewareHandler export serveStatic
import type { Context } from '../../context' import { Hono } from '../../hono' import type { Next } from '../../types' import { serveStatic } from './serve-static' // Mock const store:Record
const store: Record<string, string>
= { 'assets/static/plain.abcdef.txt': 'This is plain.txt', 'assets/static/hono.abcdef.html': '
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type THono!
', 'assets/static/top/index.abcdef.html': 'Top
', 'static-no-root/plain.abcdef.txt': 'That is plain.txt', 'assets/static/options/foo.abcdef.txt': 'With options', 'assets/.static/plain.abcdef.txt': 'In the dot', 'assets/static/video/morning-routine.abcdef.m3u8': 'Good morning', 'assets/static/video/morning-routine1.abcdef.ts': 'Good', 'assets/static/video/introduction.abcdef.mp4': 'Let me introduce myself', 'assets/static/download': 'download', } const manifest =JSON
const manifest: string
.stringify({
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
'assets/static/plain.txt': 'assets/static/plain.abcdef.txt', 'assets/static/hono.html': 'assets/static/hono.abcdef.html', 'assets/static/top/index.html': 'assets/static/top/index.abcdef.html', 'static-no-root/plain.txt': 'static-no-root/plain.abcdef.txt', 'assets/.static/plain.txt': 'assets/.static/plain.abcdef.txt', 'assets/static/download': 'assets/static/download', }) Objectspace
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read..assign(global, {
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.assign<any, { __STATIC_CONTENT_MANIFEST: string; }>(target: any, source: { __STATIC_CONTENT_MANIFEST: string; }): any (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.@param
target
— The target object to copy to.@param
__STATIC_CONTENT_MANIFEST:source
— The source object from which to copy properties.manifest })
(property) __STATIC_CONTENT_MANIFEST: string
Object
const manifest: string
.assign(global, {
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.assign<any, { __STATIC_CONTENT: { get: (path: string) => string; }; }>(target: any, source: { __STATIC_CONTENT: { get: (path: string) => string; }; }): any (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.@param
target
— The target object to copy to.@param
__STATIC_CONTENT: {source
— The source object from which to copy properties.get:
(property) __STATIC_CONTENT: { get: (path: string) => string; }
(path: string) => {
(property) get: (path: string) => string
return store
(parameter) path: string
[path]
const store: Record<string, string>
}, }, }) describe('ServeStatic Middleware', () => { const app = new
(parameter) path: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const onNotFound = vi.fn(() => {})options
— Optional configuration options for the Hono instance.app
const onNotFound: any
.use('/static/*',
const app: Hono<BlankEnv, BlankSchema, "/">
serveStatic({
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/static/*", "/static/*", any>(path: "/static/*", handler: MiddlewareHandler<any, "/static/*", {}>) => Hono<{}, { "/static/*": {}; }, "/"> (+20 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
root: './assets',
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.onNotFound,
(property) root?: string | undefined
manifest }))
(property) onNotFound?: ((path: string, c: Context<Env, any, {}>) => void | Promise<void>) | undefined
app
(property) manifest: string | object
.use('/static-no-root/*',
const app: Hono<BlankEnv, BlankSchema, "/">
serveStatic({
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/static-no-root/*", "/static-no-root/*", any>(path: "/static-no-root/*", handler: MiddlewareHandler<any, "/static-no-root/*", {}>) => Hono<{}, { "/static-no-root/*": {}; }, "/"> (+20 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
manifest }))
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.app
(property) manifest: string | object
.use(
const app: Hono<BlankEnv, BlankSchema, "/">
'/dot-static/*', serveStatic({
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/dot-static/*", "/dot-static/*", any>(path: "/dot-static/*", handler: MiddlewareHandler<any, "/dot-static/*", {}>) => Hono<{}, { "/dot-static/*": {}; }, "/"> (+20 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
root: './assets',
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.rewriteRequestPath:
(property) root?: string | undefined
(path) =>
(property) rewriteRequestPath?: ((path: string) => string) | undefined
path
(parameter) path: string
.replace(/^\/dot-static/, '/.static'),
(parameter) path: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
manifest,replaceValue
— The replacement text.}) ) beforeEach(() => onNotFound.mockClear())
(property) manifest: string | object
it('Should return plain.txt', async () => { const res = await
const onNotFound: any
app
const res: Response
.request('http://localhost/static/plain.txt')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('This is plain.txt')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('text/plain; charset=utf-8')
(property) Response.headers: Headers
MDN Referenceexpect(onNotFound).not.toHaveBeenCalled()
(method) Headers.get(name: string): string | null
MDN Reference}) it('Should return hono.html', async () => { const res = await
const onNotFound: any
app
const res: Response
.request('http://localhost/static/hono.html')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('
const res: Response
Hono!
')expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('text/html; charset=utf-8')
(property) Response.headers: Headers
MDN Referenceexpect(onNotFound).not.toHaveBeenCalled()
(method) Headers.get(name: string): string | null
MDN Reference}) it('Should return 404 response', async () => { const res = await
const onNotFound: any
app
const res: Response
.request('http://localhost/static/not-found.html')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
expect(onNotFound).toHaveBeenCalledWith('assets/static/not-found.html', expect.anything())
(property) Response.status: number
MDN Reference}) it('Should return plan.txt', async () => { const res = await
const onNotFound: any
app
const res: Response
.request('http://localhost/static-no-root/plain.txt')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('That is plain.txt')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('text/plain; charset=utf-8')
(property) Response.headers: Headers
MDN Reference}) it('Should return index.html', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/static/top')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('
const res: Response
Top
')expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('text/html; charset=utf-8')
(property) Response.headers: Headers
MDN Reference}) it('Should return plain.txt with a rewriteRequestPath option', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/dot-static/plain.txt')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('In the dot')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('text/plain; charset=utf-8')
(property) Response.headers: Headers
MDN Reference}) }) describe('With options', () => { const manifest = {
(method) Headers.get(name: string): string | null
MDN Reference'assets/static/options/foo.txt': 'assets/static/options/foo.abcdef.txt', } const app = new
const manifest: { 'assets/static/options/foo.txt': string; }
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('/static/*',
const app: Hono<BlankEnv, BlankSchema, "/">
serveStatic({
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/static/*", "/static/*", any>(path: "/static/*", handler: MiddlewareHandler<any, "/static/*", {}>) => Hono<{}, { "/static/*": {}; }, "/"> (+20 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
root: './assets',
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.manifest:
(property) root?: string | undefined
manifest }))
(property) manifest: string | object
it('Should return foo.txt', async () => { const res = await
const manifest: { 'assets/static/options/foo.txt': string; }
app
const res: Response
.request('http://localhost/static/options/foo.txt')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('With options')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('text/plain; charset=utf-8')
(property) Response.headers: Headers
MDN Reference}) }) describe('With `file` options', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/foo/*',
const app: Hono<BlankEnv, BlankSchema, "/">
serveStatic({
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo/*", "/foo/*", HandlerResponse<any>, {}, any>(path: "/foo/*", handler: H<any, "/foo/*", {}, HandlerResponse<any>>) => Hono<BlankEnv, { ...; }, "/"> (+22 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
path: './assets/static/hono.html',
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.manifest }))
(property) path?: string | undefined
app
(property) manifest: string | object
.get('/bar/*',
const app: Hono<BlankEnv, BlankSchema, "/">
serveStatic({
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/bar/*", "/bar/*", HandlerResponse<any>, {}, any>(path: "/bar/*", handler: H<any, "/bar/*", {}, HandlerResponse<any>>) => Hono<BlankEnv, { ...; }, "/"> (+22 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
path: './static/hono.html',
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.root: './assets',
(property) path?: string | undefined
manifest }))
(property) root?: string | undefined
it('Should return hono.html', async () => { const res = await
(property) manifest: string | object
app
const res: Response
.request('http://localhost/foo/fallback')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('
const res: Response
Hono!
')}) it('Should return hono.html - with `root` option', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/bar/fallback')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('
const res: Response
Hono!
')}) }) describe('With `mimes` options', () => { const mimes = {
(method) Body.text(): Promise<string>
MDN Referencem3u8: 'application/vnd.apple.mpegurl',
const mimes: { m3u8: string; ts: string; }
ts: 'video/mp2t',
(property) m3u8: string
} const manifest = {
(property) ts: string
'assets/static/video/morning-routine.m3u8': 'assets/static/video/morning-routine.abcdef.m3u8', 'assets/static/video/morning-routine1.ts': 'assets/static/video/morning-routine1.abcdef.ts', 'assets/static/video/introduction.mp4': 'assets/static/video/introduction.abcdef.mp4', } const app = new
const manifest: { 'assets/static/video/morning-routine.m3u8': string; 'assets/static/video/morning-routine1.ts': string; 'assets/static/video/introduction.mp4': string; }
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('/static/*',
const app: Hono<BlankEnv, BlankSchema, "/">
serveStatic({
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/static/*", "/static/*", any>(path: "/static/*", handler: MiddlewareHandler<any, "/static/*", {}>) => Hono<{}, { "/static/*": {}; }, "/"> (+20 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
root: './assets',
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.mimes,
(property) root?: string | undefined
manifest }))
(property) mimes?: Record<string, string> | undefined
it('Should return content-type of m3u8', async () => { const res = await
(property) manifest: string | object
app
const res: Response
.request('http://localhost/static/video/morning-routine.m3u8')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('application/vnd.apple.mpegurl')
(property) Response.headers: Headers
MDN Reference}) it('Should return content-type of ts', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/static/video/morning-routine1.ts')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('video/mp2t')
(property) Response.headers: Headers
MDN Reference}) it('Should return content-type of default on Hono', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/static/video/introduction.mp4')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('video/mp4')
(property) Response.headers: Headers
MDN Reference}) }) describe('With middleware', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const md1 = asyncoptions
— Optional configuration options for the Hono instance.(c:
const md1: (c: Context, next: Next) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Next) => {
(parameter) next: Next
await next()
(alias) type Next = () => Promise<void> import Next
c
(parameter) next: () => Promise<void>
.res
(parameter) c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('x-foo', 'bar')
(property) Response.headers: Headers
MDN Reference} const md2 = async
(method) Headers.append(name: string, value: string): void
MDN Reference(c:
const md2: (c: Context, next: Next) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Next) => {
(parameter) next: Next
await next()
(alias) type Next = () => Promise<void> import Next
c
(parameter) next: () => Promise<void>
.res
(parameter) c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('x-foo2', 'bar2')
(property) Response.headers: Headers
MDN Reference} app
(method) Headers.append(name: string, value: string): void
MDN Reference.use('/static/*',
const app: Hono<BlankEnv, BlankSchema, "/">
md1)
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/static/*", any, any>(path: "/static/*", handler: MiddlewareHandler<any, any, {}>) => Hono<{}, { [x: string]: {}; }, "/"> (+20 overloads)
app
const md1: (c: Context, next: Next) => Promise<void>
.use('/static/*',
const app: Hono<BlankEnv, BlankSchema, "/">
md2)
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/static/*", any, any>(path: "/static/*", handler: MiddlewareHandler<any, any, {}>) => Hono<{}, { [x: string]: {}; }, "/"> (+20 overloads)
app
const md2: (c: Context, next: Next) => Promise<void>
.use('/static/*',
const app: Hono<BlankEnv, BlankSchema, "/">
serveStatic({
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/static/*", "/static/*", any>(path: "/static/*", handler: MiddlewareHandler<any, "/static/*", {}>) => Hono<{}, { "/static/*": {}; }, "/"> (+20 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
root: './assets',
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.manifest }))
(property) root?: string | undefined
app
(property) manifest: string | object
.get('/static/foo',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/static/foo", "/static/foo", Response & TypedResponse<"bar", StatusCode, "text">, BlankInput, BlankEnv>(path: "/static/foo", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/static/foo", BlankInput>
.text('bar')
(parameter) c: Context<BlankEnv, "/static/foo", BlankInput>
}) it('Should return plain.txt with correct headers', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"bar", StatusCode>(text: "bar", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"bar", StatusCode, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/static/plain.txt')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('This is plain.txt')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('Content-Type')).toBe('text/plain; charset=utf-8')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-foo')).toBe('bar')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-foo2')).toBe('bar2')
(property) Response.headers: Headers
MDN Reference}) it('Should return 200 Response', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/static/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('bar')
const res: Response
}) it('Should handle a file without an extension', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/static/download')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
}) }) describe('Types of middleware', () => { it('Should pass env type from generics of serveStatic', async () => { type Env = {
(property) Response.status: number
MDN ReferenceBindings: {
type Env = { Bindings: { HOGE: string; }; }
HOGE: string
(property) Bindings: { HOGE: string; }
} } const app = new
(property) HOGE: string
Hono
const app: Hono<Env, BlankSchema, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance.app
type Env = { Bindings: { HOGE: string; }; }
.use(
const app: Hono<Env, BlankSchema, "/">
'/static/*', serveStatic
(property) Hono<Env, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/static/*", "/static/*", any>(path: "/static/*", handler: MiddlewareHandler<any, "/static/*", {}>) => Hono<Env, { "/static/*": {}; }, "/"> (+20 overloads)
(alias) serveStatic<Env>(options: ServeStaticOptions<Env>): MiddlewareHandler import serveStatic
@deprecated
<Env>({
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.root: './assets',
type Env = { Bindings: { HOGE: string; }; }
onNotFound:
(property) root?: string | undefined
(_,
(property) onNotFound?: ((path: string, c: Context<Env, any, {}>) => void | Promise<void>) | undefined
c) => {
(parameter) _: string
expectTypeOf(c
(parameter) c: Context<Env, any, {}>
.env).toEqualTypeOf
(parameter) c: Context<Env, any, {}>
(property) Context<Env, any, {}>.env: { HOGE: string; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
<Env['Bindings']>()
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
}, manifest,
type Env = { Bindings: { HOGE: string; }; }
}) ) }) })
(property) manifest: string | object
import { serveStatic as baseServeStatic } from '../../middleware/serve-static' import type { ServeStaticOptions as BaseServeStaticOptions } from '../../middleware/serve-static' import type { Env, MiddlewareHandler } from '../../types' import { getContentFromKVAsset } from './utils' export type ServeStaticOptions<E extends
type ServeStaticOptions<E extends Env = Env> = BaseServeStaticOptions<E> & { namespace?: unknown; manifest: object | string; }
Env =
(type parameter) E in type ServeStaticOptions<E extends Env = Env>
Env> =
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
BaseServeStaticOptions
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
<E> & {
(alias) type BaseServeStaticOptions<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>; } import BaseServeStaticOptions
// namespace is KVNamespace namespace?: unknown
(type parameter) E in type ServeStaticOptions<E extends Env = Env>
manifest: object | string
(property) namespace?: unknown
} /** * @deprecated * `serveStatic` in the Cloudflare Workers adapter is deprecated. * If you want to create an application serving static assets, please consider using Cloudflare Pages. * You can start to create the Cloudflare Pages application with the `npm create hono@latest` command. */ export const serveStatic =
(property) manifest: string | object
const serveStatic: <E extends Env = Env>(options: ServeStaticOptions<E>) => MiddlewareHandler
@deprecated
<E extends
serveStatic
in the Cloudflare Workers adapter is deprecated. If you want to create an application serving static assets, please consider using Cloudflare Pages. You can start to create the Cloudflare Pages application with thenpm create hono@latest
command.Env =
(type parameter) E in <E extends Env = Env>(options: ServeStaticOptions<E>): MiddlewareHandler
Env>(
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
options:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
ServeStaticOptions
(parameter) options: ServeStaticOptions<E>
<E>
type ServeStaticOptions<E extends Env = Env> = BaseServeStaticOptions<E> & { namespace?: unknown; manifest: object | string; }
): MiddlewareHandler => {
(type parameter) E in <E extends Env = Env>(options: ServeStaticOptions<E>): MiddlewareHandler
return async function serveStatic
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
(c,
(local function) serveStatic(c: Context<any, string, {}>, next: Next): Promise<void | Response>
next) {
(parameter) c: Context<any, string, {}>
const getContent = async
(parameter) next: Next
(path: string) => {
const getContent: (path: string) => Promise<ReadableStream<any> | null>
return getContentFromKVAsset
(parameter) path: string
(path, {
(alias) getContentFromKVAsset(path: string, options?: KVAssetOptions): Promise<ReadableStream | null> import getContentFromKVAsset
manifest:
(parameter) path: string
options
(property) manifest?: string | object | undefined
.manifest,
(parameter) options: ServeStaticOptions<E>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore namespace:
(property) manifest: string | object
options
(property) namespace?: unknown
.namespace
(parameter) options: ServeStaticOptions<E>
? options
(property) namespace?: unknown
.namespace
(parameter) options: ServeStaticOptions<E>
: c
(property) namespace?: {}
.env
(parameter) c: Context<any, string, {}>
(property) Context<any, string, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
? c
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
.env.__STATIC_CONTENT
(parameter) c: Context<any, string, {}>
(property) Context<any, string, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
: undefined, }) } return baseServeStatic({
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
...options,
(alias) baseServeStatic<E>(options: BaseServeStaticOptions<E> & { getContent: (path: string, c: Context<E, any, {}>) => Promise<Data | Response | null>; pathResolve?: (path: string) => string; isDir?: (path: string) => boolean | undefined | Promise<boolean | undefined>; }): MiddlewareHandler import baseServeStatic
This middleware is not directly used by the user. Create a wrapper specifyinggetContent()
by the environment such as Deno or Bun.getContent,
(parameter) options: ServeStaticOptions<E>
})(c,
(property) getContent: (path: string, c: Context<E, any, {}>) => Promise<Data | Response | null>
next)
(parameter) c: Context<any, string, {}>
} }
(parameter) next: Next
import { getContentFromKVAsset } from './utils' // Mock const store: {[key: string]: string } = {
const store: { [key: string]: string; }
'index.abcdef.html': 'This is index', 'assets/static/plain.abcdef.txt': 'Asset text', } const manifest =
(parameter) key: string
JSON
const manifest: string
.stringify({
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
'index.html': 'index.abcdef.html', 'assets/static/plain.txt': 'assets/static/plain.abcdef.txt', }) Objectspace
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read..assign(global, {
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.assign<any, { __STATIC_CONTENT_MANIFEST: string; }>(target: any, source: { __STATIC_CONTENT_MANIFEST: string; }): any (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.@param
target
— The target object to copy to.@param
__STATIC_CONTENT_MANIFEST:source
— The source object from which to copy properties.manifest })
(property) __STATIC_CONTENT_MANIFEST: string
Object
const manifest: string
.assign(global, {
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.assign<any, { __STATIC_CONTENT: { get: (path: string) => string; }; }>(target: any, source: { __STATIC_CONTENT: { get: (path: string) => string; }; }): any (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.@param
target
— The target object to copy to.@param
__STATIC_CONTENT: {source
— The source object from which to copy properties.get:
(property) __STATIC_CONTENT: { get: (path: string) => string; }
(path: string) => {
(property) get: (path: string) => string
return store
(parameter) path: string
[path]
const store: { [key: string]: string; }
}, }, }) describe('Utils for Cloudflare Workers', () => { it('getContentFromKVAsset', async () => { let content = await
(parameter) path: string
getContentFromKVAsset('not-found.txt')
let content: ReadableStream<any> | null
expect(content).toBeFalsy()
(alias) getContentFromKVAsset(path: string, options?: KVAssetOptions): Promise<ReadableStream | null> import getContentFromKVAsset
content = await
let content: ReadableStream<any> | null
getContentFromKVAsset('index.html')
let content: ReadableStream<any> | null
expect(content).toBeTruthy()
(alias) getContentFromKVAsset(path: string, options?: KVAssetOptions): Promise<ReadableStream | null> import getContentFromKVAsset
expect(content).toBe('This is index')
let content: ReadableStream<any> | null
content = await
let content: ReadableStream<any> | null
getContentFromKVAsset('assets/static/plain.txt')
let content: ReadableStream<any> | null
expect(content).toBeTruthy()
(alias) getContentFromKVAsset(path: string, options?: KVAssetOptions): Promise<ReadableStream | null> import getContentFromKVAsset
expect(content).toBe('Asset text')
let content: ReadableStream<any> | null
}) })
let content: ReadableStream<any> | null
// __STATIC_CONTENT is KVNamespace declare const __STATIC_CONTENT: unknowndeclare const __STATIC_CONTENT_MANIFEST: string
const __STATIC_CONTENT: unknown
export type KVAssetOptions = {
const __STATIC_CONTENT_MANIFEST: string
manifest?: object | string
type KVAssetOptions = { manifest?: object | string; namespace?: unknown; }
// namespace is KVNamespace namespace?: unknown
(property) manifest?: string | object | undefined
} export const getContentFromKVAsset = async (
(property) namespace?: unknown
path: string,
const getContentFromKVAsset: (path: string, options?: KVAssetOptions) => Promise<ReadableStream | null>
options?:
(parameter) path: string
KVAssetOptions
(parameter) options: KVAssetOptions | undefined
): Promise
type KVAssetOptions = { manifest?: object | string; namespace?: unknown; }
<ReadableStream | null> => {
interface Promise<T>
Represents the completion of an asynchronous operationlet ASSET_MANIFEST:
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.Record
let ASSET_MANIFEST: Record<string, string>
if (options &&
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Toptions
(parameter) options: KVAssetOptions | undefined
.manifest) {
(parameter) options: KVAssetOptions
if (typeof options
(property) manifest?: string | object | undefined
.manifest === 'string') {
(parameter) options: KVAssetOptions
ASSET_MANIFEST =
(property) manifest?: string | object
JSON
let ASSET_MANIFEST: Record<string, string>
.parse
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.parse(text: string, reviver?: (this: any, key: string, value: any) => any): any
Converts a JavaScript Object Notation (JSON) string into an object.@param
text
— A valid JSON string.@param
(optionsreviver
A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is..manifest)
(parameter) options: KVAssetOptions
} else { ASSET_MANIFEST =
(property) manifest?: string
options
let ASSET_MANIFEST: Record<string, string>
.manifest as
(parameter) options: KVAssetOptions
Record
(property) manifest?: object
} } else { if (typeof __STATIC_CONTENT_MANIFEST === 'string') {
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TASSET_MANIFEST =
const __STATIC_CONTENT_MANIFEST: string
JSON
let ASSET_MANIFEST: Record<string, string>
.parse
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.parse(text: string, reviver?: (this: any, key: string, value: any) => any): any
Converts a JavaScript Object Notation (JSON) string into an object.@param
text
— A valid JSON string.@param
(__STATIC_CONTENT_MANIFEST)reviver
A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.} else { ASSET_MANIFEST =
const __STATIC_CONTENT_MANIFEST: string
__STATIC_CONTENT_MANIFEST
let ASSET_MANIFEST: Record<string, string>
} } // ASSET_NAMESPACE is KVNamespace let ASSET_NAMESPACE: unknown
const __STATIC_CONTENT_MANIFEST: never
if (options &&
let ASSET_NAMESPACE: unknown
options
(parameter) options: KVAssetOptions | undefined
.namespace) {
(parameter) options: KVAssetOptions
ASSET_NAMESPACE =
(property) namespace?: unknown
options
let ASSET_NAMESPACE: unknown
.namespace
(parameter) options: KVAssetOptions
} else { ASSET_NAMESPACE =
(property) namespace?: {}
__STATIC_CONTENT
let ASSET_NAMESPACE: unknown
} const key =
const __STATIC_CONTENT: unknown
ASSET_MANIFEST
const key: string
[path] ||
let ASSET_MANIFEST: Record<string, string>
path
(parameter) path: string
if (!key) {
(parameter) path: string
return null } // @ts-expect-error ASSET_NAMESPACE is not typed const content = await
const key: string
ASSET_NAMESPACE.get
const content: any
(key, {
let ASSET_NAMESPACE: unknown
type: 'stream' })
const key: string
if (!content) {
(property) type: string
return null } return content as unknown as
const content: any
ReadableStream
const content: any
}
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.
import { Hono } from '../..' import { upgradeWebSocket } from '.' describe('upgradeWebSocket middleware', () => { const server = newEventTarget()
const server: EventTarget
// @ts-expect-error Cloudflare API globalThis.WebSocketPair = class { 0: WebSocket // client
var EventTarget: new () => EventTarget
EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.1: WebSocket // server
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.constructor() { this[0] = {} as WebSocket
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.this[1] = server as
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.WebSocket
const server: EventTarget
} } const app = new
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const wsPromise = newoptions
— Optional configuration options for the Hono instance.Promise(
const wsPromise: Promise<unknown>
var Promise: PromiseConstructor new <unknown>(executor: (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void) => Promise<unknown>
Creates a new Promise.@param
(resolve) =>executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.app
(parameter) resolve: (value: unknown) => void
.get(
const app: Hono<BlankEnv, BlankSchema, "/">
'/ws', upgradeWebSocket(() => ({
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/ws", "/ws", HandlerResponse<any>, { outputFormat: "ws"; }, any>(path: "/ws", handler: H<any, "/ws", { outputFormat: "ws"; }, HandlerResponse<any>>) => Hono<...> (+22 overloads)
// eslint-disable-next-line @typescript-eslint/no-unused-vars onMessage
(alias) upgradeWebSocket(createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>, options?: any): MiddlewareHandler<any, string, { outputFormat: "ws"; }> import upgradeWebSocket
(evt,
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
ws) {
(parameter) evt: MessageEvent<WSMessageReceive>
resolve
(parameter) ws: WSContext<WebSocket>
(evt
(parameter) resolve: (value: unknown) => void
.data)
(parameter) evt: MessageEvent<WSMessageReceive>
}, })) ) ) it('Should receive message is valid', async () => { const sendingData =
(property) MessageEvent<WSMessageReceive>.data: WSMessageReceive
Returns the data of the message.Math
const sendingData: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString()
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
await appradix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers..request('/ws', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {Upgrade: 'websocket',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) server
(property) Upgrade: string
.dispatchEvent(
const server: EventTarget
new MessageEvent('message', {
(method) EventTarget.dispatchEvent(event: Event): boolean
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.data:
var MessageEvent: new <string>(type: string, eventInitDict?: MessageEventInit<string> | undefined) => MessageEvent<string>
A message received by a target object.sendingData,
(property) MessageEventInit<string>.data?: string | undefined
}) ) expect(sendingData).toBe(await
const sendingData: string
wsPromise)
const sendingData: string
}) })
const wsPromise: Promise<unknown>
import type { UpgradeWebSocket, WSContext, WSReadyState } from '../../helper/websocket' // Based on https://github.com/honojs/hono/issues/1153#issuecomment-1767321332 export const upgradeWebSocket:UpgradeWebSocket
const upgradeWebSocket: UpgradeWebSocket<WebSocket>
<WebSocket> =
(alias) type UpgradeWebSocket<T = unknown, U = any> = (createEvents: (c: Context) => WSEvents<T> | Promise<WSEvents<T>>, options?: U) => MiddlewareHandler<any, string, { outputFormat: "ws"; }> import UpgradeWebSocket
Upgrade WebSocket Type(createEvents) => async
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.(c,
(parameter) createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>
next) => {
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
const events = await
(parameter) next: Next
createEvents
const events: WSEvents<WebSocket>
(c)
(parameter) createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>
const upgradeHeader =
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
c
const upgradeHeader: string | undefined
.req
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
.header('Upgrade')
(property) Context<any, string, { outputFormat: "ws"; }>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<string, unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
if (upgradeHeader !== 'websocket') {
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
return await next()
const upgradeHeader: string | undefined
} // @ts-expect-error WebSocketPair is not typed const webSocketPair = new WebSocketPair()
(parameter) next: () => Promise<void>
const client:
const webSocketPair: any
WebSocket =
const client: WebSocket
webSocketPair[0]
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.const server:
const webSocketPair: any
WebSocket =
const server: WebSocket
webSocketPair[1]
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.const wsContext:
const webSocketPair: any
WSContext
const wsContext: WSContext<WebSocket>
<WebSocket> = {
(alias) type WSContext<T = unknown> = { send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void; raw?: T; binaryType: BinaryType; readyState: WSReadyState; url: URL | null; protocol: string | null; close(code?: number, reason?: string): void; } import WSContext
binaryType: 'arraybuffer',
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.close:
(property) binaryType: BinaryType
(code,
(method) close(code?: number, reason?: string): void
reason) =>
(parameter) code: number | undefined
server
(parameter) reason: string | undefined
.close
const server: WebSocket
(code,
(method) WebSocket.close(code?: number, reason?: string): void
Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.reason),
(parameter) code: number | undefined
get protocol() {
(parameter) reason: string | undefined
return server
(property) protocol: string | null
.protocol
const server: WebSocket
}, raw:
(property) WebSocket.protocol: string
Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.server,
(property) raw?: WebSocket | undefined
get readyState() {
const server: WebSocket
return server
(property) readyState: WSReadyState
.readyState as
const server: WebSocket
WSReadyState
(property) WebSocket.readyState: number
Returns the state of the WebSocket object's connection. It can have the values described below.}, url:
(alias) type WSReadyState = 0 | 2 | 1 | 3 import WSReadyState
server
(property) url: URL | null
.url ? new
const server: WebSocket
URL
(property) WebSocket.url: string
Returns the URL that was used to establish the WebSocket connection.(server
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs..url) : null,
const server: WebSocket
send:
(property) WebSocket.url: string
Returns the URL that was used to establish the WebSocket connection.(source) =>
(method) send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void
server
(parameter) source: string | ArrayBuffer | Uint8Array
.send
const server: WebSocket
(source),
(method) WebSocket.send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void
Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.} if (events
(parameter) source: string | ArrayBuffer | Uint8Array
.onOpen) {
const events: WSEvents<WebSocket>
server
(property) WSEvents<WebSocket>.onOpen?: ((evt: Event, ws: WSContext<WebSocket>) => void) | undefined
.addEventListener('open',
const server: WebSocket
(method) WebSocket.addEventListener<"open">(type: "open", listener: (this: WebSocket, ev: Event) => any, options?: boolean | AddEventListenerOptions): void (+1 overload)
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
(evt:Event) =>
(parameter) evt: Event
events
interface Event
An event which takes place in the DOM..onOpen?.
const events: WSEvents<WebSocket>
(evt,
(property) WSEvents<WebSocket>.onOpen?: ((evt: Event, ws: WSContext<WebSocket>) => void) | undefined
wsContext))
(parameter) evt: Event
} if (events
const wsContext: WSContext<WebSocket>
.onClose) {
const events: WSEvents<WebSocket>
server
(property) WSEvents<WebSocket>.onClose?: ((evt: CloseEvent, ws: WSContext<WebSocket>) => void) | undefined
.addEventListener('close',
const server: WebSocket
(method) WebSocket.addEventListener<"close">(type: "close", listener: (this: WebSocket, ev: CloseEvent) => any, options?: boolean | AddEventListenerOptions): void (+1 overload)
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
(evt:CloseEvent) =>
(parameter) evt: CloseEvent
events
interface CloseEvent
A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute..onClose?.
const events: WSEvents<WebSocket>
(evt,
(property) WSEvents<WebSocket>.onClose?: ((evt: CloseEvent, ws: WSContext<WebSocket>) => void) | undefined
wsContext))
(parameter) evt: CloseEvent
} if (events
const wsContext: WSContext<WebSocket>
.onMessage) {
const events: WSEvents<WebSocket>
server
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
.addEventListener('message',
const server: WebSocket
(method) WebSocket.addEventListener<"message">(type: "message", listener: (this: WebSocket, ev: MessageEvent<any>) => any, options?: boolean | AddEventListenerOptions): void (+1 overload)
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
(evt:MessageEvent) =>
(parameter) evt: MessageEvent<any>
events
interface MessageEvent<T = any>
A message received by a target object..onMessage?.
const events: WSEvents<WebSocket>
(evt,
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
wsContext))
(parameter) evt: MessageEvent<any>
} if (events
const wsContext: WSContext<WebSocket>
.onError) {
const events: WSEvents<WebSocket>
server
(property) WSEvents<WebSocket>.onError?: ((evt: Event, ws: WSContext<WebSocket>) => void) | undefined
.addEventListener('error',
const server: WebSocket
(method) WebSocket.addEventListener<"error">(type: "error", listener: (this: WebSocket, ev: Event) => any, options?: boolean | AddEventListenerOptions): void (+1 overload)
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
(evt:Event) =>
(parameter) evt: Event
events
interface Event
An event which takes place in the DOM..onError?.
const events: WSEvents<WebSocket>
(evt,
(property) WSEvents<WebSocket>.onError?: ((evt: Event, ws: WSContext<WebSocket>) => void) | undefined
wsContext))
(parameter) evt: Event
} // @ts-expect-error - server.accept is not typed server.accept?.()
const wsContext: WSContext<WebSocket>
return new Response(null, {
const server: WebSocket
status: 101,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.// @ts-expect-error - webSocket is not typed webSocket:
(property) ResponseInit.status?: number | undefined
client,
(property) webSocket: WebSocket
}) }
const client: WebSocket
import { Context } from '../../context' import { getConnInfo } from './conninfo' describe('getConnInfo', () => { it('Should info is valid', () => { const transport = 'tcp'const address =
const transport: "tcp"
Math
const address: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString()
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
const port =radix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers.Math
const port: number
.floor
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.
(method) Math.floor(x: number): number
Returns the greatest integer less than or equal to its numeric argument.@param
(Mathx
— A numeric expression..random() * (65535 + 1))
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.const c = new
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.Context(new
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.remoteAddr: {
(property) env: any
Bindings for the environment.transport,
(property) remoteAddr: { transport: string; hostname: string; port: number; }
hostname:
(property) transport: string
address,
(property) hostname: string
port,
const address: string
}, }, }) const info =
(property) port: number
getConnInfo
const info: ConnInfo
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
Get conninfo with Deno@param
c
— Context@returns — ConnInfo
(c)expect(info
const c: Context<any, any, {}>
.remote
const info: ConnInfo
.port).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(port)
(property) port?: number | undefined
Transport port numberexpect(info
const port: number
.remote
const info: ConnInfo
.address).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(address)
(property) address?: string | undefined
Host name such as IP Addrexpect(info
const address: string
.remote
const info: ConnInfo
.addressType).toBeUndefined()
(property) ConnInfo.remote: NetAddrInfo
Remote informationexpect(info
(property) addressType?: AddressType
Host name type.remote
const info: ConnInfo
.transport).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(transport)
(property) transport?: "tcp" | "udp" | undefined
Transport protocol type}) })
const transport: "tcp"
import type { GetConnInfo } from '../../helper/conninfo' /** * Get conninfo with Deno * @param c Context * @returns ConnInfo */ export const getConnInfo:
const getConnInfo: GetConnInfo
Get conninfo with Deno@param
c
— Context@returns — ConnInfo
GetConnInfo =(c) => {
(alias) type GetConnInfo = (c: Context) => ConnInfo import GetConnInfo
Helper type
(parameter) c: Context<any, any, {}>
Context@param
const { remoteAddr } =c
— Contextc
const remoteAddr: any
(parameter) c: Context<any, any, {}>
Context@param
.envc
— Context
(property) Context<any, any, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
return { remote: {
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
address:
(property) ConnInfo.remote: NetAddrInfo
Remote informationremoteAddr.hostname,
(property) address: any
port:
const remoteAddr: any
remoteAddr.port,
(property) port?: number | undefined
Transport port numbertransport:
const remoteAddr: any
remoteAddr.transport,
(property) transport?: "tcp" | "udp" | undefined
Transport protocol type}, } }
const remoteAddr: any
declare namespace Deno {/** * Creates a new directory with the specified path. * * @param path The path to create a directory. * @param options Options for creating a directory. * @returns A promise that resolves when the directory is created. */ export function mkdir
namespace Deno
function Deno.mkdir(path: string, options?: { recursive?: boolean; }): Promise<void>
Creates a new directory with the specified path.@param
path
— The path to create a directory.@param
options
— Options for creating a directory.@returns — A promise that resolves when the directory is created.
(path: string,
(parameter) path: string
The path to create a directory.@param
options?: {path
— The path to create a directory.
(parameter) options: { recursive?: boolean; } | undefined
Options for creating a directory.@param
recursive?: boolean }):options
— Options for creating a directory.Promise
(property) recursive?: boolean | undefined
/** * Write a new file, with the specified path and data. * * @param path The path to the file to write. * @param data The data to write to the file. * @returns A promise that resolves when the file is written. */ export function writeFile
interface Promise<T>
Represents the completion of an asynchronous operation
function Deno.writeFile(path: string, data: Uint8Array): Promise<void>
Write a new file, with the specified path and data.@param
path
— The path to the file to write.@param
data
— The data to write to the file.@returns — A promise that resolves when the file is written.
(path: string,
(parameter) path: string
The path to the file to write.@param
data:path
— The path to the file to write.
(parameter) data: Uint8Array
The data to write to the file.@param
Uint8Array):data
— The data to write to the file.Promise
interface Uint8Array
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.export function upgradeWebSocket(
interface Promise<T>
Represents the completion of an asynchronous operationreq:
function Deno.upgradeWebSocket(req: Request, options: any): { response: Response; socket: WebSocket; }
Request,
(parameter) req: Request
// eslint-disable-next-line @typescript-eslint/no-explicit-any options: any
interface Request
This Fetch API interface represents a resource request.): { response:
(parameter) options: any
Response
(property) response: Response
socket:
interface Response
This Fetch API interface represents the response to a request.WebSocket
(property) socket: WebSocket
} }
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
/** * @module * Deno Adapter for Hono. */ export { serveStatic } from './serve-static'export { toSSG,
(alias) const serveStatic: <E extends Env = Env>(options: ServeStaticOptions<E>) => MiddlewareHandler export serveStatic
(alias) const toSSG: ToSSGAdaptorInterface<Env, {}, "/"> export toSSG
@experimental
denoFileSystemModule } from './ssg'
toSSG
is an experimental feature. The API might be changed.
(alias) const denoFileSystemModule: FileSystemModule export denoFileSystemModule
@experimental
export { upgradeWebSocket } from './websocket'
denoFileSystemModule
is an experimental feature. The API might be changed.export { getConnInfo } from './conninfo'
(alias) const upgradeWebSocket: UpgradeWebSocket<WebSocket, UpgradeWebSocketOptions> export upgradeWebSocket
(alias) const getConnInfo: GetConnInfo export getConnInfo
Get conninfo with Deno@param
c
— Context@returns — ConnInfo
import type { ServeStaticOptions } from '../../middleware/serve-static' import { serveStatic as baseServeStatic } from '../../middleware/serve-static' import type { Env, MiddlewareHandler } from '../../types' // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const { open,lstatSync } =
const open: any
Deno
const lstatSync: any
export const serveStatic =
namespace Deno
<E extends
const serveStatic: <E extends Env = Env>(options: ServeStaticOptions<E>) => MiddlewareHandler
Env =
(type parameter) E in <E extends Env = Env>(options: ServeStaticOptions<E>): MiddlewareHandler
Env>(
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
options:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
ServeStaticOptions
(parameter) options: ServeStaticOptions<E>
<E>
(alias) 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>; } import ServeStaticOptions
): MiddlewareHandler => {
(type parameter) E in <E extends Env = Env>(options: ServeStaticOptions<E>): MiddlewareHandler
return async function serveStatic
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
(c,
(local function) serveStatic(c: Context<any, string, {}>, next: Next): Promise<void | Response>
next) {
(parameter) c: Context<any, string, {}>
const getContent = async
(parameter) next: Next
(path: string) => {
const getContent: (path: string) => Promise<any>
try { const file = await
(parameter) path: string
open
const file: any
(path)
const open: any
// eslint-disable-next-line @typescript-eslint/no-explicit-any return file ?
(parameter) path: string
(file.readable as any) : null
const file: any
} catch (e) {
const file: any
console
(local var) e: unknown
.warn(`$
var console: Console
{e}`)
(method) Console.warn(...data: any[]): void
MDN Reference} } const pathResolve =
(local var) e: unknown
(path: string) => {
const pathResolve: (path: string) => string
return path
(parameter) path: string
.startsWith('/') ?
(parameter) path: string
path : `./$
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.{path}`
(parameter) path: string
} const isDir =
(parameter) path: string
(path: string) => {
const isDir: (path: string) => any
let isDir
(parameter) path: string
try { const stat =
let isDir: any
lstatSync
const stat: any
(path)
const lstatSync: any
isDir =
(parameter) path: string
stat.isDirectory
let isDir: any
} catch {} return isDir
const stat: any
} return baseServeStatic({
let isDir: any
...options,
(alias) baseServeStatic<E>(options: ServeStaticOptions<E> & { getContent: (path: string, c: Context<E, any, {}>) => Promise<Data | Response | null>; pathResolve?: (path: string) => string; isDir?: (path: string) => boolean | undefined | Promise<boolean | undefined>; }): MiddlewareHandler import baseServeStatic
This middleware is not directly used by the user. Create a wrapper specifyinggetContent()
by the environment such as Deno or Bun.getContent,
(parameter) options: ServeStaticOptions<E>
pathResolve,
(property) getContent: (path: string, c: Context<E, any, {}>) => Promise<Data | Response | null>
isDir,
(property) pathResolve?: ((path: string) => string) | undefined
})(c,
(property) isDir?: ((path: string) => boolean | undefined | Promise<boolean | undefined>) | undefined
next)
(parameter) c: Context<any, string, {}>
} }
(parameter) next: Next
import { toSSG as baseToSSG } from '../../helper/ssg/index' import type { FileSystemModule, ToSSGAdaptorInterface } from '../../helper/ssg/index' /** * @experimental * `denoFileSystemModule` is an experimental feature. * The API might be changed. */ export const denoFileSystemModule:
const denoFileSystemModule: FileSystemModule
@experimental
FileSystemModule = {
denoFileSystemModule
is an experimental feature. The API might be changed.
(alias) interface FileSystemModule import FileSystemModule
@experimental
writeFile: async
FileSystemModule
is an experimental feature. The API might be changed.(path,
(method) FileSystemModule.writeFile(path: string, data: string | Uint8Array): Promise<void>
data) => {
(parameter) path: string
const uint8Data =
(parameter) data: string | Uint8Array
typeof data === 'string' ? new
const uint8Data: Uint8Array
TextEncoder()
(parameter) data: string | Uint8Array
.encode
var TextEncoder: new () => TextEncoder
TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays.(data) : new
(method) TextEncoder.encode(input?: string): Uint8Array
Returns the result of running UTF-8's encoder.Uint8Array
(parameter) data: string
(data)
var Uint8Array: Uint8ArrayConstructor new (elements: Iterable<number>) => Uint8Array (+4 overloads)
await Deno
(parameter) data: Uint8Array
.writeFile
namespace Deno
function Deno.writeFile(path: string, data: Uint8Array): Promise<void>
Write a new file, with the specified path and data.@param
path
— The path to the file to write.@param
data
— The data to write to the file.@returns — A promise that resolves when the file is written.
(path,uint8Data)
(parameter) path: string
}, mkdir: async
const uint8Data: Uint8Array
(path,
(method) FileSystemModule.mkdir(path: string, options: { recursive: boolean; }): Promise<void | string>
options) => {
(parameter) path: string
return Deno
(parameter) options: { recursive: boolean; }
.mkdir
namespace Deno
function Deno.mkdir(path: string, options?: { recursive?: boolean; }): Promise<void>
Creates a new directory with the specified path.@param
path
— The path to create a directory.@param
options
— Options for creating a directory.@returns — A promise that resolves when the directory is created.
(path, {recursive:
(parameter) path: string
options?
(property) recursive?: boolean | undefined
.recursive ?? false })
(parameter) options: { recursive: boolean; }
}, } /** * @experimental * `toSSG` is an experimental feature. * The API might be changed. */ export const toSSG:
(property) recursive: boolean
const toSSG: ToSSGAdaptorInterface<Env, {}, "/">
@experimental
ToSSGAdaptorInterface = async
toSSG
is an experimental feature. The API might be changed.
(alias) interface ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/"> import ToSSGAdaptorInterface
@experimental
(app,
ToSSGAdaptorInterface
is an experimental feature. The API might be changed.options) => {
(parameter) app: Hono<Env, {}, "/">
return baseToSSG
(parameter) options: ToSSGOptions | undefined
(alias) baseToSSG(app: Hono<any, any, any>, fsModule: FileSystemModule, options?: ToSSGOptions): Promise<ToSSGResult> import baseToSSG
@experimental
(app,
toSSG
is an experimental feature. The API might be changed.denoFileSystemModule,
(parameter) app: Hono<Env, {}, "/">
const denoFileSystemModule: FileSystemModule
@experimental
options)
denoFileSystemModule
is an experimental feature. The API might be changed.}
(parameter) options: ToSSGOptions | undefined
import { Hono } from '../..' import { upgradeWebSocket } from './websocket' globalThis.Deno = {} as typeofDeno
namespace Deno
describe('WebSockets', () => { let app:
namespace Deno
Hono
let app: Hono<BlankEnv, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
beforeEach(() => { app = newBasePath
— The base path type.Hono()
let app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
}) it('Should receive data is valid', async () => { const messagePromise = newoptions
— Optional configuration options for the Hono instance.Promise(
const messagePromise: Promise<unknown>
var Promise: PromiseConstructor new <unknown>(executor: (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void) => Promise<unknown>
Creates a new Promise.@param
(resolve) =>executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.app
(parameter) resolve: (value: unknown) => void
.get(
let app: Hono<BlankEnv, BlankSchema, "/">
'/ws', upgradeWebSocket(() => ({
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/ws", "/ws", HandlerResponse<any>, { outputFormat: "ws"; }, any>(path: "/ws", handler: H<any, "/ws", { outputFormat: "ws"; }, HandlerResponse<any>>) => Hono<...> (+22 overloads)
onMessage:
(alias) upgradeWebSocket(createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>, options?: UpgradeWebSocketOptions | undefined): MiddlewareHandler<any, string, { outputFormat: "ws"; }> import upgradeWebSocket
(evt) =>
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
resolve
(parameter) evt: MessageEvent<WSMessageReceive>
(evt
(parameter) resolve: (value: unknown) => void
.data),
(parameter) evt: MessageEvent<WSMessageReceive>
})) ) ) const socket = new
(property) MessageEvent<WSMessageReceive>.data: WSMessageReceive
Returns the data of the message.EventTarget() as
const socket: WebSocket
WebSocket
var EventTarget: new () => EventTarget
EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.Deno
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection..upgradeWebSocket = () => {
namespace Deno
return { response: new
function Deno.upgradeWebSocket(req: Request, options: any): { response: Response; socket: WebSocket; }
Response(),
(property) response: Response
socket,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.} } await app
(property) socket: WebSocket
.request('/ws', {
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {upgrade: 'websocket',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) const data =
(property) upgrade: string
Math
const data: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString()
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
socketradix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers..onmessage &&
const socket: WebSocket
socket
(property) WebSocket.onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null
MDN Reference.onmessage(
const socket: WebSocket
new MessageEvent('message', {
(property) WebSocket.onmessage: (this: WebSocket, ev: MessageEvent) => any
MDN Referencedata,
var MessageEvent: new <string>(type: string, eventInitDict?: MessageEventInit<string> | undefined) => MessageEvent<string>
A message received by a target object.}) ) expect(await messagePromise).toBe
(property) MessageEventInit<string>.data?: string | undefined
(data)
const messagePromise: Promise<unknown>
}) it('Should receive data is valid with Options', async () => { const messagePromise = new
const data: string
Promise(
const messagePromise: Promise<unknown>
var Promise: PromiseConstructor new <unknown>(executor: (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void) => Promise<unknown>
Creates a new Promise.@param
(resolve) =>executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.app
(parameter) resolve: (value: unknown) => void
.get(
let app: Hono<BlankEnv, BlankSchema, "/">
'/ws', upgradeWebSocket(
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/ws", "/ws", HandlerResponse<any>, { outputFormat: "ws"; }, any>(path: "/ws", handler: H<any, "/ws", { outputFormat: "ws"; }, HandlerResponse<any>>) => Hono<...> (+22 overloads)
() => ({ onMessage:
(alias) upgradeWebSocket(createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>, options?: UpgradeWebSocketOptions | undefined): MiddlewareHandler<any, string, { outputFormat: "ws"; }> import upgradeWebSocket
(evt) =>
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
resolve
(parameter) evt: MessageEvent<WSMessageReceive>
(evt
(parameter) resolve: (value: unknown) => void
.data),
(parameter) evt: MessageEvent<WSMessageReceive>
}), { idleTimeout: 5000,
(property) MessageEvent<WSMessageReceive>.data: WSMessageReceive
Returns the data of the message.
(property) UpgradeWebSocketOptions.idleTimeout?: number | undefined
If the client does not respond to this frame with apong
within the timeout specified, the connection is deemed unhealthy and is closed. Theclose
anderror
event will be emitted.The unit is seconds, with a default of 30. Set to
} ) ) ) const socket = new0
to disable timeouts.EventTarget() as
const socket: WebSocket
WebSocket
var EventTarget: new () => EventTarget
EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.Deno
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection..upgradeWebSocket = () => {
namespace Deno
return { response: new
function Deno.upgradeWebSocket(req: Request, options: any): { response: Response; socket: WebSocket; }
Response(),
(property) response: Response
socket,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.} } await app
(property) socket: WebSocket
.request('/ws', {
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {upgrade: 'websocket',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) const data =
(property) upgrade: string
Math
const data: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString()
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
socketradix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers..onmessage &&
const socket: WebSocket
socket
(property) WebSocket.onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null
MDN Reference.onmessage(
const socket: WebSocket
new MessageEvent('message', {
(property) WebSocket.onmessage: (this: WebSocket, ev: MessageEvent) => any
MDN Referencedata,
var MessageEvent: new <string>(type: string, eventInitDict?: MessageEventInit<string> | undefined) => MessageEvent<string>
A message received by a target object.}) ) expect(await messagePromise).toBe
(property) MessageEventInit<string>.data?: string | undefined
(data)
const messagePromise: Promise<unknown>
}) })
const data: string
import type { UpgradeWebSocket, WSContext, WSReadyState } from '../../helper/websocket' export interface UpgradeWebSocketOptions {/** * Sets the `.protocol` property on the client side web socket to the * value provided here, which should be one of the strings specified in the * `protocols` parameter when requesting the web socket. This is intended * for clients and servers to specify sub-protocols to use to communicate to * each other. */ protocol?: string
interface UpgradeWebSocketOptions
/** * If the client does not respond to this frame with a * `pong` within the timeout specified, the connection is deemed * unhealthy and is closed. The `close` and `error` event will be emitted. * * The unit is seconds, with a default of 30. * Set to `0` to disable timeouts. */ idleTimeout?: number
(property) UpgradeWebSocketOptions.protocol?: string | undefined
Sets the.protocol
property on the client side web socket to the value provided here, which should be one of the strings specified in theprotocols
parameter when requesting the web socket. This is intended for clients and servers to specify sub-protocols to use to communicate to each other.
(property) UpgradeWebSocketOptions.idleTimeout?: number | undefined
If the client does not respond to this frame with apong
within the timeout specified, the connection is deemed unhealthy and is closed. Theclose
anderror
event will be emitted.The unit is seconds, with a default of 30. Set to
} export const upgradeWebSocket:0
to disable timeouts.UpgradeWebSocket
const upgradeWebSocket: UpgradeWebSocket<WebSocket, UpgradeWebSocketOptions>
<WebSocket,
(alias) type UpgradeWebSocket<T = unknown, U = any> = (createEvents: (c: Context) => WSEvents<T> | Promise<WSEvents<T>>, options?: U) => MiddlewareHandler<any, string, { outputFormat: "ws"; }> import UpgradeWebSocket
Upgrade WebSocket TypeUpgradeWebSocketOptions> =
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.(createEvents,
interface UpgradeWebSocketOptions
options) => async
(parameter) createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>
(c,
(parameter) options: UpgradeWebSocketOptions | undefined
next) => {
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
if (c
(parameter) next: Next
.req
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
.header('upgrade') !== 'websocket') {
(property) Context<any, string, { outputFormat: "ws"; }>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<string, unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
return await next()
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
} const events = await
(parameter) next: () => Promise<void>
createEvents
const events: WSEvents<WebSocket>
(c)
(parameter) createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>
const { response,
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
socket } =
const response: Response
Deno
const socket: WebSocket
.upgradeWebSocket
namespace Deno
(c
function Deno.upgradeWebSocket(req: Request, options: any): { response: Response; socket: WebSocket; }
.req
(parameter) c: Context<any, string, { outputFormat: "ws"; }>
.raw,
(property) Context<any, string, { outputFormat: "ws"; }>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
options || {})
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
const wsContext:
(parameter) options: UpgradeWebSocketOptions | undefined
WSContext
const wsContext: WSContext<WebSocket>
<WebSocket> = {
(alias) type WSContext<T = unknown> = { send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void; raw?: T; binaryType: BinaryType; readyState: WSReadyState; url: URL | null; protocol: string | null; close(code?: number, reason?: string): void; } import WSContext
binaryType: 'arraybuffer',
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.close:
(property) binaryType: BinaryType
(code,
(method) close(code?: number, reason?: string): void
reason) =>
(parameter) code: number | undefined
socket
(parameter) reason: string | undefined
.close
const socket: WebSocket
(code,
(method) WebSocket.close(code?: number, reason?: string): void
Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.reason),
(parameter) code: number | undefined
get protocol() {
(parameter) reason: string | undefined
return socket
(property) protocol: string | null
.protocol
const socket: WebSocket
}, raw:
(property) WebSocket.protocol: string
Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.socket,
(property) raw?: WebSocket | undefined
get readyState() {
const socket: WebSocket
return socket
(property) readyState: WSReadyState
.readyState as
const socket: WebSocket
WSReadyState
(property) WebSocket.readyState: number
Returns the state of the WebSocket object's connection. It can have the values described below.}, url:
(alias) type WSReadyState = 0 | 2 | 1 | 3 import WSReadyState
socket
(property) url: URL | null
.url ? new
const socket: WebSocket
URL
(property) WebSocket.url: string
Returns the URL that was used to establish the WebSocket connection.(socket
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs..url) : null,
const socket: WebSocket
send:
(property) WebSocket.url: string
Returns the URL that was used to establish the WebSocket connection.(source) =>
(method) send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void
socket
(parameter) source: string | ArrayBuffer | Uint8Array
.send
const socket: WebSocket
(source),
(method) WebSocket.send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void
Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.} socket
(parameter) source: string | ArrayBuffer | Uint8Array
.onopen =
const socket: WebSocket
(evt) =>
(property) WebSocket.onopen: ((this: WebSocket, ev: Event) => any) | null
MDN Referenceevents
(parameter) evt: Event
.onOpen?.
const events: WSEvents<WebSocket>
(evt,
(property) WSEvents<WebSocket>.onOpen?: ((evt: Event, ws: WSContext<WebSocket>) => void) | undefined
wsContext)
(parameter) evt: Event
socket
const wsContext: WSContext<WebSocket>
.onmessage =
const socket: WebSocket
(evt) =>
(property) WebSocket.onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null
MDN Referenceevents
(parameter) evt: MessageEvent<any>
.onMessage?.
const events: WSEvents<WebSocket>
(evt,
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
wsContext)
(parameter) evt: MessageEvent<any>
socket
const wsContext: WSContext<WebSocket>
.onclose =
const socket: WebSocket
(evt) =>
(property) WebSocket.onclose: ((this: WebSocket, ev: CloseEvent) => any) | null
MDN Referenceevents
(parameter) evt: CloseEvent
.onClose?.
const events: WSEvents<WebSocket>
(evt,
(property) WSEvents<WebSocket>.onClose?: ((evt: CloseEvent, ws: WSContext<WebSocket>) => void) | undefined
wsContext)
(parameter) evt: CloseEvent
socket
const wsContext: WSContext<WebSocket>
.onerror =
const socket: WebSocket
(evt) =>
(property) WebSocket.onerror: ((this: WebSocket, ev: Event) => any) | null
MDN Referenceevents
(parameter) evt: Event
.onError?.
const events: WSEvents<WebSocket>
(evt,
(property) WSEvents<WebSocket>.onError?: ((evt: Event, ws: WSContext<WebSocket>) => void) | undefined
wsContext)
(parameter) evt: Event
return response
const wsContext: WSContext<WebSocket>
}
const response: Response
import { Context } from '../../context' import { getConnInfo } from './conninfo' import type { CloudFrontEdgeEvent } from './handler' describe('getConnInfo', () => { it('Should info is valid', () => { const clientIp =Math
const clientIp: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString()
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
const env = {radix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers.event: {
const env: { event: CloudFrontEdgeEvent; }
Records: [
(property) event: CloudFrontEdgeEvent
{ cf: {
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
request: {
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
clientIp,
(property) request: CloudFrontRequest
}, }, }, ], } as CloudFrontEdgeEvent,
(property) CloudFrontRequest.clientIp: string
} const c = new
(alias) interface CloudFrontEdgeEvent import CloudFrontEdgeEvent
Context(new
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
Request('http://localhost/'), {options
— Optional configuration options for the context.env })
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.const info =
(property) env: any
Bindings for the environment.getConnInfo
const info: ConnInfo
(c)
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
expect(info
const c: Context<any, any, {}>
.remote
const info: ConnInfo
.address).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(clientIp)
(property) address?: string | undefined
Host name such as IP Addr}) })
const clientIp: string
import type { Context } from '../../context' import type { GetConnInfo } from '../../helper/conninfo' import type { CloudFrontEdgeEvent } from './handler' type Env = {Bindings: {
type Env = { Bindings: { event: CloudFrontEdgeEvent; }; }
event:
(property) Bindings: { event: CloudFrontEdgeEvent; }
CloudFrontEdgeEvent
(property) event: CloudFrontEdgeEvent
} } export const getConnInfo:
(alias) interface CloudFrontEdgeEvent import CloudFrontEdgeEvent
GetConnInfo =
const getConnInfo: GetConnInfo
(c:
(alias) type GetConnInfo = (c: Context) => ConnInfo import GetConnInfo
Helper typeContext
(parameter) c: Context<Env, any, {}>
<Env>) => ({
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
remote: {
type Env = { Bindings: { event: CloudFrontEdgeEvent; }; }
address:
(property) ConnInfo.remote: NetAddrInfo
Remote informationc
(property) address: string
.env
(parameter) c: Context<Env, any, {}>
(property) Context<Env, any, {}>.env: { event: CloudFrontEdgeEvent; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
.event
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
.Records[0]
(property) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.request
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
.clientIp,
(property) request: CloudFrontRequest
}, })
(property) CloudFrontRequest.clientIp: string
import { encodeBase64 } from '../../utils/encode' import { createBody, isContentTypeBinary } from './handler' describe('isContentTypeBinary', () => { it('Should determine whether it is binary', () => { expect(isContentTypeBinary('image/png')).toBe(true)expect(isContentTypeBinary('font/woff2')).toBe(true)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('image/svg+xml')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('image/svg+xml; charset=UTF-8')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('text/plain')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('text/plain; charset=UTF-8')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('text/css')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('text/javascript')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('application/json')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('application/ld+json')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
expect(isContentTypeBinary('application/json; charset=UTF-8')).toBe(false)
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
}) }) describe('createBody', () => { it('Should the request be a GET or HEAD, the Request must not include a Body', () => { const encoder = new
(alias) isContentTypeBinary(contentType: string): boolean import isContentTypeBinary
TextEncoder()
const encoder: TextEncoder
const data =
var TextEncoder: new () => TextEncoder
TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays.encoder
const data: Uint8Array
.encode('test')
const encoder: TextEncoder
const body = {
(method) TextEncoder.encode(input?: string): Uint8Array
Returns the result of running UTF-8's encoder.action: 'read-only',
const body: { action: string; data: string; encoding: string; inputTruncated: boolean; }
data:
(property) action: string
encodeBase64
(property) data: string
(data),
(alias) encodeBase64(buf: ArrayBufferLike): string import encodeBase64
encoding: 'base64',
const data: Uint8Array
inputTruncated: false,
(property) encoding: string
} expect(createBody('GET',
(property) inputTruncated: boolean
body)).toEqual(undefined)
(alias) createBody(method: string, requestBody: CloudFrontRequest["body"]): string | Uint8Array | undefined import createBody
expect(createBody('GET',
const body: { action: string; data: string; encoding: string; inputTruncated: boolean; }
body)).not.toEqual
(alias) createBody(method: string, requestBody: CloudFrontRequest["body"]): string | Uint8Array | undefined import createBody
(data)
const body: { action: string; data: string; encoding: string; inputTruncated: boolean; }
expect(createBody('HEAD',
const data: Uint8Array
body)).toEqual(undefined)
(alias) createBody(method: string, requestBody: CloudFrontRequest["body"]): string | Uint8Array | undefined import createBody
expect(createBody('HEAD',
const body: { action: string; data: string; encoding: string; inputTruncated: boolean; }
body)).not.toEqual
(alias) createBody(method: string, requestBody: CloudFrontRequest["body"]): string | Uint8Array | undefined import createBody
(data)
const body: { action: string; data: string; encoding: string; inputTruncated: boolean; }
expect(createBody('POST',
const data: Uint8Array
body)).toEqual
(alias) createBody(method: string, requestBody: CloudFrontRequest["body"]): string | Uint8Array | undefined import createBody
(data)
const body: { action: string; data: string; encoding: string; inputTruncated: boolean; }
expect(createBody('POST',
const data: Uint8Array
body)).not.toEqual(undefined)
(alias) createBody(method: string, requestBody: CloudFrontRequest["body"]): string | Uint8Array | undefined import createBody
}) })
const body: { action: string; data: string; encoding: string; inputTruncated: boolean; }
import crypto from 'node:crypto' import type { Hono } from '../../hono' import { decodeBase64, encodeBase64 } from '../../utils/encode' // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore globalThis.crypto ??= cryptointerface CloudFrontHeader {
var crypto: Crypto
MDN Referencekey: string
interface CloudFrontHeader
value: string
(property) CloudFrontHeader.key: string
} interface CloudFrontHeaders {
(property) CloudFrontHeader.value: string
[name: string]:
interface CloudFrontHeaders
CloudFrontHeader[]
(parameter) name: string
} interface CloudFrontCustomOrigin {
interface CloudFrontHeader
customHeaders:
interface CloudFrontCustomOrigin
CloudFrontHeaders
(property) CloudFrontCustomOrigin.customHeaders: CloudFrontHeaders
domainName: string
interface CloudFrontHeaders
keepaliveTimeout: number
(property) CloudFrontCustomOrigin.domainName: string
path: string
(property) CloudFrontCustomOrigin.keepaliveTimeout: number
port: number
(property) CloudFrontCustomOrigin.path: string
protocol: string
(property) CloudFrontCustomOrigin.port: number
readTimeout: number
(property) CloudFrontCustomOrigin.protocol: string
sslProtocols: string[]
(property) CloudFrontCustomOrigin.readTimeout: number
} // https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html interface CloudFrontS3Origin {
(property) CloudFrontCustomOrigin.sslProtocols: string[]
authMethod: 'origin-access-identity' | 'none'
interface CloudFrontS3Origin
customHeaders:
(property) CloudFrontS3Origin.authMethod: "none" | "origin-access-identity"
CloudFrontHeaders
(property) CloudFrontS3Origin.customHeaders: CloudFrontHeaders
domainName: string
interface CloudFrontHeaders
path: string
(property) CloudFrontS3Origin.domainName: string
region: string
(property) CloudFrontS3Origin.path: string
} type CloudFrontOrigin =
(property) CloudFrontS3Origin.region: string
| { s3:
type CloudFrontOrigin = { s3: CloudFrontS3Origin; custom?: never; } | { custom: CloudFrontCustomOrigin; s3?: never; }
CloudFrontS3Origin;
(property) s3: CloudFrontS3Origin
custom?: never }
interface CloudFrontS3Origin
| { custom:
(property) custom?: undefined
CloudFrontCustomOrigin;
(property) custom: CloudFrontCustomOrigin
s3?: never }
interface CloudFrontCustomOrigin
export interface CloudFrontRequest {
(property) s3?: undefined
clientIp: string
interface CloudFrontRequest
headers:
(property) CloudFrontRequest.clientIp: string
CloudFrontHeaders
(property) CloudFrontRequest.headers: CloudFrontHeaders
method: string
interface CloudFrontHeaders
querystring: string
(property) CloudFrontRequest.method: string
uri: string
(property) CloudFrontRequest.querystring: string
body?: {
(property) CloudFrontRequest.uri: string
inputTruncated: boolean
(property) CloudFrontRequest.body?: { inputTruncated: boolean; action: string; encoding: string; data: string; } | undefined
action: string
(property) inputTruncated: boolean
encoding: string
(property) action: string
data: string
(property) encoding: string
} origin?:
(property) data: string
CloudFrontOrigin
(property) CloudFrontRequest.origin?: CloudFrontOrigin | undefined
} export interface CloudFrontResponse {
type CloudFrontOrigin = { s3: CloudFrontS3Origin; custom?: never; } | { custom: CloudFrontCustomOrigin; s3?: never; }
headers:
interface CloudFrontResponse
CloudFrontHeaders
(property) CloudFrontResponse.headers: CloudFrontHeaders
status: string
interface CloudFrontHeaders
statusDescription?: string
(property) CloudFrontResponse.status: string
} export interface CloudFrontConfig {
(property) CloudFrontResponse.statusDescription?: string | undefined
distributionDomainName: string
interface CloudFrontConfig
distributionId: string
(property) CloudFrontConfig.distributionDomainName: string
eventType: string
(property) CloudFrontConfig.distributionId: string
requestId: string
(property) CloudFrontConfig.eventType: string
} interface CloudFrontEvent {
(property) CloudFrontConfig.requestId: string
cf: {
interface CloudFrontEvent
config:
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
CloudFrontConfig
(property) config: CloudFrontConfig
request:
interface CloudFrontConfig
CloudFrontRequest
(property) request: CloudFrontRequest
response?:
interface CloudFrontRequest
CloudFrontResponse
(property) response?: CloudFrontResponse | undefined
} } export interface CloudFrontEdgeEvent {
interface CloudFrontResponse
Records:
interface CloudFrontEdgeEvent
CloudFrontEvent[]
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
} type CloudFrontContext = {}
interface CloudFrontEvent
export interface Callback {
type CloudFrontContext = {}
(err:
interface Callback
Error | null,
(parameter) err: Error | null
result?:
interface Error
CloudFrontRequest |
(parameter) result: CloudFrontRequest | CloudFrontResult | undefined
CloudFrontResult): void
interface CloudFrontRequest
} // https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-generating-http-responses-in-requests.html#lambda-generating-http-responses-programming-model interface CloudFrontResult {
interface CloudFrontResult
status: string
interface CloudFrontResult
statusDescription?: string
(property) CloudFrontResult.status: string
headers?: {
(property) CloudFrontResult.statusDescription?: string | undefined
[header: string]: {
(property) CloudFrontResult.headers?: { [header: string]: { key: string; value: string; }[]; } | undefined
key: string
(parameter) header: string
value: string
(property) key: string
}[] } body?: string
(property) value: string
bodyEncoding?: 'text' | 'base64'
(property) CloudFrontResult.body?: string | undefined
} /** * Accepts events from 'Lambda@Edge' event * https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html */ const convertHeaders =
(property) CloudFrontResult.bodyEncoding?: "text" | "base64" | undefined
(headers:
const convertHeaders: (headers: Headers) => CloudFrontHeaders
Accepts events from 'Lambda@Edge' event https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.htmlHeaders):
(parameter) headers: Headers
CloudFrontHeaders => {
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.const cfHeaders:
interface CloudFrontHeaders
CloudFrontHeaders = {}
const cfHeaders: CloudFrontHeaders
headers
interface CloudFrontHeaders
.forEach(
(parameter) headers: Headers
(value,
(method) Headers.forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void
key) => {
(parameter) value: string
cfHeaders
(parameter) key: string
[key
const cfHeaders: CloudFrontHeaders
.toLowerCase()] = [{
(parameter) key: string
key:
(method) String.toLowerCase(): string
Converts all the alphabetic characters in a string to lowercase.key
(property) CloudFrontHeader.key: string
.toLowerCase(),
(parameter) key: string
value }]
(method) String.toLowerCase(): string
Converts all the alphabetic characters in a string to lowercase.}) return cfHeaders
(property) CloudFrontHeader.value: string
} export const handle = (
const cfHeaders: CloudFrontHeaders
// eslint-disable-next-line @typescript-eslint/no-explicit-any app:
const handle: (app: Hono<any>) => ((event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult>)
Hono
(parameter) app: Hono<any, BlankSchema, "/">
): (( event:
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.CloudFrontEdgeEvent,
(parameter) event: CloudFrontEdgeEvent
context?:
interface CloudFrontEdgeEvent
CloudFrontContext,
(parameter) context: CloudFrontContext | undefined
callback?:
type CloudFrontContext = {}
Callback
(parameter) callback: Callback | undefined
) => Promise
interface Callback
<CloudFrontResult>) => {
interface Promise<T>
Represents the completion of an asynchronous operationreturn async (event,
interface CloudFrontResult
context?,
(parameter) event: CloudFrontEdgeEvent
callback?) => {
(parameter) context: CloudFrontContext | undefined
const res = await
(parameter) callback: Callback | undefined
app
const res: Response
.fetch
(parameter) app: Hono<any, BlankSchema, "/">
(property) Hono<any, BlankSchema, "/">.fetch: (request: Request, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(createRequest(event), {
const createRequest: (event: CloudFrontEdgeEvent) => Request
event,
(parameter) event: CloudFrontEdgeEvent
context,
(property) event: CloudFrontEdgeEvent
callback:
(property) context: CloudFrontContext | undefined
(err:
(property) callback: (err: Error | null, result?: CloudFrontResult | CloudFrontRequest) => void
Error | null,
(parameter) err: Error | null
result?:
interface Error
CloudFrontResult |
(parameter) result: CloudFrontRequest | CloudFrontResult | undefined
CloudFrontRequest) => {
interface CloudFrontResult
callback?.
interface CloudFrontRequest
(err,
(parameter) callback: Callback | undefined
result)
(parameter) err: Error | null
}, config:
(parameter) result: CloudFrontRequest | CloudFrontResult | undefined
event
(property) config: CloudFrontConfig
.Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.config,
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
request:
(property) config: CloudFrontConfig
event
(property) request: CloudFrontRequest
.Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.request,
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
response:
(property) request: CloudFrontRequest
event
(property) response: CloudFrontResponse | undefined
.Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.response,
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
}) return createResult
(property) response?: CloudFrontResponse | undefined
(res)
const createResult: (res: Response) => Promise<CloudFrontResult>
} } const createResult = async
const res: Response
(res:
const createResult: (res: Response) => Promise<CloudFrontResult>
Response):
(parameter) res: Response
Promise
interface Response
This Fetch API interface represents the response to a request.<CloudFrontResult> => {
interface Promise<T>
Represents the completion of an asynchronous operationconst isBase64Encoded =
interface CloudFrontResult
isContentTypeBinary
const isBase64Encoded: boolean
(res
const isContentTypeBinary: (contentType: string) => boolean
.headers
(parameter) res: Response
.get('content-type') || '')
(property) Response.headers: Headers
MDN Referenceconst body =
(method) Headers.get(name: string): string | null
MDN ReferenceisBase64Encoded ?
const body: string
encodeBase64(await
const isBase64Encoded: boolean
res
(alias) encodeBase64(buf: ArrayBufferLike): string import encodeBase64
.arrayBuffer()) : await
(parameter) res: Response
res
(method) Body.arrayBuffer(): Promise<ArrayBuffer>
MDN Reference.text()
(parameter) res: Response
return { status:
(method) Body.text(): Promise<string>
MDN Referenceres
(property) CloudFrontResult.status: string
.status
(parameter) res: Response
.toString(),
(property) Response.status: number
MDN Reference
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
headers:radix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers.convertHeaders
(property) CloudFrontResult.headers?: { [header: string]: { key: string; value: string; }[]; } | undefined
(res
const convertHeaders: (headers: Headers) => CloudFrontHeaders
Accepts events from 'Lambda@Edge' event https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html.headers),
(parameter) res: Response
body,
(property) Response.headers: Headers
MDN Reference...(isBase64Encoded ? {
(property) CloudFrontResult.body?: string | undefined
bodyEncoding: 'base64' } : {}),
const isBase64Encoded: boolean
} } const createRequest =
(property) CloudFrontResult.bodyEncoding?: "text" | "base64" | undefined
(event:
const createRequest: (event: CloudFrontEdgeEvent) => Request
CloudFrontEdgeEvent):
(parameter) event: CloudFrontEdgeEvent
Request => {
interface CloudFrontEdgeEvent
const queryString =
interface Request
This Fetch API interface represents a resource request.event
const queryString: string
.Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.request
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
.querystring
(property) request: CloudFrontRequest
const urlPath = `https://$
(property) CloudFrontRequest.querystring: string
{event
const urlPath: string
.Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.config
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
.distributionDomainName}$
(property) config: CloudFrontConfig
{event
(property) CloudFrontConfig.distributionDomainName: string
.Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.request
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
.uri}`
(property) request: CloudFrontRequest
const url =
(property) CloudFrontRequest.uri: string
queryString ? `$
const url: string
{urlPath}?$
const queryString: string
{queryString}` :
const urlPath: string
urlPath
const queryString: string
const headers = new
const urlPath: string
Headers()
const headers: Headers
Object
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence..entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<CloudFrontHeader[]>(o: { [s: string]: CloudFrontHeader[]; } | ArrayLike<CloudFrontHeader[]>): [string, CloudFrontHeader[]][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(evento
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.request
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
.headers)
(property) request: CloudFrontRequest
.forEach((
(property) CloudFrontRequest.headers: CloudFrontHeaders
(method) Array<[string, CloudFrontHeader[]]>.forEach(callbackfn: (value: [string, CloudFrontHeader[]], index: number, array: [string, CloudFrontHeader[]][]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
[k,thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.v]) => {
(parameter) k: string
v
(parameter) v: CloudFrontHeader[]
.forEach(
(parameter) v: CloudFrontHeader[]
(method) Array<CloudFrontHeader>.forEach(callbackfn: (value: CloudFrontHeader, index: number, array: CloudFrontHeader[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(header) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.headers
(parameter) header: CloudFrontHeader
.set
const headers: Headers
(k,
(method) Headers.set(name: string, value: string): void
MDN Referenceheader
(parameter) k: string
.value))
(parameter) header: CloudFrontHeader
}) const requestBody =
(property) CloudFrontHeader.value: string
event
const requestBody: { inputTruncated: boolean; action: string; encoding: string; data: string; } | undefined
.Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.request
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
.body
(property) request: CloudFrontRequest
const method =
(property) CloudFrontRequest.body?: { inputTruncated: boolean; action: string; encoding: string; data: string; } | undefined
event
const method: string
.Records[0]
(parameter) event: CloudFrontEdgeEvent
.cf
(property) CloudFrontEdgeEvent.Records: CloudFrontEvent[]
.request
(property) CloudFrontEvent.cf: { config: CloudFrontConfig; request: CloudFrontRequest; response?: CloudFrontResponse; }
.method
(property) request: CloudFrontRequest
const body =
(property) CloudFrontRequest.method: string
createBody
const body: string | Uint8Array | undefined
(method,
const createBody: (method: string, requestBody: CloudFrontRequest["body"]) => string | Uint8Array | undefined
requestBody)
const method: string
return new Request
const requestBody: { inputTruncated: boolean; action: string; encoding: string; data: string; } | undefined
(url, {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.headers,
const url: string
method,
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.body,
(property) RequestInit.method?: string | undefined
A string to set request's method.}) } export const createBody = (
(property) RequestInit.body?: BodyInit | null | undefined
A BodyInit object or null to set request's body.method: string,
const createBody: (method: string, requestBody: CloudFrontRequest["body"]) => string | Uint8Array | undefined
requestBody:
(parameter) method: string
CloudFrontRequest['body']
(parameter) requestBody: { inputTruncated: boolean; action: string; encoding: string; data: string; } | undefined
): string | Uint8Array | undefined => {
interface CloudFrontRequest
if (!requestBody ||
interface Uint8Array
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.!requestBody
(parameter) requestBody: { inputTruncated: boolean; action: string; encoding: string; data: string; } | undefined
.data) {
(parameter) requestBody: { inputTruncated: boolean; action: string; encoding: string; data: string; }
return undefined } if (method === 'GET' ||
(property) data: string
method === 'HEAD') {
(parameter) method: string
return undefined } if (requestBody
(parameter) method: string
.encoding === 'base64') {
(parameter) requestBody: { inputTruncated: boolean; action: string; encoding: string; data: string; }
return decodeBase64
(property) encoding: string
(requestBody
(alias) decodeBase64(str: string): Uint8Array import decodeBase64
.data)
(parameter) requestBody: { inputTruncated: boolean; action: string; encoding: string; data: string; }
} return requestBody
(property) data: string
.data
(parameter) requestBody: { inputTruncated: boolean; action: string; encoding: string; data: string; }
} export const isContentTypeBinary =
(property) data: string
(contentType: string): boolean => {
const isContentTypeBinary: (contentType: string) => boolean
return !/^(text\/(plain|html|css|javascript|csv).*|application\/(.*json|.*xml).*|image\/svg\+xml.*)$/.test(
(parameter) contentType: string
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
contentTypestring
— String on which to perform the search.) }
(parameter) contentType: string
/** * @module * Lambda@Edge Adapter for Hono. */ export { handle } from './handler'export { getConnInfo } from './conninfo'
(alias) const handle: (app: Hono<any>) => ((event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult>) export handle
export type { Callback,
(alias) const getConnInfo: GetConnInfo export getConnInfo
CloudFrontConfig,
(alias) interface Callback export Callback
CloudFrontRequest,
(alias) interface CloudFrontConfig export CloudFrontConfig
CloudFrontResponse,
(alias) interface CloudFrontRequest export CloudFrontRequest
CloudFrontEdgeEvent,
(alias) interface CloudFrontResponse export CloudFrontResponse
} from './handler'
(alias) interface CloudFrontEdgeEvent export CloudFrontEdgeEvent
/* eslint-disable @typescript-eslint/no-explicit-any */ import type { Hono } from '../../hono' export const handle = (app:
const handle: (app: Hono<any, any>) => ((req: Request, context: any) => Response | Promise<Response>)
Hono
(parameter) app: Hono<any, any, "/">
): ((req:
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.Request,
(parameter) req: Request
context: any) =>
interface Request
This Fetch API interface represents a resource request.Response |
(parameter) context: any
Promise
interface Response
This Fetch API interface represents the response to a request.<Response>) => {
interface Promise<T>
Represents the completion of an asynchronous operationreturn (req:
interface Response
This Fetch API interface represents the response to a request.Request,
(parameter) req: Request
context: any) => {
interface Request
This Fetch API interface represents a resource request.return app
(parameter) context: any
.fetch
(parameter) app: Hono<any, any, "/">
(property) Hono<any, any, "/">.fetch: (request: Request, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(req, {context })
(parameter) req: Request
} }
(property) context: any
/** * @module * Netlify Adapter for Hono. */ export * from './mod'
export { handle } from './handler' (alias) const handle: (app: Hono<any, any>) => ((req: Request, context: any) => Response | Promise<Response>)
export handle
import { Hono } from '../../hono' import { handle } from './handler' import type { FetchEvent } from './types' describe('handle', () => { it('Success to fetch', async () => { const app = newHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", JSONRespondReturn<{ hello: string; }, StatusCode>, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
hello: 'world' })
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ hello: string; }, StatusCode>(object: { hello: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ hello: string; }, StatusCode> (+1 overload)
}) const handler =
(property) hello: string
handle
const handler: Handler
(app)
(alias) handle(app: Hono, opts?: { fetch?: typeof fetch; }): Handler import handle
Adapter for Service Workerconst json = await new
const app: Hono<BlankEnv, BlankSchema, "/">
Promise
const json: any
var Promise: PromiseConstructor new <Response>(executor: (resolve: (value: Response | PromiseLike<Response>) => void, reject: (reason?: any) => void) => void) => Promise<...>
Creates a new Promise.@param
<Response>(executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.(resolve) => {
interface Response
This Fetch API interface represents the response to a request.handler({
(parameter) resolve: (value: Response | PromiseLike<Response>) => void
request: new
const handler: (evt: FetchEvent) => void
Request('http://localhost/'),
(property) FetchEvent.request: Request
respondWith
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.(res) {
(method) FetchEvent.respondWith(r: Response | PromiseLike<Response>): void
resolve
(parameter) res: Response | PromiseLike<Response>
(res)
(parameter) resolve: (value: Response | PromiseLike<Response>) => void
}, } as FetchEvent)
(parameter) res: Response | PromiseLike<Response>
}).then(
(alias) interface FetchEvent import FetchEvent
(method) Promise<Response>.then<any, never>(onfulfilled?: ((value: Response) => any) | null | undefined, onrejected?: ((reason: any) => PromiseLike<never>) | null | undefined): Promise<any>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(res) =>res
(parameter) res: Response
.json())
(parameter) res: Response
expect(json).toStrictEqual({
(method) Body.json(): Promise<any>
MDN Referencehello: 'world' })
const json: any
}) it('Fallback 404', async () => { const app = new
(property) hello: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const handler =options
— Optional configuration options for the Hono instance.handle
const handler: Handler
(app, {
(alias) handle(app: Hono, opts?: { fetch?: typeof fetch; }): Handler import handle
Adapter for Service Workerasync fetch() {
const app: Hono<BlankEnv, BlankSchema, "/">
return new Response('hello world')
(property) fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
}, }) const text = await new
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.Promise
const text: string
var Promise: PromiseConstructor new <Response>(executor: (resolve: (value: Response | PromiseLike<Response>) => void, reject: (reason?: any) => void) => void) => Promise<...>
Creates a new Promise.@param
<Response>(executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.(resolve) => {
interface Response
This Fetch API interface represents the response to a request.handler({
(parameter) resolve: (value: Response | PromiseLike<Response>) => void
request: new
const handler: (evt: FetchEvent) => void
Request('http://localhost/'),
(property) FetchEvent.request: Request
respondWith
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.(res) {
(method) FetchEvent.respondWith(r: Response | PromiseLike<Response>): void
resolve
(parameter) res: Response | PromiseLike<Response>
(res)
(parameter) resolve: (value: Response | PromiseLike<Response>) => void
}, } as FetchEvent)
(parameter) res: Response | PromiseLike<Response>
}).then(
(alias) interface FetchEvent import FetchEvent
(method) Promise<Response>.then<string, never>(onfulfilled?: ((value: Response) => string | PromiseLike<string>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<never>) | null | undefined): Promise<...>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(res) =>res
(parameter) res: Response
.text())
(parameter) res: Response
expect(text).toBe('hello world')
(method) Body.text(): Promise<string>
MDN Reference}) it('Do not fallback 404 when fetch is undefined', async () => { const app = new
const text: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"Not found", 404, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('Not found', 404))
(parameter) c: Context<BlankEnv, "/", BlankInput>
const handler =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Not found", 404>(text: "Not found", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Not found", 404, "text"> (+1 overload)
handle
const handler: Handler
(app, {
(alias) handle(app: Hono, opts?: { fetch?: typeof fetch; }): Handler import handle
Adapter for Service Workerfetch: undefined,
const app: Hono<BlankEnv, BlankSchema, "/">
}) const result = await new
(property) fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
Promise
const result: Response
var Promise: PromiseConstructor new <Response>(executor: (resolve: (value: Response | PromiseLike<Response>) => void, reject: (reason?: any) => void) => void) => Promise<...>
Creates a new Promise.@param
<Response>(executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.(resolve) =>
interface Response
This Fetch API interface represents the response to a request.handler({
(parameter) resolve: (value: Response | PromiseLike<Response>) => void
request: new
const handler: (evt: FetchEvent) => void
Request('https://localhost/'),
(property) FetchEvent.request: Request
respondWith
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.(r) {
(method) FetchEvent.respondWith(r: Response | PromiseLike<Response>): void
resolve
(parameter) r: Response | PromiseLike<Response>
(r)
(parameter) resolve: (value: Response | PromiseLike<Response>) => void
}, } as FetchEvent)
(parameter) r: Response | PromiseLike<Response>
) expect(result
(alias) interface FetchEvent import FetchEvent
.status).toBe(404)
const result: Response
expect(await result
(property) Response.status: number
MDN Reference.text()).toBe('Not found')
const result: Response
}) })
(method) Body.text(): Promise<string>
MDN Reference
/** * Handler for Service Worker * @module */ import type { Hono } from '../../hono' import type { FetchEvent } from './types' type Handler =(evt:
type Handler = (evt: FetchEvent) => void
FetchEvent) => void
(parameter) evt: FetchEvent
/** * Adapter for Service Worker */ export const handle = (
(alias) interface FetchEvent import FetchEvent
app:
const handle: (app: Hono, opts?: { fetch?: typeof fetch; }) => Handler
Adapter for Service WorkerHono,
(parameter) app: Hono<BlankEnv, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
opts: {BasePath
— The base path type.fetch?: typeof
(parameter) opts: { fetch?: typeof fetch; }
fetch
(property) fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
} = { // To use `fetch` on a Service Worker correctly, first refer to `self.fetch`. fetch: globalThis
function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
MDN Reference.self !== undefined ? globalThis
(property) fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
.self
var self: Window & typeof globalThis
MDN Reference.fetch :
var self: Window & typeof globalThis
MDN Referencefetch,
(method) fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
MDN Reference} ): Handler => {
function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
MDN Referencereturn (evt) => {
type Handler = (evt: FetchEvent) => void
evt
(parameter) evt: FetchEvent
.respondWith(
(parameter) evt: FetchEvent
(async () => { const res = await
(method) FetchEvent.respondWith(r: Response | PromiseLike<Response>): void
app
const res: Response
.fetch
(parameter) app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.fetch: (request: Request, Env?: unknown, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(evt.request)
(parameter) evt: FetchEvent
if (opts
(property) FetchEvent.request: Request
.fetch &&
(parameter) opts: { fetch?: typeof fetch; }
res
(property) fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
.status === 404) {
const res: Response
return await opts
(property) Response.status: number
MDN Reference.fetch
(parameter) opts: { fetch?: typeof fetch; }
(evt
(property) fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
MDN Reference.request)
(parameter) evt: FetchEvent
} return res
(property) FetchEvent.request: Request
})() ) } }
const res: Response
/** * Cloudflare Workers Adapter for Hono. * @module */ export { handle } from './handler'
(alias) const handle: (app: Hono, opts?: { fetch?: typeof fetch; }) => Handler export handle
Adapter for Service Worker
interface ExtendableEvent extendsEvent {
interface ExtendableEvent
// eslint-disable-next-line @typescript-eslint/no-explicit-any waitUntil
interface Event
An event which takes place in the DOM.(f:
(method) ExtendableEvent.waitUntil(f: Promise<any>): void
Promise
(parameter) f: Promise<any>
): void } export interface FetchEvent extends
interface Promise<T>
Represents the completion of an asynchronous operationExtendableEvent {
interface FetchEvent
readonly clientId: string
interface ExtendableEvent
readonly handled:
(property) FetchEvent.clientId: string
Promise
(property) FetchEvent.handled: Promise<undefined>
// eslint-disable-next-line @typescript-eslint/no-explicit-any readonly preloadResponse:
interface Promise<T>
Represents the completion of an asynchronous operationPromise
(property) FetchEvent.preloadResponse: Promise<any>
readonly request:
interface Promise<T>
Represents the completion of an asynchronous operationRequest
(property) FetchEvent.request: Request
readonly resultingClientId: string
interface Request
This Fetch API interface represents a resource request.respondWith
(property) FetchEvent.resultingClientId: string
(r:
(method) FetchEvent.respondWith(r: Response | PromiseLike<Response>): void
Response |
(parameter) r: Response | PromiseLike<Response>
PromiseLike
interface Response
This Fetch API interface represents the response to a request.<Response>): void
interface PromiseLike<T>
}
interface Response
This Fetch API interface represents the response to a request.
import { Context } from '../../context' import { getConnInfo } from './conninfo' describe('getConnInfo', () => { it('Should getConnInfo works', () => { const address =Math
const address: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString()
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
const req = newradix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers.Request('http://localhost/', {
const req: Request
headers: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.'x-real-ip': address,
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) const c = new
const address: string
Context
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const info =
const req: Request
getConnInfo
const info: ConnInfo
(c)
(alias) getConnInfo(c: Context): ConnInfo import getConnInfo
expect(info
const c: Context<any, any, {}>
.remote
const info: ConnInfo
.address).toBe
(property) ConnInfo.remote: NetAddrInfo
Remote information(address)
(property) address?: string | undefined
Host name such as IP Addr}) })
const address: string
import type { GetConnInfo } from '../../helper/conninfo' export const getConnInfo:GetConnInfo =
const getConnInfo: GetConnInfo
(c) => ({
(alias) type GetConnInfo = (c: Context) => ConnInfo import GetConnInfo
Helper typeremote: {
(parameter) c: Context<any, any, {}>
// https://github.com/vercel/vercel/blob/b70bfb5fbf28a4650d4042ce68ca5c636d37cf44/packages/edge/src/edge-headers.ts#L10-L12C32 address:
(property) ConnInfo.remote: NetAddrInfo
Remote informationc
(property) address: string | undefined
.req
(parameter) c: Context<any, any, {}>
.header('x-real-ip'),
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
}, })
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
/* eslint-disable @typescript-eslint/no-explicit-any */ import { Hono } from '../../hono' import { handle } from './handler' describe('Adapter for Next.js', () => { it('Should return 200 response with a `waitUntil` value', async () => { const app = newHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/api/foo', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/api/foo", "/api/foo", Promise<JSONRespondReturn<{ path: string; waitUntil: any; }, StatusCode>>, BlankInput, BlankEnv>(path: "/api/foo", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/api/foo", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/api/foo", BlankInput>
path: '/api/foo',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ path: string; waitUntil: any; }, StatusCode>(object: { path: string; waitUntil: any; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
/** * Checking if the `waitUntil` value is passed. */ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore waitUntil:
(property) path: string
c
(property) waitUntil: any
Checking if thewaitUntil
value is passed..executionCtx
(parameter) c: Context<BlankEnv, "/api/foo", BlankInput>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.executionCtx: ExecutionContext
@see — https://hono.dev/docs/api/context#executionctxThe ExecutionContext associated with the current request.
@throws — Will throw an error if the context does not have an ExecutionContext.
.waitUntil() as any,
(method) ExecutionContext.waitUntil(promise: Promise<unknown>): void
Extends the lifetime of the event callback until the promise is settled.@param
}) }) const handler =promise
— A promise to wait for.handle
const handler: (req: Request, requestContext: FetchEventLike) => Response | Promise<Response>
(app)
(alias) handle(app: Hono<any, any, any>): (req: Request, requestContext: FetchEventLike) => Response | Promise<Response> import handle
const req = new
const app: Hono<BlankEnv, BlankSchema, "/">
Request('http://localhost/api/foo')
const req: Request
const res = await
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.handler
const res: Response
(req, {
const handler: (req: Request, requestContext: FetchEventLike) => Response | Promise<Response>
waitUntil: () => 'waitUntil' } as any)
const req: Request
expect(res
(property) waitUntil: () => string
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
path: '/api/foo',
(method) Body.json(): Promise<any>
MDN ReferencewaitUntil: 'waitUntil',
(property) path: string
}) }) it('Should not use `route()` if path argument is not passed', async () => { const app = new
(property) waitUntil: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/api">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.basePath('/api')options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/api">(path: "/api"): Hono<BlankEnv, BlankSchema, "/api">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
app
ts const api = new Hono().basePath('/api')
.onError(
const app: Hono<BlankEnv, BlankSchema, "/api">
(property) Hono<BlankEnv, BlankSchema, "/api">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/api">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(e) => {
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
throw e
(parameter) e: Error | HTTPResponseError
}) app
(parameter) e: Error | HTTPResponseError
.get('/error', () => {
const app: Hono<BlankEnv, BlankSchema, "/api">
throw new Error('Custom Error')
(property) Hono<BlankEnv, BlankSchema, "/api">.get: HandlerInterface <"/error", "/api/error", never, BlankInput, BlankEnv>(path: "/error", handler: H<BlankEnv, "/api/error", BlankInput, never>) => Hono<...> (+22 overloads)
}) const handler =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
handle
const handler: (req: Request, requestContext: FetchEventLike) => Response | Promise<Response>
(app)
(alias) handle(app: Hono<any, any, any>): (req: Request, requestContext: FetchEventLike) => Response | Promise<Response> import handle
const req = new
const app: Hono<BlankEnv, BlankSchema, "/api">
Request('http://localhost/api/error')
const req: Request
expect(() => handler
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.(req, {
const handler: (req: Request, requestContext: FetchEventLike) => Response | Promise<Response>
waitUntil: () => {},
const req: Request
} as any) ).toThrowError('Custom Error') }) })
(property) waitUntil: () => void
/* eslint-disable @typescript-eslint/no-explicit-any */ import type { Hono } from '../../hono' import type { FetchEventLike } from '../../types' export const handle =(app:
const handle: (app: Hono<any, any, any>) => (req: Request, requestContext: FetchEventLike) => Response | Promise<Response>
Hono
(parameter) app: Hono<any, any, any>
) => (req:
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.Request,
(parameter) req: Request
requestContext:
interface Request
This Fetch API interface represents a resource request.FetchEventLike):
(parameter) requestContext: FetchEventLike
Response |
(alias) class FetchEventLike import FetchEventLike
Promise
interface Response
This Fetch API interface represents the response to a request.<Response> => {
interface Promise<T>
Represents the completion of an asynchronous operationreturn app
interface Response
This Fetch API interface represents the response to a request..fetch
(parameter) app: Hono<any, any, any>
(property) Hono<any, any, any>.fetch: (request: Request, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(req, {},requestContext as any)
(parameter) req: Request
}
(parameter) requestContext: FetchEventLike
/** * @module * Vercel Adapter for Hono. */ export { handle } from './handler'export { getConnInfo } from './conninfo'
(alias) const handle: (app: Hono<any, any, any>) => (req: Request, requestContext: FetchEventLike) => Response | Promise<Response> export handle
(alias) const getConnInfo: GetConnInfo export getConnInfo
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { HttpResponse, http } from 'msw' import { setupServer } from 'msw/node' import { expectTypeOf, vi } from 'vitest' import { upgradeWebSocket } from '../adapter/deno/websocket' import { Hono } from '../hono' import { parse } from '../utils/cookie' import type { Equal, Expect, JSONValue, SimplifyDeepArray } from '../utils/types' import { validator } from '../validator' import { hc } from './client' import type { ClientResponse, InferRequestType, InferResponseType } from './types' describe('Basic - JSON', () => { const app = newHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
.post(
const app: Hono<BlankEnv, BlankSchema, "/">
'/posts', validator('cookie', () => {
(property) Hono<BlankEnv, BlankSchema, "/">.post: HandlerInterface <"/posts", "/posts", JSONRespondReturn<{ success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { id: number; title: string; }; }, StatusCode>, { ...; }, { ...; }, { ...; }, { ...; } & ... 1 more ... & { ...; }, any, any, any, {}>(path: "/posts", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
return {} as { debug: string
(alias) validator<unknown, string, string, "cookie", { debug: string; }, { debug: string; }, string, { in: { cookie: { debug: string; }; }; out: { cookie: { debug: string; }; }; }, any>(target: "cookie", validationFunc: ValidationFunction<Record<string, string>, { ...; }, any, string>): MiddlewareHandler<...> import validator
} }), validator('header', () => {
(property) debug: string
return {} as { 'x-message': string } }), validator('json', () => {
(alias) validator<unknown, "/posts", string, "header", { 'x-message': string; }, { 'x-message': string; }, "/posts", { in: { header: { 'x-message': string; }; }; out: { header: { 'x-message': string; }; }; }, any>(target: "header", validationFunc: ValidationFunction<Record<string, string>, { ...; }, any, "/posts">): MiddlewareHandler<...> import validator
return {} as { id: number
(alias) validator<unknown, "/posts", string, "json", { id: number; title: string; }, { id: number; title: string; }, "/posts", { in: { json: { id: number; title: string; }; }; out: { json: { id: number; title: string; }; }; }, any>(target: "json", validationFunc: ValidationFunction<...>): MiddlewareHandler<...> import validator
title: string
(property) id: number
} }), (c) => {
(property) title: string
return c
(parameter) c: Context<{}, "/posts", { in: { cookie: { debug: string; }; }; out: { cookie: { debug: string; }; }; } & { in: { header: { 'x-message': string; }; }; out: { header: { 'x-message': string; }; }; } & { in: { json: { id: number; title: string; }; }; out: { ...; }; }>
.json({
(parameter) c: Context<{}, "/posts", { in: { cookie: { debug: string; }; }; out: { cookie: { debug: string; }; }; } & { in: { header: { 'x-message': string; }; }; out: { header: { 'x-message': string; }; }; } & { in: { json: { id: number; title: string; }; }; out: { ...; }; }>
success: true,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { id: number; title: string; }; }, StatusCode>(object: { success: boolean; ... 4 more ...; requestBody: { id: number; title: string; }; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
message: 'dummy',
(property) success: boolean
requestContentType: 'dummy',
(property) message: string
requestHono: 'dummy',
(property) requestContentType: string
requestMessage: 'dummy',
(property) requestHono: string
requestBody: {
(property) requestMessage: string
id: 123,
(property) requestBody: { id: number; title: string; }
title: 'dummy',
(property) id: number
}, }) } ) .get('/hello-not-found',
(property) title: string
(c) =>
(property) Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/hello-not-found", "/hello-not-found", Response | Promise<Response>, BlankInput, BlankEnv>(path: "/hello-not-found", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hello-not-found", BlankInput>
.notFound())
(parameter) c: Context<BlankEnv, "/hello-not-found", BlankInput>
(property) Context<BlankEnv, "/hello-not-found", BlankInput>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
.get('/null',
ts app.get('/notfound', (c) => { return c.notFound() })
(c) =>
(property) Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">.get: HandlerInterface <"/null", "/null", JSONRespondReturn<null, StatusCode>, BlankInput, BlankEnv>(path: "/null", handler: H<BlankEnv, "/null", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/null", BlankInput>
.json(null))
(parameter) c: Context<BlankEnv, "/null", BlankInput>
type AppType = typeof
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <null, StatusCode>(object: null, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<null, StatusCode> (+1 overload)
route
type AppType = Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
const server = setupServer(
const route: Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
http.post('http://localhost/posts', async ({ request }) => {
const server: any
const requestContentType =
(parameter) request: any
request.headers.get('content-type')
const requestContentType: any
const requestHono =
(parameter) request: any
request.headers.get('x-hono')
const requestHono: any
const requestMessage =
(parameter) request: any
request.headers.get('x-message')
const requestMessage: any
const requestBody = await
(parameter) request: any
request.json()
const requestBody: any
const payload = {
(parameter) request: any
message: 'Hello!',
const payload: { message: string; success: boolean; requestContentType: any; requestHono: any; requestMessage: any; requestBody: any; }
success: true,
(property) message: string
requestContentType,
(property) success: boolean
requestHono,
(property) requestContentType: any
requestMessage,
(property) requestHono: any
requestBody,
(property) requestMessage: any
} return HttpResponse.json(payload)
(property) requestBody: any
}), http.get('http://localhost/hello-not-found', () => { return HttpResponse.text(null, { status: 404,
const payload: { message: string; success: boolean; requestContentType: any; requestHono: any; requestMessage: any; requestBody: any; }
}) }), http.get('http://localhost/null', () => { return HttpResponse.json(null) }), http.get('http://localhost/api/string', () => { return HttpResponse.json('a-string') }), http.get('http://localhost/api/number', async () => { return HttpResponse.json(37) }), http.get('http://localhost/api/boolean', async () => { return HttpResponse.json(true) }), http.get('http://localhost/api/generic', async () => { return HttpResponse.json(Math
(property) status: number
.random() > 0.5 ?
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.Boolean
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.(Math
var Boolean: BooleanConstructor <number>(value?: number | undefined) => boolean
.random()) :
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.Math
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1..random())
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.}) ) beforeAll(() => server.listen())
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.afterEach(() => server.resetHandlers())
const server: any
afterAll(() => server.close())
const server: any
const payload = {
const server: any
id: 123,
const payload: { id: number; title: string; }
title: 'Hello! Hono!',
(property) id: number
} const client =
(property) title: string
hc
const client: { posts: ClientRequest<{ $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; }
<AppType>('http://localhost', {
(alias) hc<Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & ... 1 more ... & { ...; } import hc
headers: { 'x-hono': 'hono' } })
type AppType = Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
it('Should get 200 response', async () => { const res = await
(property) headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>) | undefined
client.posts.$post(
const res: ClientResponse<{ success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }, StatusCode, "json">
{ json:
const client: { posts: ClientRequest<{ $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; }
payload,
(property) json: { id: number; title: string; }
header: {
const payload: { id: number; title: string; }
'x-message': 'foobar', }, cookie: {
(property) header: { 'x-message': string; }
debug: 'true',
(property) cookie: { debug: string; }
}, }, {} ) expect(res
(property) debug: string
.ok).toBe(true)
const res: ClientResponse<{ success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }, StatusCode, "json">
const data = await
(property) ClientResponse<{ success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }, StatusCode, "json">.ok: boolean
MDN Referenceres
const data: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }
.json()
const res: ClientResponse<{ success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }, StatusCode, "json">
expect(data
(method) ClientResponse<{ success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }, StatusCode, "json">.json(): Promise<{ success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { id: number; title: string; }; }>
MDN Reference.success).toBe(true)
const data: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }
expect(data
(property) success: boolean
.message).toBe('Hello!')
const data: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }
expect(data
(property) message: string
.requestContentType).toBe('application/json')
const data: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }
expect(data
(property) requestContentType: string
.requestHono).toBe('hono')
const data: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }
expect(data
(property) requestHono: string
.requestMessage).toBe('foobar')
const data: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }
expect(data
(property) requestMessage: string
.requestBody).toEqual
const data: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }
(payload)
(property) requestBody: { id: number; title: string; }
}) it('Should get 404 response', async () => { const res = await
const payload: { id: number; title: string; }
client['hello-not-found'].$get()
const res: ClientResponse<{}, StatusCode, string>
expect(res
const client: { posts: ClientRequest<{ $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; }
.status).toBe(404)
const res: ClientResponse<{}, StatusCode, string>
}) it('Should get a `null` content', async () => { const client =
(property) ClientResponse<{}, StatusCode, string>.status: StatusCode
MDN Referencehc
const client: { posts: ClientRequest<{ $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; }
<AppType>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & ... 1 more ... & { ...; } import hc
const res = await
type AppType = Hono<BlankEnv, { "/posts": { $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
client.null.$get()
const res: ClientResponse<null, StatusCode, "json">
const data = await
const client: { posts: ClientRequest<{ $post: { input: { cookie: { debug: string; }; } & { header: { 'x-message': string; }; } & { json: { id: number; title: string; }; }; output: { success: boolean; message: string; requestContentType: string; requestHono: string; requestMessage: string; requestBody: { ...; }; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; }
res
const data: null
.json()
const res: ClientResponse<null, StatusCode, "json">
expectTypeOf(data).toMatchTypeOf
(method) ClientResponse<null, StatusCode, "json">.json(): Promise<null>
MDN Reference() expect(data).toBe(null)
const data: null
}) it('Should have correct types - primitives', async () => { const app = new
const data: null
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/api/string": { $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }; } & { "/api/number": { $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
.get('/api/string',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/api/string", "/api/string", JSONRespondReturn<"a-string", StatusCode>, BlankInput, BlankEnv>(path: "/api/string", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/api/string", BlankInput>
.json('a-string'))
(parameter) c: Context<BlankEnv, "/api/string", BlankInput>
.get('/api/number',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <"a-string", StatusCode>(object: "a-string", status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<"a-string", StatusCode> (+1 overload)
(c) =>
(property) Hono<BlankEnv, { "/api/string": { $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/api/number", "/api/number", JSONRespondReturn<37, StatusCode>, BlankInput, BlankEnv>(path: "/api/number", handler: H<BlankEnv, "/api/number", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/api/number", BlankInput>
.json(37))
(parameter) c: Context<BlankEnv, "/api/number", BlankInput>
.get('/api/boolean',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <37, StatusCode>(object: 37, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<37, StatusCode> (+1 overload)
(c) =>
(property) Hono<BlankEnv, { "/api/string": { $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }; } & { "/api/number": { $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/api/boolean", "/api/boolean", JSONRespondReturn<true, StatusCode>, BlankInput, BlankEnv>(path: "/api/boolean", handler: H<BlankEnv, "/api/boolean", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/api/boolean", BlankInput>
.json(true))
(parameter) c: Context<BlankEnv, "/api/boolean", BlankInput>
.get('/api/generic',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <true, StatusCode>(object: true, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<true, StatusCode> (+1 overload)
(c) =>
(property) Hono<BlankEnv, { "/api/string": { $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }; } & { "/api/number": { $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">.get: HandlerInterface <"/api/generic", "/api/generic", JSONRespondReturn<number | boolean, StatusCode>, BlankInput, BlankEnv>(path: "/api/generic", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/api/generic", BlankInput>
.json
(parameter) c: Context<BlankEnv, "/api/generic", BlankInput>
(Math
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <number | boolean, StatusCode>(object: number | boolean, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
.random() > 0.5 ?
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.Boolean
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.(Math
var Boolean: BooleanConstructor <number>(value?: number | undefined) => boolean
.random()) :
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.Math
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1..random())
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.) type AppType = typeof
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.route
type AppType = Hono<BlankEnv, { "/api/string": { $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }; } & { "/api/number": { $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
const client =
const route: Hono<BlankEnv, { "/api/string": { $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }; } & { "/api/number": { $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
hc
const client: { api: { string: ClientRequest<{ $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { number: ClientRequest<{ $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; } & { ...; }
<AppType>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/api/string": { $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }; } & { "/api/number": { $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & ... 2 more ... & { ...; } import hc
const stringFetch = await
type AppType = Hono<BlankEnv, { "/api/string": { $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }; } & { "/api/number": { $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">
client.api.string.$get()
const stringFetch: ClientResponse<"a-string", StatusCode, "json">
const stringRes = await
const client: { api: { string: ClientRequest<{ $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { number: ClientRequest<{ $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; } & { ...; }
stringFetch
const stringRes: "a-string"
.json()
const stringFetch: ClientResponse<"a-string", StatusCode, "json">
const numberFetch = await
(method) ClientResponse<"a-string", StatusCode, "json">.json(): Promise<"a-string">
MDN Referenceclient.api.number.$get()
const numberFetch: ClientResponse<37, StatusCode, "json">
const numberRes = await
const client: { api: { string: ClientRequest<{ $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { number: ClientRequest<{ $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; } & { ...; }
numberFetch
const numberRes: 37
.json()
const numberFetch: ClientResponse<37, StatusCode, "json">
const booleanFetch = await
(method) ClientResponse<37, StatusCode, "json">.json(): Promise<37>
MDN Referenceclient.api.boolean.$get()
const booleanFetch: ClientResponse<true, StatusCode, "json">
const booleanRes = await
const client: { api: { string: ClientRequest<{ $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { number: ClientRequest<{ $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; } & { ...; }
booleanFetch
const booleanRes: true
.json()
const booleanFetch: ClientResponse<true, StatusCode, "json">
const genericFetch = await
(method) ClientResponse<true, StatusCode, "json">.json(): Promise<true>
MDN Referenceclient.api.generic.$get()
const genericFetch: ClientResponse<number | boolean, StatusCode, "json">
const genericRes = await
const client: { api: { string: ClientRequest<{ $get: { input: {}; output: "a-string"; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { number: ClientRequest<{ $get: { input: {}; output: 37; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; } & { ...; }
genericFetch
const genericRes: number | boolean
.json()
const genericFetch: ClientResponse<number | boolean, StatusCode, "json">
type stringVerify =
(method) ClientResponse<number | boolean, StatusCode, "json">.json(): Promise<number | boolean>
MDN ReferenceExpect
type stringVerify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<'a-string', typeofstringRes>>
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
expect(stringRes).toBe('a-string')
const stringRes: "a-string"
type numberVerify =
const stringRes: "a-string"
Expect
type numberVerify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<37, typeofnumberRes>>
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
expect(numberRes).toBe(37)
const numberRes: 37
type booleanVerify =
const numberRes: 37
Expect
type booleanVerify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<EqualbooleanRes>>
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
expect(booleanRes).toBe(true)
const booleanRes: true
type genericVerify =
const booleanRes: true
Expect
type genericVerify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<EqualgenericRes>>
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
expect(typeof genericRes === 'number' || typeof
const genericRes: number | boolean
genericRes === 'boolean').toBe(true)
const genericRes: number | boolean
// using .text() on json endpoint should return string type textTest =
const genericRes: boolean
Expect
type textTest = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Promise
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
, ReturnType
interface Promise<T>
Represents the completion of an asynchronous operationgenericFetch
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any
Obtain the return type of a function type.text>>>
const genericFetch: ClientResponse<number | boolean, StatusCode, "json">
}) }) describe('Basic - query, queries, form, path params, header and cookie', () => { const app = new
(method) ClientResponse<number | boolean, StatusCode, "json">.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/search": { $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; } & { ...; }, "/">
.get(
const app: Hono<BlankEnv, BlankSchema, "/">
'/search', validator('query', () => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", JSONRespondReturn<{ q: string; tag: string[]; filter: string; }, StatusCode>, { in: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; out: { ...; }; }, { in: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; out: { ...; }; }, any, {}>(path: "/search", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
return {} as { q: string;
(alias) validator<unknown, string, string, "query", { q: string; tag: string[]; filter: string; }, { q: string; tag: string[]; filter: string; }, string, { in: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; out: { ...; }; }, any>(target: "query", validationFunc: ValidationFunction<...>): MiddlewareHandler<...> import validator
tag: string[];
(property) q: string
filter: string }
(property) tag: string[]
}), (c) => {
(property) filter: string
return c
(parameter) c: Context<{}, "/search", { in: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; out: { query: { q: string; tag: string[]; filter: string; }; }; }>
.json({
(parameter) c: Context<{}, "/search", { in: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; out: { query: { q: string; tag: string[]; filter: string; }; }; }>
q: 'fake',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ q: string; tag: string[]; filter: string; }, StatusCode>(object: { q: string; tag: string[]; filter: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
tag: ['fake'],
(property) q: string
filter: 'fake',
(property) tag: string[]
}) } ) .put(
(property) filter: string
'/posts/:id', validator('form', () => {
(property) Hono<BlankEnv, { "/search": { $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">.put: HandlerInterface <"/posts/:id", "/posts/:id", JSONRespondReturn<{ title: string; }, StatusCode>, { in: { form: { title: ParsedFormValue | ParsedFormValue[]; }; }; out: { ...; }; }, { in: { form: { title: ParsedFormValue | ParsedFormValue[]; }; }; out: { ...; }; }, any, {}>(path: "/posts/:id", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
return { title: 'Hello',
(alias) validator<unknown, string, string, "form", { title: string; }, { title: string; }, string, { in: { form: { title: ParsedFormValue | ParsedFormValue[]; }; }; out: { form: { title: string; }; }; }, any>(target: "form", validationFunc: ValidationFunction<...>): MiddlewareHandler<...> import validator
} }), (c) => {
(property) title: string
const data =
(parameter) c: Context<{}, "/posts/:id", { in: { form: { title: ParsedFormValue | ParsedFormValue[]; }; }; out: { form: { title: string; }; }; }>
c
const data: { title: string; }
.req
(parameter) c: Context<{}, "/posts/:id", { in: { form: { title: ParsedFormValue | ParsedFormValue[]; }; }; out: { form: { title: string; }; }; }>
.valid('form')
(property) Context<{}, "/posts/:id", { in: { form: { title: ParsedFormValue | ParsedFormValue[]; }; }; out: { form: { title: string; }; }; }>.req: HonoRequest<"/posts/:id", { form: { title: string; }; }>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id", { form: { title: string; }; }>.valid<"form">(target: "form"): { title: string; }
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
return c.json
(parameter) c: Context<{}, "/posts/:id", { in: { form: { title: ParsedFormValue | ParsedFormValue[]; }; }; out: { form: { title: string; }; }; }>
(data)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ title: string; }, StatusCode>(object: { title: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ title: string; }, StatusCode> (+1 overload)
} ) .get(
const data: { title: string; }
'/header', validator('header', () => {
(property) Hono<BlankEnv, { "/search": { $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">.get: HandlerInterface <"/header", "/header", JSONRespondReturn<{ 'x-message-id': string; }, StatusCode>, { in: { header: { 'x-message-id': string; }; }; out: { header: { 'x-message-id': string; }; }; }, { in: { header: { 'x-message-id': string; }; }; out: { header: { 'x-message-id': string; }; }; }, any, {}>(path: "/header", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
return { 'x-message-id': 'Hello', } }), (c) => {
(alias) validator<unknown, string, string, "header", { 'x-message-id': string; }, { 'x-message-id': string; }, string, { in: { header: { 'x-message-id': string; }; }; out: { header: { 'x-message-id': string; }; }; }, any>(target: "header", validationFunc: ValidationFunction<Record<...>, { ...; }, any, string>): MiddlewareHandler<...> import validator
const data =
(parameter) c: Context<{}, "/header", { in: { header: { 'x-message-id': string; }; }; out: { header: { 'x-message-id': string; }; }; }>
c
const data: { 'x-message-id': string; }
.req
(parameter) c: Context<{}, "/header", { in: { header: { 'x-message-id': string; }; }; out: { header: { 'x-message-id': string; }; }; }>
.valid('header')
(property) Context<{}, "/header", { in: { header: { 'x-message-id': string; }; }; out: { header: { 'x-message-id': string; }; }; }>.req: HonoRequest<"/header", { header: { 'x-message-id': string; }; }>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/header", { header: { 'x-message-id': string; }; }>.valid<"header">(target: "header"): { 'x-message-id': string; }
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
return c.json
(parameter) c: Context<{}, "/header", { in: { header: { 'x-message-id': string; }; }; out: { header: { 'x-message-id': string; }; }; }>
(data)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ 'x-message-id': string; }, StatusCode>(object: { 'x-message-id': string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
} ) .get(
const data: { 'x-message-id': string; }
'/cookie', validator('cookie', () => {
(property) Hono<BlankEnv, { "/search": { $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">.get: HandlerInterface <"/cookie", "/cookie", JSONRespondReturn<{ hello: string; }, StatusCode>, { in: { cookie: { hello: string; }; }; out: { cookie: { hello: string; }; }; }, { in: { cookie: { hello: string; }; }; out: { cookie: { hello: string; }; }; }, any, {}>(path: "/cookie", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
return { hello: 'world',
(alias) validator<unknown, string, string, "cookie", { hello: string; }, { hello: string; }, string, { in: { cookie: { hello: string; }; }; out: { cookie: { hello: string; }; }; }, any>(target: "cookie", validationFunc: ValidationFunction<Record<string, string>, { ...; }, any, string>): MiddlewareHandler<...> import validator
} }), (c) => {
(property) hello: string
const data =
(parameter) c: Context<{}, "/cookie", { in: { cookie: { hello: string; }; }; out: { cookie: { hello: string; }; }; }>
c
const data: { hello: string; }
.req
(parameter) c: Context<{}, "/cookie", { in: { cookie: { hello: string; }; }; out: { cookie: { hello: string; }; }; }>
.valid('cookie')
(property) Context<{}, "/cookie", { in: { cookie: { hello: string; }; }; out: { cookie: { hello: string; }; }; }>.req: HonoRequest<"/cookie", { cookie: { hello: string; }; }>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/cookie", { cookie: { hello: string; }; }>.valid<"cookie">(target: "cookie"): { hello: string; }
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
return c.json
(parameter) c: Context<{}, "/cookie", { in: { cookie: { hello: string; }; }; out: { cookie: { hello: string; }; }; }>
(data)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ hello: string; }, StatusCode>(object: { hello: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ hello: string; }, StatusCode> (+1 overload)
} ) const server = setupServer(
const data: { hello: string; }
http.get('http://localhost/api/search', ({ request }) => {
const server: any
const url = new
(parameter) request: any
URL
const url: URL
(request.url)
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs.const query =
(parameter) request: any
url
const query: string | null
.searchParams
const url: URL
.get('q')
(property) URL.searchParams: URLSearchParams
MDN Referenceconst tag =
(method) URLSearchParams.get(name: string): string | null
Returns the first value associated to the given search parameter.url
const tag: string[]
.searchParams
const url: URL
.getAll('tag')
(property) URL.searchParams: URLSearchParams
MDN Referenceconst filter =
(method) URLSearchParams.getAll(name: string): string[]
Returns all the values association with a given search parameter.url
const filter: string | null
.searchParams
const url: URL
.get('filter')
(property) URL.searchParams: URLSearchParams
MDN Referencereturn HttpResponse.json({ q:
(method) URLSearchParams.get(name: string): string | null
Returns the first value associated to the given search parameter.query,
(property) q: string | null
tag,
const query: string | null
filter,
(property) tag: string[]
}) }), http.get('http://localhost/api/posts', ({ request }) => {
(property) filter: string | null
const url = new
(parameter) request: any
URL
const url: URL
(request.url)
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs.const tags =
(parameter) request: any
url
const tags: string[]
.searchParams
const url: URL
.getAll('tags')
(property) URL.searchParams: URLSearchParams
MDN Referencereturn HttpResponse.json({ tags:
(method) URLSearchParams.getAll(name: string): string[]
Returns all the values association with a given search parameter.tags,
(property) tags: string[]
}) }), http.put('http://localhost/api/posts/123', async ({ request }) => {
const tags: string[]
const buffer = await
(parameter) request: any
request.arrayBuffer()
const buffer: any
// @ts-ignore const string =
(parameter) request: any
String
const string: string
.fromCharCode
var String: StringConstructor
Allows manipulation and formatting of text strings and determination and location of substrings within strings..apply('', new
(method) StringConstructor.fromCharCode(...codes: number[]): string
(method) CallableFunction.apply<string, number[], string>(this: (this: string, ...args: number[]) => string, thisArg: string, args: number[]): string (+1 overload)
Calls the function with the specified object as the this value and the elements of specified array as the arguments.@param
thisArg
— The object to be used as the this object.@param
Uint8Arrayargs
— An array of argument values to be passed to the function.(buffer))
var Uint8Array: Uint8ArrayConstructor new (elements: Iterable<number>) => Uint8Array (+4 overloads)
return HttpResponse.text(string)
const buffer: any
}), http.get('http://localhost/api/header', async ({ request }) => {
const string: string
const message = await
(parameter) request: any
request.headers.get('x-message-id')
const message: any
return HttpResponse.json({ 'x-message-id': message })
(parameter) request: any
}), http.get('http://localhost/api/cookie', async ({ request }) => {
const message: any
const obj =
(parameter) request: any
parse
const obj: Cookie
(request.headers.get('cookie') || '')
(alias) parse(cookie: string, name?: string): Cookie import parse
const value =
(parameter) request: any
obj['hello']
const value: string
return HttpResponse.json({ hello:
const obj: Cookie
value })
(property) hello: string
}) ) beforeAll(() => server.listen())
const value: string
afterEach(() => server.resetHandlers())
const server: any
afterAll(() => server.close())
const server: any
type AppType = typeof
const server: any
route
type AppType = Hono<BlankEnv, { "/search": { $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; } & { ...; }, "/">
const client =
const route: Hono<BlankEnv, { "/search": { $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; } & { ...; }, "/">
hc
const client: { search: ClientRequest<{ $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; } & { ...; }
<AppType>('http://localhost/api')
(alias) hc<Hono<BlankEnv, { "/search": { $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; } & { ...; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & ... 2 more ... & { ...; } import hc
it('Should get 200 response - query', async () => { const res = await
type AppType = Hono<BlankEnv, { "/search": { $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { ...; } & { ...; } & { ...; }, "/">
client.search.$get({
const res: ClientResponse<{ q: string; tag: string[]; filter: string; }, StatusCode, "json">
query: {
const client: { search: ClientRequest<{ $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; } & { ...; }
q: 'foobar',
(property) query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }
tag: ['a', 'b'],
(property) q: string | string[]
// @ts-expect-error filter: undefined,
(property) tag: string | string[]
}, }) expect(res
(property) filter: string | string[]
.status).toBe(200)
const res: ClientResponse<{ q: string; tag: string[]; filter: string; }, StatusCode, "json">
expect(await res
(property) ClientResponse<{ q: string; tag: string[]; filter: string; }, StatusCode, "json">.status: StatusCode
MDN Reference.json()).toEqual({
const res: ClientResponse<{ q: string; tag: string[]; filter: string; }, StatusCode, "json">
q: 'foobar',
(method) ClientResponse<{ q: string; tag: string[]; filter: string; }, StatusCode, "json">.json(): Promise<{ q: string; tag: string[]; filter: string; }>
MDN Referencetag: ['a', 'b'],
(property) q: string
filter: null,
(property) tag: string[]
}) }) it('Should get 200 response - form, params', async () => { const res = await
(property) filter: null
client.posts[':id'].$put({
const res: ClientResponse<{ title: string; }, StatusCode, "json">
form: {
const client: { search: ClientRequest<{ $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; } & { ...; }
title: 'Good Night',
(property) form: { title: ParsedFormValue | ParsedFormValue[]; }
}, param: {
(property) title: ParsedFormValue | ParsedFormValue[]
id: '123',
(property) param: { id: string; }
}, }) expect(res
(property) id: string
.status).toBe(200)
const res: ClientResponse<{ title: string; }, StatusCode, "json">
expect(await res
(property) ClientResponse<{ title: string; }, StatusCode, "json">.status: StatusCode
MDN Reference.text()).toMatch('Good Night')
const res: ClientResponse<{ title: string; }, StatusCode, "json">
}) it('Should get 200 response - header', async () => { const header = {
(method) ClientResponse<{ title: string; }, StatusCode, "json">.text(): Promise<string>
MDN Reference'x-message-id': 'Hello', } const res = await
const header: { 'x-message-id': string; }
client.header.$get({
const res: ClientResponse<{ 'x-message-id': string; }, StatusCode, "json">
header,
const client: { search: ClientRequest<{ $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; } & { ...; }
}) expect(res
(property) header: { 'x-message-id': string; }
.status).toBe(200)
const res: ClientResponse<{ 'x-message-id': string; }, StatusCode, "json">
expect(await res
(property) ClientResponse<{ 'x-message-id': string; }, StatusCode, "json">.status: StatusCode
MDN Reference.json()).toEqual
const res: ClientResponse<{ 'x-message-id': string; }, StatusCode, "json">
(header)
(method) ClientResponse<{ 'x-message-id': string; }, StatusCode, "json">.json(): Promise<{ 'x-message-id': string; }>
MDN Reference}) it('Should get 200 response - cookie', async () => { const cookie = {
const header: { 'x-message-id': string; }
hello: 'world',
const cookie: { hello: string; }
} const res = await
(property) hello: string
client.cookie.$get({
const res: ClientResponse<{ hello: string; }, StatusCode, "json">
cookie,
const client: { search: ClientRequest<{ $get: { input: { query: { q: string | string[]; tag: string | string[]; filter: string | string[]; }; }; output: { q: string; tag: string[]; filter: string; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; } & { ...; } & { ...; }
}) expect(res
(property) cookie: { hello: string; }
.status).toBe(200)
const res: ClientResponse<{ hello: string; }, StatusCode, "json">
expect(await res
(property) ClientResponse<{ hello: string; }, StatusCode, "json">.status: StatusCode
MDN Reference.json()).toEqual
const res: ClientResponse<{ hello: string; }, StatusCode, "json">
(cookie)
(method) ClientResponse<{ hello: string; }, StatusCode, "json">.json(): Promise<{ hello: string; }>
MDN Reference}) }) describe('Form - Multiple Values', () => { const server = setupServer(
const cookie: { hello: string; }
http.post('http://localhost/multiple-values', async ({ request }) => {
const server: any
const data = await
(parameter) request: any
request.formData()
const data: any
return HttpResponse.json(data.getAll('key'))
(parameter) request: any
}) ) beforeAll(() => server.listen())
const data: any
afterEach(() => server.resetHandlers())
const server: any
afterAll(() => server.close())
const server: any
const client =
const server: any
hc('http://localhost/')
const client: { [x: string]: ClientRequest<any>; }
it('Should get 200 response - query', async () => { // @ts-expect-error `client['multiple-values'].$post` is not typed const res = await
(alias) hc<Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions): { [x: string]: ClientRequest<any>; } import hc
client['multiple-values'].$post({
const res: any
form: {
const client: { [x: string]: ClientRequest<any>; }
key: ['foo', 'bar'],
(property) form: { key: string[]; }
}, }) expect(res.status).toBe(200)
(property) key: string[]
expect(await res.json()).toEqual(['foo', 'bar'])
const res: any
}) }) describe('Infer the response/request type', () => { const app = new
const res: any
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
.get(
const app: Hono<BlankEnv, BlankSchema, "/">
'/', validator('query', () => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", JSONRespondReturn<{ id: number; title: string; }, StatusCode>, { in: { query: { name: string | string[]; age: string | string[]; }; }; out: { query: { name: string; age: string; }; }; }, { ...; }, { ...; }, { in: { query: { name: string | string[]; age: string | string[]; }; }; out: { query: { name: string; age: string; }; }; } & ... 1 more ... & { ...; }, any, any, any, {}>(path: "/", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
return { name: 'dummy',
(alias) validator<unknown, string, string, "query", { name: string; age: string; }, { name: string; age: string; }, string, { in: { query: { name: string | string[]; age: string | string[]; }; }; out: { query: { name: string; age: string; }; }; }, any>(target: "query", validationFunc: ValidationFunction<...>): MiddlewareHandler<...> import validator
age: 'dummy',
(property) name: string
} }), validator('header', () => {
(property) age: string
return { 'x-request-id': 'dummy', } }), validator('cookie', () => {
(alias) validator<unknown, "/", string, "header", { 'x-request-id': string; }, { 'x-request-id': string; }, "/", { in: { header: { 'x-request-id': string; }; }; out: { header: { 'x-request-id': string; }; }; }, any>(target: "header", validationFunc: ValidationFunction<Record<string, string>, { ...; }, any, "/">): MiddlewareHandler<...> import validator
return { name: 'dummy',
(alias) validator<unknown, "/", string, "cookie", { name: string; }, { name: string; }, "/", { in: { cookie: { name: string; }; }; out: { cookie: { name: string; }; }; }, any>(target: "cookie", validationFunc: ValidationFunction<Record<string, string>, { name: string; }, any, "/">): MiddlewareHandler<...> import validator
} }), (c) =>
(property) name: string
c
(parameter) c: Context<{}, "/", { in: { query: { name: string | string[]; age: string | string[]; }; }; out: { query: { name: string; age: string; }; }; } & { in: { header: { 'x-request-id': string; }; }; out: { header: { 'x-request-id': string; }; }; } & { ...; }>
.json({
(parameter) c: Context<{}, "/", { in: { query: { name: string | string[]; age: string | string[]; }; }; out: { query: { name: string; age: string; }; }; } & { in: { header: { 'x-request-id': string; }; }; out: { header: { 'x-request-id': string; }; }; } & { ...; }>
id: 123,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ id: number; title: string; }, StatusCode>(object: { id: number; title: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
title: 'Morning!',
(property) id: number
}) ) type AppType = typeof
(property) title: string
route
type AppType = Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
it('Should infer response type the type correctly', () => { const client =
const route: Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { index: ClientRequest<{ $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('/')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const req =
type AppType = Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.index.$get
const req: (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
type Actual =
const client: { index: ClientRequest<{ $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
InferResponseType
type Actual = { id: number; title: string; }
req>
(alias) type InferResponseType<T, U extends StatusCode = StatusCode> = InferEndpointType<T> extends { output: infer O; status: infer S; } ? S extends U ? O : never : never import InferResponseType
type Expected = {
const req: (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
id: number
type Expected = { id: number; title: string; }
title: string
(property) id: number
} type verify =
(property) title: string
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual>>
type Expected = { id: number; title: string; }
}) it('Should infer request type the type correctly', () => { const client =
type Actual = { id: number; title: string; }
hc
const client: { index: ClientRequest<{ $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('/')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const req =
type AppType = Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.index.$get
const req: (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
type Actual =
const client: { index: ClientRequest<{ $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
InferRequestType
type Actual = { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }
req>
(alias) type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never import InferRequestType
type Expected = {
const req: (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
age: string | string[]
type Expected = { age: string | string[]; name: string | string[]; }
name: string | string[]
(property) age: string | string[]
} type verify =
(property) name: string | string[]
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual['query']>>
type Expected = { age: string | string[]; name: string | string[]; }
}) it('Should infer request header type the type correctly', () => { const client =
type Actual = { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }
hc
const client: { index: ClientRequest<{ $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('/')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const req =
type AppType = Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.index.$get
const req: (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
type c = typeof
const client: { index: ClientRequest<{ $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
req
type c = (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
type Actual =
const req: (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
InferRequestType
type Actual = { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }
<c>
(alias) type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never import InferRequestType
type Expected = {
type c = (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
'x-request-id': string } type verify =
type Expected = { 'x-request-id': string; }
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual['header']>>
type Expected = { 'x-request-id': string; }
}) it('Should infer request cookie type the type correctly', () => { const client =
type Actual = { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }
hc
const client: { index: ClientRequest<{ $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('/')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const req =
type AppType = Hono<BlankEnv, { "/": { $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.index.$get
const req: (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
type c = typeof
const client: { index: ClientRequest<{ $get: { input: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }; output: { id: number; title: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
req
type c = (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
type Actual =
const req: (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
InferRequestType
type Actual = { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }
<c>
(alias) type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never import InferRequestType
type Expected = {
type c = (args: { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }, options?: ClientRequestOptions) => Promise<...>
name: string
type Expected = { name: string; }
} type verify =
(property) name: string
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual['cookie']>>
type Expected = { name: string; }
}) describe('Without input', () => { const route =
type Actual = { query: { name: string | string[]; age: string | string[]; }; } & { header: { 'x-request-id': string; }; } & { cookie: { name: string; }; }
app
const route: Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
.get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
type AppType = typeof
(property) ok: boolean
route
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
it('Should infer response type the type correctly', () => { const client =
const route: Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('/')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const req =
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.index.$get
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<{ ok: boolean; }, StatusCode, "json">>
type Actual =
const client: { index: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }
InferResponseType
type Actual = { ok: boolean; }
req>
(alias) type InferResponseType<T, U extends StatusCode = StatusCode> = InferEndpointType<T> extends { output: infer O; status: infer S; } ? S extends U ? O : never : never import InferResponseType
type Expected = {
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<{ ok: boolean; }, StatusCode, "json">>
ok: boolean }
type Expected = { ok: boolean; }
type verify =
(property) ok: boolean
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual>>
type Expected = { ok: boolean; }
}) it('Should infer request type the type correctly', () => { const client =
type Actual = { ok: boolean; }
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('/')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const req =
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.index.$get
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<{ ok: boolean; }, StatusCode, "json">>
type Actual =
const client: { index: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }
InferRequestType
type Actual = {}
req>
(alias) type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never import InferRequestType
type Expected = {}
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<{ ok: boolean; }, StatusCode, "json">>
type verify =
type Expected = {}
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual>>
type Expected = {}
}) }) }) describe('Merge path with `app.route()`', () => { const server = setupServer(
type Actual = {}
http.get('http://localhost/api/search', async () => { return HttpResponse.json({ ok: true,
const server: any
}) }), http.get('http://localhost/api/searchArray', async () => { return HttpResponse.json([ { ok: true,
(property) ok: boolean
}, ]) }), http.get('http://localhost/api/foo', async () => { return HttpResponse.json({ ok: true,
(property) ok: boolean
}) }), http.post('http://localhost/api/bar', async () => { return HttpResponse.json({ ok: true,
(property) ok: boolean
}) }), http.get('http://localhost/v1/book', async () => { return HttpResponse.json({ ok: true,
(property) ok: boolean
}) }) ) beforeAll(() => server.listen())
(property) ok: boolean
afterEach(() => server.resetHandlers())
const server: any
afterAll(() => server.close())
const server: any
type Env = {
const server: any
Bindings: {
type Env = { Bindings: { TOKEN: string; }; }
TOKEN: string
(property) Bindings: { TOKEN: string; }
} } it('Should have correct types', async () => { const api = new
(property) TOKEN: string
Hono
const api: Hono<Env, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance..get('/search',
type Env = { Bindings: { TOKEN: string; }; }
(c) =>
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, Env>(path: "/search", handler: H<Env, "/search", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<Env, "/search", BlankInput>
.json({
(parameter) c: Context<Env, "/search", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
const app = new
(property) ok: boolean
Hono
const app: Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance..route('/api',
type Env = { Bindings: { TOKEN: string; }; }
(method) Hono<Env, BlankSchema, "/">.route<"/api", Env, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">(path: "/api", app: Hono<Env, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api)type AppType = typeof
const api: Hono<Env, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
app
type AppType = Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
const client =
const app: Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
<AppType>('http://localhost')
(alias) hc<Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const res = await
type AppType = Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.api.search.$get()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
const data = await
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
res
const data: { ok: boolean; }
.json()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
type verify =
(method) ClientResponse<{ ok: boolean; }, StatusCode, "json">.json(): Promise<{ ok: boolean; }>
MDN ReferenceExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equaldata
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
.ok>>
const data: { ok: boolean; }
expect(data
(property) ok: boolean
.ok).toBe(true)
const data: { ok: boolean; }
}) it('Should have correct types - basePath() then get()', async () => { const base = new
(property) ok: boolean
Hono
const base: Hono<Env, BlankSchema, "/api">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance..basePath('/api')
type Env = { Bindings: { TOKEN: string; }; }
(method) Hono<Env, BlankSchema, "/">.basePath<"/api">(path: "/api"): Hono<Env, BlankSchema, "/api">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
const app =
ts const api = new Hono().basePath('/api')
base
const app: Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
.get('/search',
const base: Hono<Env, BlankSchema, "/api">
(c) =>
(property) Hono<Env, BlankSchema, "/api">.get: HandlerInterface <"/search", "/api/search", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, Env>(path: "/search", handler: H<Env, "/api/search", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<Env, "/api/search", BlankInput>
.json({
(parameter) c: Context<Env, "/api/search", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
type AppType = typeof
(property) ok: boolean
app
type AppType = Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
const client =
const app: Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
hc
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
<AppType>('http://localhost')
(alias) hc<Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const res = await
type AppType = Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
client.api.search.$get()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
const data = await
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
res
const data: { ok: boolean; }
.json()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
type verify =
(method) ClientResponse<{ ok: boolean; }, StatusCode, "json">.json(): Promise<{ ok: boolean; }>
MDN ReferenceExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equaldata
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
.ok>>
const data: { ok: boolean; }
expect(data
(property) ok: boolean
.ok).toBe(true)
const data: { ok: boolean; }
}) it('Should have correct types - basePath(), route(), get()', async () => { const book = new
(property) ok: boolean
Hono()
const book: Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
const app = new
(property) ok: boolean
Hono()
const app: Hono<BlankEnv, { "/v1/book": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/v1">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.basePath('/v1')options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/v1">(path: "/v1"): Hono<BlankEnv, BlankSchema, "/v1">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
.route('/book',
ts const api = new Hono().basePath('/api')
(method) Hono<BlankEnv, BlankSchema, "/v1">.route<"/book", BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">(path: "/book", app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
book)type AppType = typeof
const book: Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
app
type AppType = Hono<BlankEnv, { "/v1/book": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/v1">
const client =
const app: Hono<BlankEnv, { "/v1/book": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/v1">
hc
const client: { v1: { book: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
<AppType>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/v1/book": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/v1">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const res = await
type AppType = Hono<BlankEnv, { "/v1/book": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/v1">
client.v1.book.$get()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
const data = await
const client: { v1: { book: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
res
const data: { ok: boolean; }
.json()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
type verify =
(method) ClientResponse<{ ok: boolean; }, StatusCode, "json">.json(): Promise<{ ok: boolean; }>
MDN ReferenceExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equaldata
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
.ok>>
const data: { ok: boolean; }
expect(data
(property) ok: boolean
.ok).toBe(true)
const data: { ok: boolean; }
}) it('Should have correct types - with interface', async () => { interface Result {
(property) ok: boolean
ok: boolean
interface Result
okUndefined?: boolean
(property) Result.ok: boolean
} const result:
(property) Result.okUndefined?: boolean | undefined
Result = {
const result: Result
ok: true }
interface Result
const base = new
(property) Result.ok: boolean
Hono
const base: Hono<Env, BlankSchema, "/api">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance..basePath('/api')
type Env = { Bindings: { TOKEN: string; }; }
(method) Hono<Env, BlankSchema, "/">.basePath<"/api">(path: "/api"): Hono<Env, BlankSchema, "/api">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
const app =
ts const api = new Hono().basePath('/api')
base
const app: Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
.get('/search',
const base: Hono<Env, BlankSchema, "/api">
(c) =>
(property) Hono<Env, BlankSchema, "/api">.get: HandlerInterface <"/search", "/api/search", JSONRespondReturn<Result, StatusCode>, BlankInput, Env>(path: "/search", handler: H<Env, "/api/search", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<Env, "/api/search", BlankInput>
.json
(parameter) c: Context<Env, "/api/search", BlankInput>
(result))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <Result, StatusCode>(object: Result, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<Result, StatusCode> (+1 overload)
type AppType = typeof
const result: Result
app
type AppType = Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
const client =
const app: Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
hc
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
<AppType>('http://localhost')
(alias) hc<Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const res = await
type AppType = Hono<Env, { "/api/search": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
client.api.search.$get()
const res: ClientResponse<{ ok: boolean; okUndefined?: boolean | undefined; }, StatusCode, "json">
const data = await
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
res
const data: { ok: boolean; okUndefined?: boolean | undefined; }
.json()
const res: ClientResponse<{ ok: boolean; okUndefined?: boolean | undefined; }, StatusCode, "json">
type verify =
(method) ClientResponse<{ ok: boolean; okUndefined?: boolean | undefined; }, StatusCode, "json">.json(): Promise<{ ok: boolean; okUndefined?: boolean | undefined; }>
MDN ReferenceExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Result, typeof
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
data>>
interface Result
expect(data
const data: { ok: boolean; okUndefined?: boolean | undefined; }
.ok).toBe(true)
const data: { ok: boolean; okUndefined?: boolean | undefined; }
// A few more types only tests interface DeepInterface {
(property) ok: boolean
l2: {
interface DeepInterface
l3:
(property) DeepInterface.l2: { l3: Result; }
Result
(property) l3: Result
} } interface ExtraDeepInterface {
interface Result
l4:
interface ExtraDeepInterface
DeepInterface
(property) ExtraDeepInterface.l4: DeepInterface
} type verifyDeepInterface =
interface DeepInterface
Expect<
type verifyDeepInterface = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
Equal<SimplifyDeepArray
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
<DeepInterface> extends
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.JSONValue ? true : false, true>
interface DeepInterface
> type verifyExtraDeepInterface =
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
Expect<
type verifyExtraDeepInterface = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
Equal<SimplifyDeepArray
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
<ExtraDeepInterface> extends
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.JSONValue ? true : false, true>
interface ExtraDeepInterface
> }) it('Should have correct types - with array of interfaces', async () => { interface Result {
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
ok: boolean
interface Result
okUndefined?: boolean
(property) Result.ok: boolean
} type Results =
(property) Result.okUndefined?: boolean | undefined
Result[]
type Results = Result[]
const results:
interface Result
Results = [{
const results: Results
ok: true }]
type Results = Result[]
const base = new
(property) Result.ok: boolean
Hono
const base: Hono<Env, BlankSchema, "/api">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance..basePath('/api')
type Env = { Bindings: { TOKEN: string; }; }
(method) Hono<Env, BlankSchema, "/">.basePath<"/api">(path: "/api"): Hono<Env, BlankSchema, "/api">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
const app =
ts const api = new Hono().basePath('/api')
base
const app: Hono<Env, { "/api/searchArray": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }[]; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
.get('/searchArray',
const base: Hono<Env, BlankSchema, "/api">
(c) =>
(property) Hono<Env, BlankSchema, "/api">.get: HandlerInterface <"/searchArray", "/api/searchArray", JSONRespondReturn<Results, StatusCode>, BlankInput, Env>(path: "/searchArray", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<Env, "/api/searchArray", BlankInput>
.json
(parameter) c: Context<Env, "/api/searchArray", BlankInput>
(results))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <Results, StatusCode>(object: Results, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<Results, StatusCode> (+1 overload)
type AppType = typeof
const results: Results
app
type AppType = Hono<Env, { "/api/searchArray": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }[]; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
const client =
const app: Hono<Env, { "/api/searchArray": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }[]; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
hc
const client: { api: { searchArray: ClientRequest<{ $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }[]; outputFormat: "json"; status: StatusCode; }; }>; }; }
<AppType>('http://localhost')
(alias) hc<Hono<Env, { "/api/searchArray": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }[]; outputFormat: "json"; status: StatusCode; }; }; }, "/api">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const res = await
type AppType = Hono<Env, { "/api/searchArray": { $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }[]; outputFormat: "json"; status: StatusCode; }; }; }, "/api">
client.api.searchArray.$get()
const res: ClientResponse<{ ok: boolean; okUndefined?: boolean | undefined; }[], StatusCode, "json">
const data = await
const client: { api: { searchArray: ClientRequest<{ $get: { input: {}; output: { ok: boolean; okUndefined?: boolean | undefined; }[]; outputFormat: "json"; status: StatusCode; }; }>; }; }
res
const data: { ok: boolean; okUndefined?: boolean | undefined; }[]
.json()
const res: ClientResponse<{ ok: boolean; okUndefined?: boolean | undefined; }[], StatusCode, "json">
type verify =
(method) ClientResponse<{ ok: boolean; okUndefined?: boolean | undefined; }[], StatusCode, "json">.json(): Promise<{ ok: boolean; okUndefined?: boolean | undefined; }[]>
MDN ReferenceExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Results, typeof
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
data>>
type Results = Result[]
expect(data[0]
const data: { ok: boolean; okUndefined?: boolean | undefined; }[]
.ok).toBe(true)
const data: { ok: boolean; okUndefined?: boolean | undefined; }[]
// A few more types only tests type verifyNestedArrayTyped =
(property) ok: boolean
Expect<
type verifyNestedArrayTyped = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
Equal<SimplifyDeepArray<[string,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Results]> extends
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.JSONValue ? true : false, true>
type Results = Result[]
> type verifyNestedArrayInterfaceArray =
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
Expect<
type verifyNestedArrayInterfaceArray = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
Equal<SimplifyDeepArray<[string,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Result[]]> extends
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.JSONValue ? true : false, true>
interface Result
> type verifyExtraNestedArrayTyped =
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
Expect<
type verifyExtraNestedArrayTyped = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
Equal<SimplifyDeepArray<[string,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Results[]]> extends
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.JSONValue ? true : false, true>
type Results = Result[]
> type verifyExtraNestedArrayInterfaceArray =
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
Expect<
type verifyExtraNestedArrayInterfaceArray = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
Equal<SimplifyDeepArray<[string,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Result[][]]> extends
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.JSONValue ? true : false, true>
interface Result
> }) it('Should allow a Date object and return it as a string', async () => { const app = new
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { datetime: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
.get('/api/foo',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/api/foo", "/api/foo", JSONRespondReturn<{ datetime: Date; }, StatusCode>, BlankInput, BlankEnv>(path: "/api/foo", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/api/foo", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/api/foo", BlankInput>
datetime: new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ datetime: Date; }, StatusCode>(object: { datetime: Date; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
Date() }))
(property) datetime: Date
type AppType = typeof
var Date: DateConstructor new () => Date (+4 overloads)
route
type AppType = Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { datetime: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
const client =
const route: Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { datetime: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { api: { foo: ClientRequest<{ $get: { input: {}; output: { datetime: string; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
<AppType>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { datetime: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const res = await
type AppType = Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { datetime: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.api.foo.$get()
const res: ClientResponse<{ datetime: string; }, StatusCode, "json">
const { datetime } = await
const client: { api: { foo: ClientRequest<{ $get: { input: {}; output: { datetime: string; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
res
const datetime: string
.json()
const res: ClientResponse<{ datetime: string; }, StatusCode, "json">
type verify =
(method) ClientResponse<{ datetime: string; }, StatusCode, "json">.json(): Promise<{ datetime: string; }>
MDN ReferenceExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equaldatetime>>
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
}) describe('Multiple endpoints', () => { const api = new
const datetime: string
Hono()
const api: Hono<BlankEnv, { "/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { "/bar": { $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/foo',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo", "/foo", JSONRespondReturn<{ foo: string; }, StatusCode>, BlankInput, BlankEnv>(path: "/foo", handler: H<BlankEnv, "/foo", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
foo: '' }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ foo: string; }, StatusCode>(object: { foo: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ foo: string; }, StatusCode> (+1 overload)
.post('/bar',
(property) foo: string
(c) =>
(property) Hono<BlankEnv, { "/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">.post: HandlerInterface <"/bar", "/bar", JSONRespondReturn<{ bar: number; }, StatusCode>, BlankInput, BlankEnv>(path: "/bar", handler: H<BlankEnv, "/bar", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/bar", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/bar", BlankInput>
bar: 0 }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ bar: number; }, StatusCode>(object: { bar: number; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ bar: number; }, StatusCode> (+1 overload)
const app = new
(property) bar: number
Hono()
const app: Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; "/api/bar": { $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.route('/api',options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", BlankEnv, { "/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { "/bar": { $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">(path: "/api", app: Hono<...>): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api)type AppType = typeof
const api: Hono<BlankEnv, { "/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; } & { "/bar": { $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
app
type AppType = Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; "/api/bar": { $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
const client =
const app: Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; "/api/bar": { $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { api: { foo: ClientRequest<{ $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { bar: ClientRequest<{ $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
app>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; "/api/bar": { $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & { ...; } import hc
it('Should return correct types - GET /api/foo', async () => { const res = await
const app: Hono<BlankEnv, { "/api/foo": { $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }; "/api/bar": { $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.api.foo.$get()
const res: ClientResponse<{ foo: string; }, StatusCode, "json">
const data = await
const client: { api: { foo: ClientRequest<{ $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { bar: ClientRequest<{ $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
res
const data: { foo: string; }
.json()
const res: ClientResponse<{ foo: string; }, StatusCode, "json">
type verify =
(method) ClientResponse<{ foo: string; }, StatusCode, "json">.json(): Promise<{ foo: string; }>
MDN ReferenceExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equaldata
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
.foo>>
const data: { foo: string; }
}) it('Should return correct types - POST /api/bar', async () => { const res = await
(property) foo: string
client.api.bar.$post()
const res: ClientResponse<{ bar: number; }, StatusCode, "json">
const data = await
const client: { api: { foo: ClientRequest<{ $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { bar: ClientRequest<{ $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
res
const data: { bar: number; }
.json()
const res: ClientResponse<{ bar: number; }, StatusCode, "json">
type verify =
(method) ClientResponse<{ bar: number; }, StatusCode, "json">.json(): Promise<{ bar: number; }>
MDN ReferenceExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equaldata
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
.bar>>
const data: { bar: number; }
}) it('Should work with $url', async () => { const url =
(property) bar: number
client.api.bar
const url: URL
.$url()
const client: { api: { foo: ClientRequest<{ $get: { input: {}; output: { foo: string; }; outputFormat: "json"; status: StatusCode; }; }>; }; } & { api: { bar: ClientRequest<{ $post: { input: {}; output: { bar: number; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
expect(url
(property) $url: (arg?: {} | undefined) => URL
.href).toBe('http://localhost/api/bar')
const url: URL
}) }) describe('With a blank path', () => { const app = new
(property) URL.href: string
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/api/v1">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.basePath('/api/v1')options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/api/v1">(path: "/api/v1"): Hono<BlankEnv, BlankSchema, "/api/v1">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
const routes =
ts const api = new Hono().basePath('/api')
app
const routes: Hono<BlankEnv, { "/api/v1/me": { $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api/v1">
.route(
const app: Hono<BlankEnv, BlankSchema, "/api/v1">
(method) Hono<BlankEnv, BlankSchema, "/api/v1">.route<"/me", BlankEnv, { "/": { $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">(path: "/me", app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
'/me', new Hono()
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.route(options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.route<"", BlankEnv, { "/": { $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">(path: "", app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
'', new Hono()
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('', asyncoptions
— Optional configuration options for the Hono instance.(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"", "/", Promise<JSONRespondReturn<{ name: string; }, StatusCode>>, BlankInput, BlankEnv>(path: "", handler: H<BlankEnv, "/", BlankInput, Promise<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
name: 'hono' })
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ name: string; }, StatusCode>(object: { name: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ name: string; }, StatusCode> (+1 overload)
}) ) ) const client =
(property) name: string
hc
const client: { api: { v1: { me: ClientRequest<{ $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }>; }; }; }
routes>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/api/v1/me": { $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api/v1">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
it('Should infer paths correctly', async () => { // Should not a throw type error const url =
const routes: Hono<BlankEnv, { "/api/v1/me": { $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/api/v1">
client.api.v1.me
const url: URL
.$url()
const client: { api: { v1: { me: ClientRequest<{ $get: { input: {}; output: { name: string; }; outputFormat: "json"; status: StatusCode; }; }>; }; }; }
expectTypeOf<URL>
(property) $url: (arg?: {} | undefined) => URL
(url)
interface URL
The URL interface represents an object providing static methods used for creating object URLs.expect(url
const url: URL
.href).toBe('http://localhost/api/v1/me')
const url: URL
}) }) }) describe('Use custom fetch method', () => { it('Should call the custom fetch method when provided', async () => { const fetchMock = vi.fn()
(property) URL.href: string
MDN Referenceconst api = new
const fetchMock: any
Hono()
const api: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/search',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, BlankEnv>(path: "/search", handler: H<BlankEnv, "/search", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/search", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/search", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
const app = new
(property) ok: boolean
Hono()
const app: Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.route('/api',options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">(path: "/api", app: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api)type AppType = typeof
const api: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
app
type AppType = Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
const client =
const app: Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
<AppType>('http://localhost', {
(alias) hc<Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
fetch:
type AppType = Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
fetchMock })
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
await client.api.search.$get()
const fetchMock: any
expect(fetchMock).toHaveBeenCalledTimes(1)
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
}) it('Should return Response from custom fetch method', async () => { const fetchMock = vi.fn()
const fetchMock: any
const returnValue = new
const fetchMock: any
Response(null, {
const returnValue: Response
status: 200 })
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.fetchMock.mockReturnValueOnce
(property) ResponseInit.status?: number | undefined
(returnValue)
const fetchMock: any
const api = new
const returnValue: Response
Hono()
const api: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/search',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, BlankEnv>(path: "/search", handler: H<BlankEnv, "/search", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/search", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/search", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
const app = new
(property) ok: boolean
Hono()
const app: Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.route('/api',options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">(path: "/api", app: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api)type AppType = typeof
const api: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
app
type AppType = Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
const client =
const app: Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
<AppType>('http://localhost', {
(alias) hc<Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
fetch:
type AppType = Hono<BlankEnv, { "/api/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
fetchMock })
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
const res = await
const fetchMock: any
client.api.search.$get()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
expect(res
const client: { api: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }
.ok).toBe(true)
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
expect(res).toEqual
(property) ClientResponse<{ ok: boolean; }, StatusCode, "json">.ok: boolean
MDN Reference(returnValue)
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
}) }) describe('Use custom fetch (app.request) method', () => { it('Should return Response from app request method', async () => { const app = new
const returnValue: Response
Hono()
const app: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/search',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, BlankEnv>(path: "/search", handler: H<BlankEnv, "/search", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/search", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/search", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
type AppType = typeof
(property) ok: boolean
app
type AppType = Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
const client =
const app: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('', {
(alias) hc<Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
fetch:
type AppType = Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
app
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
.request })
const app: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(property) Hono<BlankEnv, { "/search": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
const res = awaitclient.search.$get()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
expect(res
const client: { search: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }
.ok).toBe(true)
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
}) }) describe('Optional parameters in JSON response', () => { it('Should return the correct type', async () => { const app = new
(property) ClientResponse<{ ok: boolean; }, StatusCode, "json">.ok: boolean
MDN ReferenceHono()
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/',options
— Optional configuration options for the Hono instance.(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", JSONRespondReturn<{ message?: string; }, StatusCode>, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
message: 'foo' } as {
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ message?: string; }, StatusCode>(object: { message?: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
message?: string })
(property) message?: string | undefined
}) type AppType = typeof
(property) message?: string | undefined
app
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
const client =
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('', {
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
fetch:
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
app
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
.request })
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(property) Hono<BlankEnv, { "/": { $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
const res = awaitclient.index.$get()
const res: ClientResponse<{ message?: string | undefined; }, StatusCode, "json">
const data = await
const client: { index: ClientRequest<{ $get: { input: {}; output: { message?: string | undefined; }; outputFormat: "json"; status: StatusCode; }; }>; }
res
const data: { message?: string | undefined; }
.json()
const res: ClientResponse<{ message?: string | undefined; }, StatusCode, "json">
expectTypeOf(data).toEqualTypeOf<{
(method) ClientResponse<{ message?: string | undefined; }, StatusCode, "json">.json(): Promise<{ message?: string | undefined; }>
MDN Referencemessage?: string
const data: { message?: string | undefined; }
}>() }) }) describe('ClientResponse
(property) message?: string | undefined
.json() returns a Union type correctly', () => { const condition = () => trueconst app = new
const condition: () => boolean
Hono()
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { data: string; }; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { message: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/', asyncoptions
— Optional configuration options for the Hono instance.(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Promise<JSONRespondReturn<{ data: string; }, StatusCode> | JSONRespondReturn<{ message: string; }, StatusCode>>, BlankInput, BlankEnv>(path: "/", handler: H<...>) => Hono<...> (+22 overloads)
const ok =
(parameter) c: Context<BlankEnv, "/", BlankInput>
condition()
const ok: boolean
if (ok) {
const condition: () => boolean
return c
const ok: boolean
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
data: 'foo' })
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ data: string; }, StatusCode>(object: { data: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ data: string; }, StatusCode> (+1 overload)
} return c
(property) data: string
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
message: 'error' })
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ message: string; }, StatusCode>(object: { message: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ message: string; }, StatusCode> (+1 overload)
}) const client =
(property) message: string
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: { data: string; }; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { message: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
app>('', {
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: { data: string; }; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { message: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
fetch:
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { data: string; }; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { message: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
app
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
.request })
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { data: string; }; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { message: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(property) Hono<BlankEnv, { "/": { $get: { input: {}; output: { data: string; }; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { message: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
it('Should be a Union type', async () => { const res = awaitclient.index.$get()
const res: ClientResponse<{ data: string; }, StatusCode, "json"> | ClientResponse<{ message: string; }, StatusCode, "json">
const json = await
const client: { index: ClientRequest<{ $get: { input: {}; output: { data: string; }; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { message: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
res
const json: { data: string; } | { message: string; }
.json()
const res: ClientResponse<{ data: string; }, StatusCode, "json"> | ClientResponse<{ message: string; }, StatusCode, "json">
expectTypeOf(json).toEqualTypeOf<{
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.json(): Promise<{ data: string; }> | Promise<{ message: string; }>
MDN Referencedata: string } | {
const json: { data: string; } | { message: string; }
message: string }>()
(property) data: string
}) }) describe('Response with different status codes', () => { const condition = () => true
(property) message: string
const app = new
const condition: () => boolean
Hono()
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/', asyncoptions
— Optional configuration options for the Hono instance.(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Promise<JSONRespondReturn<null, StatusCode> | JSONRespondReturn<{ data: string; }, 200> | JSONRespondReturn<{ message: string; }, 400>>, BlankInput, BlankEnv>(path: "/", handler: H<...>) => Hono<...> (+22 overloads)
const ok =
(parameter) c: Context<BlankEnv, "/", BlankInput>
condition()
const ok: boolean
if (ok) {
const condition: () => boolean
return c
const ok: boolean
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
data: 'foo' }, 200)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ data: string; }, 200>(object: { data: string; }, status?: 200 | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ data: string; }, 200> (+1 overload)
} if (!ok) {
(property) data: string
return c
const ok: false
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
message: 'error' }, 400)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ message: string; }, 400>(object: { message: string; }, status?: 400 | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ message: string; }, 400> (+1 overload)
} return c
(property) message: string
.json(null)
(parameter) c: Context<BlankEnv, "/", BlankInput>
}) const client =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <null, StatusCode>(object: null, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<null, StatusCode> (+1 overload)
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
app>('', {
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
fetch:
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">
app
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
.request })
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">
(property) Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
it('all', async () => { const res = awaitclient.index.$get()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
const json = await
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
res
const json: { data: string; } | { message: string; } | null
.json()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
expectTypeOf(json).toEqualTypeOf<{
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.json(): Promise<null> | Promise<{ data: string; }> | Promise<{ message: string; }>
MDN Referencedata: string } | {
const json: { data: string; } | { message: string; } | null
message: string } | null>()
(property) data: string
}) it('status 200', async () => { const res = await
(property) message: string
client.index.$get()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
if (res
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
.status === 200) {
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
const json = await
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.status: StatusCode
MDN Referenceres
const json: { data: string; } | null
.json()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json">
expectTypeOf(json).toEqualTypeOf<{
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.json(): Promise<null> | Promise<{ data: string; }>
MDN Referencedata: string } | null>()
const json: { data: string; } | null
} }) it('status 400', async () => { const res = await
(property) data: string
client.index.$get()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
if (res
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
.status === 400) {
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
const json = await
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.status: StatusCode
MDN Referenceres
const json: { message: string; } | null
.json()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ message: string; }, 400, "json">
expectTypeOf(json).toEqualTypeOf<{
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.json(): Promise<null> | Promise<{ message: string; }>
MDN Referencemessage: string } | null>()
const json: { message: string; } | null
} }) it('response is ok', async () => { const res = await
(property) message: string
client.index.$get()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
if (res
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
.ok) {
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
const json = await
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.ok: boolean
MDN Referenceres
const json: { data: string; } | null
.json()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json">
expectTypeOf(json).toEqualTypeOf<{
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.json(): Promise<null> | Promise<{ data: string; }>
MDN Referencedata: string } | null>()
const json: { data: string; } | null
} }) it('response is not ok', async () => { const res = await
(property) data: string
client.index.$get()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
if (!res
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
.ok) {
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ data: string; }, 200, "json"> | ClientResponse<{ message: string; }, 400, "json">
const json = await
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.ok: boolean
MDN Referenceres
const json: { message: string; } | null
.json()
const res: ClientResponse<null, StatusCode, "json"> | ClientResponse<{ message: string; }, 400, "json">
expectTypeOf(json).toEqualTypeOf<{
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.json(): Promise<null> | Promise<{ message: string; }>
MDN Referencemessage: string } | null>()
const json: { message: string; } | null
} }) }) describe('Infer the response type with different status codes', () => { const condition = () => true
(property) message: string
const app = new
const condition: () => boolean
Hono()
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/', asyncoptions
— Optional configuration options for the Hono instance.(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Promise<JSONRespondReturn<null, StatusCode> | JSONRespondReturn<{ data: string; }, 200> | JSONRespondReturn<{ message: string; }, 400>>, BlankInput, BlankEnv>(path: "/", handler: H<...>) => Hono<...> (+22 overloads)
const ok =
(parameter) c: Context<BlankEnv, "/", BlankInput>
condition()
const ok: boolean
if (ok) {
const condition: () => boolean
return c
const ok: boolean
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
data: 'foo' }, 200)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ data: string; }, 200>(object: { data: string; }, status?: 200 | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ data: string; }, 200> (+1 overload)
} if (!ok) {
(property) data: string
return c
const ok: false
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
message: 'error' }, 400)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ message: string; }, 400>(object: { message: string; }, status?: 400 | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ message: string; }, 400> (+1 overload)
} return c
(property) message: string
.json(null)
(parameter) c: Context<BlankEnv, "/", BlankInput>
}) const client =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <null, StatusCode>(object: null, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<null, StatusCode> (+1 overload)
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
app>('', {
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
fetch:
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">
app
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
.request })
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">
(property) Hono<BlankEnv, { "/": { $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }; }, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
it('Should infer response type correctly', () => { const req =client.index.$get
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<null, StatusCode, "json"> | ClientResponse<...> | ClientResponse<...>>
type Actual =
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
InferResponseType
type Actual = { data: string; } | { message: string; } | null
req>
(alias) type InferResponseType<T, U extends StatusCode = StatusCode> = InferEndpointType<T> extends { output: infer O; status: infer S; } ? S extends U ? O : never : never import InferResponseType
type Expected =
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<null, StatusCode, "json"> | ClientResponse<...> | ClientResponse<...>>
| { data: string
type Expected = { data: string; } | { message: string; } | null
} | { message: string
(property) data: string
} | null type verify =
(property) message: string
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual>>
type Expected = { data: string; } | { message: string; } | null
}) it('Should infer response type of status 200 correctly', () => { const req =
type Actual = { data: string; } | { message: string; } | null
client.index.$get
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<null, StatusCode, "json"> | ClientResponse<...> | ClientResponse<...>>
type Actual =
const client: { index: ClientRequest<{ $get: { input: {}; output: null; outputFormat: "json"; status: StatusCode; } | { input: {}; output: { data: string; }; outputFormat: "json"; status: 200; } | { ...; }; }>; }
InferResponseType
type Actual = { data: string; } | null
req, 200>
(alias) type InferResponseType<T, U extends StatusCode = StatusCode> = InferEndpointType<T> extends { output: infer O; status: infer S; } ? S extends U ? O : never : never import InferResponseType
type Expected = {
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<null, StatusCode, "json"> | ClientResponse<...> | ClientResponse<...>>
data: string
type Expected = { data: string; } | null
} | null type verify =
(property) data: string
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual>>
type Expected = { data: string; } | null
}) }) describe('$url() with a param option', () => { const app = new
type Actual = { data: string; } | null
Hono()
const app: Hono<BlankEnv, { "/posts/:id/comments": { $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; } & { "/something/:firstId/:secondId/:version?": { ...; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/posts/:id/comments',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id/comments", "/posts/:id/comments", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, BlankEnv>(path: "/posts/:id/comments", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/posts/:id/comments", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/posts/:id/comments", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
.get('/something/:firstId/:secondId/:version?',
(property) ok: boolean
(c) =>
(property) Hono<BlankEnv, { "/posts/:id/comments": { $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/something/:firstId/:secondId/:version?", "/something/:firstId/:secondId/:version?", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, BlankEnv>(path: "/something/:firstId/:secondId/:version?", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/something/:firstId/:secondId/:version?", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/something/:firstId/:secondId/:version?", BlankInput>
ok: true }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
type AppType = typeof
(property) ok: boolean
app
type AppType = Hono<BlankEnv, { "/posts/:id/comments": { $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; } & { "/something/:firstId/:secondId/:version?": { ...; }; }, "/">
const client =
const app: Hono<BlankEnv, { "/posts/:id/comments": { $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; } & { "/something/:firstId/:secondId/:version?": { ...; }; }, "/">
hc
const client: { posts: { ":id": { comments: ClientRequest<{ $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }; } & { something: { ...; }; }
<AppType>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/posts/:id/comments": { $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; } & { "/something/:firstId/:secondId/:version?": { ...; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & { ...; } import hc
it('Should return the correct path - /posts/123/comments', async () => { const url =
type AppType = Hono<BlankEnv, { "/posts/:id/comments": { $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; } & { "/something/:firstId/:secondId/:version?": { ...; }; }, "/">
client.posts[':id'].comments
const url: URL
.$url({
const client: { posts: { ":id": { comments: ClientRequest<{ $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }; } & { something: { ...; }; }
param: {
(property) $url: (arg?: { param: { id: string; }; } | undefined) => URL
id: '123',
(property) param: { id: string; }
}, }) expect(url
(property) id: string
.pathname).toBe('/posts/123/comments')
const url: URL
}) it('Should return the correct path - /posts/:id/comments', async () => { const url =
(property) URL.pathname: string
MDN Referenceclient.posts[':id'].comments
const url: URL
.$url()
const client: { posts: { ":id": { comments: ClientRequest<{ $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }; } & { something: { ...; }; }
expect(url
(property) $url: (arg?: { param: { id: string; }; } | undefined) => URL
.pathname).toBe('/posts/:id/comments')
const url: URL
}) it('Should return the correct path - /something/123/456', async () => { const url =
(property) URL.pathname: string
MDN Referenceclient.something[':firstId'][':secondId'][':version?']
const url: URL
.$url({
const client: { posts: { ":id": { comments: ClientRequest<{ $get: { input: { param: { id: string; }; }; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; }; }; } & { something: { ...; }; }
param: {
(property) $url: (arg?: { param: { firstId: string; } & { secondId: string; } & Record<"version", string | undefined>; } | undefined) => URL
firstId: '123',
(property) param: { firstId: string; } & { secondId: string; } & Record<"version", string | undefined>
secondId: '456',
(property) firstId: string
version: undefined,
(property) secondId: string
}, }) expect(url
(property) version: string | undefined
.pathname).toBe('/something/123/456')
const url: URL
}) }) describe('Client can be awaited', () => { it('Can be awaited without side effects', async () => { const client =
(property) URL.pathname: string
MDN Referencehc('http://localhost')
const client: { [x: string]: ClientRequest<any>; }
const awaited = await
(alias) hc<Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions): { [x: string]: ClientRequest<any>; } import hc
client
const awaited: { [x: string]: ClientRequest<any>; }
expect(awaited).toEqual
const client: { [x: string]: ClientRequest<any>; }
(client)
const awaited: { [x: string]: ClientRequest<any>; }
}) }) describe('Dynamic headers', () => { const app = new
const client: { [x: string]: ClientRequest<any>; }
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/posts": { $post: { input: {}; output: { requestDynamic: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
.post('/posts',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.post: HandlerInterface <"/posts", "/posts", JSONRespondReturn<{ requestDynamic: string; }, StatusCode>, BlankInput, BlankEnv>(path: "/posts", handler: H<BlankEnv, "/posts", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/posts", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/posts", BlankInput>
requestDynamic: 'dummy',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ requestDynamic: string; }, StatusCode>(object: { requestDynamic: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
}) }) type AppType = typeof
(property) requestDynamic: string
route
type AppType = Hono<BlankEnv, { "/posts": { $post: { input: {}; output: { requestDynamic: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
const server = setupServer(
const route: Hono<BlankEnv, { "/posts": { $post: { input: {}; output: { requestDynamic: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
http.post('http://localhost/posts', async ({ request }) => {
const server: any
const requestDynamic =
(parameter) request: any
request.headers.get('x-dynamic')
const requestDynamic: any
const payload = {
(parameter) request: any
requestDynamic,
const payload: { requestDynamic: any; }
} return HttpResponse.json(payload)
(property) requestDynamic: any
}) ) beforeAll(() => server.listen())
const payload: { requestDynamic: any; }
afterEach(() => server.resetHandlers())
const server: any
afterAll(() => server.close())
const server: any
let dynamic = ''
const server: any
const client =
let dynamic: string
hc
const client: { posts: ClientRequest<{ $post: { input: {}; output: { requestDynamic: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
<AppType>('http://localhost', {
(alias) hc<Hono<BlankEnv, { "/posts": { $post: { input: {}; output: { requestDynamic: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
headers: () => ({ 'x-hono': 'hono', 'x-dynamic':
type AppType = Hono<BlankEnv, { "/posts": { $post: { input: {}; output: { requestDynamic: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
dynamic }),
(property) headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>) | undefined
}) it('Should have "x-dynamic": "one"', async () => { dynamic = 'one'
let dynamic: string
const res = await
let dynamic: string
client.posts.$post()
const res: ClientResponse<{ requestDynamic: string; }, StatusCode, "json">
expect(res
const client: { posts: ClientRequest<{ $post: { input: {}; output: { requestDynamic: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
.ok).toBe(true)
const res: ClientResponse<{ requestDynamic: string; }, StatusCode, "json">
const data = await
(property) ClientResponse<{ requestDynamic: string; }, StatusCode, "json">.ok: boolean
MDN Referenceres
const data: { requestDynamic: string; }
.json()
const res: ClientResponse<{ requestDynamic: string; }, StatusCode, "json">
expect(data
(method) ClientResponse<{ requestDynamic: string; }, StatusCode, "json">.json(): Promise<{ requestDynamic: string; }>
MDN Reference.requestDynamic).toEqual('one')
const data: { requestDynamic: string; }
}) it('Should have "x-dynamic": "two"', async () => { dynamic = 'two'
(property) requestDynamic: string
const res = await
let dynamic: string
client.posts.$post()
const res: ClientResponse<{ requestDynamic: string; }, StatusCode, "json">
expect(res
const client: { posts: ClientRequest<{ $post: { input: {}; output: { requestDynamic: string; }; outputFormat: "json"; status: StatusCode; }; }>; }
.ok).toBe(true)
const res: ClientResponse<{ requestDynamic: string; }, StatusCode, "json">
const data = await
(property) ClientResponse<{ requestDynamic: string; }, StatusCode, "json">.ok: boolean
MDN Referenceres
const data: { requestDynamic: string; }
.json()
const res: ClientResponse<{ requestDynamic: string; }, StatusCode, "json">
expect(data
(method) ClientResponse<{ requestDynamic: string; }, StatusCode, "json">.json(): Promise<{ requestDynamic: string; }>
MDN Reference.requestDynamic).toEqual('two')
const data: { requestDynamic: string; }
}) }) describe('RequestInit work as expected', () => { const app = new
(property) requestDynamic: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/credentials": { $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }; } & { "/headers": { $get: { ...; }; }; } & { ...; }, "/">
.get('/credentials',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/credentials", "/credentials", Response & TypedResponse<RequestCredentials, StatusCode, "text">, BlankInput, BlankEnv>(path: "/credentials", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/credentials", BlankInput>
.text('' as
(parameter) c: Context<BlankEnv, "/credentials", BlankInput>
RequestCredentials)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <RequestCredentials, StatusCode>(text: RequestCredentials, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) .get('/headers',
type RequestCredentials = "include" | "omit" | "same-origin"
(c) => {
(property) Hono<BlankEnv, { "/credentials": { $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/headers", "/headers", JSONRespondReturn<Record<string, string>, StatusCode>, BlankInput, BlankEnv>(path: "/headers", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/headers", BlankInput>
.json({} as
(parameter) c: Context<BlankEnv, "/headers", BlankInput>
Record
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <Record<string, string>, StatusCode>(object: Record<string, string>, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
) }) .post('/headers',
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T(c) =>
(property) Hono<BlankEnv, { "/credentials": { $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }; } & { "/headers": { $get: { ...; }; }; }, "/">.post: HandlerInterface <"/headers", "/headers", Response & TypedResponse<"Not found", 404, "text">, BlankInput, BlankEnv>(path: "/headers", handler: H<BlankEnv, "/headers", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/headers", BlankInput>
.text('Not found', 404))
(parameter) c: Context<BlankEnv, "/headers", BlankInput>
type AppType = typeof
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Not found", 404>(text: "Not found", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Not found", 404, "text"> (+1 overload)
route
type AppType = Hono<BlankEnv, { "/credentials": { $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }; } & { "/headers": { $get: { ...; }; }; } & { ...; }, "/">
const server = setupServer(
const route: Hono<BlankEnv, { "/credentials": { $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }; } & { "/headers": { $get: { ...; }; }; } & { ...; }, "/">
http.get('http://localhost/credentials', ({ request }) => {
const server: any
return HttpResponse.text(request.credentials)
(parameter) request: any
}), http.get('http://localhost/headers', ({ request }) => {
(parameter) request: any
const allHeaders:
(parameter) request: any
Record
const allHeaders: Record<string, string>
= {} for (const [k,
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tv] of
const k: any
request.headers.entries()) {
const v: any
allHeaders
(parameter) request: any
[k] =
const allHeaders: Record<string, string>
v
const k: any
} return HttpResponse.json(allHeaders)
const v: any
}), http.post('http://localhost/headers', () => { return HttpResponse.text('Should not be here', { status: 400,
const allHeaders: Record<string, string>
}) }) ) beforeAll(() => server.listen())
(property) status: number
afterEach(() => server.resetHandlers())
const server: any
afterAll(() => server.close())
const server: any
const client =
const server: any
hc
const client: { credentials: ClientRequest<{ $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }>; } & { headers: ClientRequest<...>; }
<AppType>('http://localhost', {
(alias) hc<Hono<BlankEnv, { "/credentials": { $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }; } & { "/headers": { ...; }; } & { ...; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & { ...; } import hc
headers: { 'x-hono': 'fire' },
type AppType = Hono<BlankEnv, { "/credentials": { $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }; } & { "/headers": { $get: { ...; }; }; } & { ...; }, "/">
init: {
(property) headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>) | undefined
(property) init?: RequestInit | undefined
StandardRequestInit
, caution that this take highest priority and could be used to overwrite things that Hono sets for you, likebody | method | headers
.If you want to add some headers, use in
credentials: 'include',headers
instead ofinit
}, }) it('Should overwrite method and fail', async () => { const res = await
(property) RequestInit.credentials?: RequestCredentials | undefined
A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.client.headers.$get(undefined, {
const res: ClientResponse<{ [x: string]: string; }, StatusCode, "json">
init: {
const client: { credentials: ClientRequest<{ $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }>; } & { headers: ClientRequest<...>; }
(property) init?: RequestInit | undefined
StandardRequestInit
, caution that this take highest priority and could be used to overwrite things that Hono sets for you, likebody | method | headers
.If you want to add some headers, use in
method: 'POST' } })headers
instead ofinit
expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..ok).toBe(false)
const res: ClientResponse<{ [x: string]: string; }, StatusCode, "json">
}) it('Should clear headers', async () => { const res = await
(property) ClientResponse<{ [x: string]: string; }, StatusCode, "json">.ok: boolean
MDN Referenceclient.headers.$get(undefined, {
const res: ClientResponse<{ [x: string]: string; }, StatusCode, "json">
init: {
const client: { credentials: ClientRequest<{ $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }>; } & { headers: ClientRequest<...>; }
(property) init?: RequestInit | undefined
StandardRequestInit
, caution that this take highest priority and could be used to overwrite things that Hono sets for you, likebody | method | headers
.If you want to add some headers, use in
headers: undefined } })headers
instead ofinit
expect(res
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers..ok).toBe(true)
const res: ClientResponse<{ [x: string]: string; }, StatusCode, "json">
const data = await
(property) ClientResponse<{ [x: string]: string; }, StatusCode, "json">.ok: boolean
MDN Referenceres
const data: { [x: string]: string; }
.json()
const res: ClientResponse<{ [x: string]: string; }, StatusCode, "json">
expect(data).toEqual({})
(method) ClientResponse<{ [x: string]: string; }, StatusCode, "json">.json(): Promise<{ [x: string]: string; }>
MDN Reference}) it('Should overwrite headers', async () => { const res = await
const data: { [x: string]: string; }
client.headers.$get(undefined, {
const res: ClientResponse<{ [x: string]: string; }, StatusCode, "json">
init: {
const client: { credentials: ClientRequest<{ $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }>; } & { headers: ClientRequest<...>; }
(property) init?: RequestInit | undefined
StandardRequestInit
, caution that this take highest priority and could be used to overwrite things that Hono sets for you, likebody | method | headers
.If you want to add some headers, use in
headers: newheaders
instead ofinit
Headers({ 'x-hono': 'awesome' }) },
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}) expect(res
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence..ok).toBe(true)
const res: ClientResponse<{ [x: string]: string; }, StatusCode, "json">
const data = await
(property) ClientResponse<{ [x: string]: string; }, StatusCode, "json">.ok: boolean
MDN Referenceres
const data: { [x: string]: string; }
.json()
const res: ClientResponse<{ [x: string]: string; }, StatusCode, "json">
expect(data).toEqual({ 'x-hono': 'awesome' })
(method) ClientResponse<{ [x: string]: string; }, StatusCode, "json">.json(): Promise<{ [x: string]: string; }>
MDN Reference}) it('credentials is include', async () => { const res = await
const data: { [x: string]: string; }
client.credentials.$get()
const res: ClientResponse<RequestCredentials, StatusCode, "text">
expect(res
const client: { credentials: ClientRequest<{ $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }>; } & { headers: ClientRequest<...>; }
.ok).toBe(true)
const res: ClientResponse<RequestCredentials, StatusCode, "text">
const data = await
(property) ClientResponse<RequestCredentials, StatusCode, "text">.ok: boolean
MDN Referenceres
const data: "include" | "omit" | "same-origin"
.text()
const res: ClientResponse<RequestCredentials, StatusCode, "text">
expect(data).toEqual('include')
(method) ClientResponse<RequestCredentials, StatusCode, "text">.text(): Promise<"include"> | Promise<"omit"> | Promise<"same-origin">
MDN Reference}) it('deepMerge should works and not unset credentials', async () => { const res = await
const data: "include" | "omit" | "same-origin"
client.credentials.$get(undefined, {
const res: ClientResponse<RequestCredentials, StatusCode, "text">
init: {
const client: { credentials: ClientRequest<{ $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }>; } & { headers: ClientRequest<...>; }
(property) init?: RequestInit | undefined
StandardRequestInit
, caution that this take highest priority and could be used to overwrite things that Hono sets for you, likebody | method | headers
.If you want to add some headers, use in
headers: {headers
instead ofinit
hi: 'hello' } } })
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.expect(res
(property) hi: string
.ok).toBe(true)
const res: ClientResponse<RequestCredentials, StatusCode, "text">
const data = await
(property) ClientResponse<RequestCredentials, StatusCode, "text">.ok: boolean
MDN Referenceres
const data: "include" | "omit" | "same-origin"
.text()
const res: ClientResponse<RequestCredentials, StatusCode, "text">
expect(data).toEqual('include')
(method) ClientResponse<RequestCredentials, StatusCode, "text">.text(): Promise<"include"> | Promise<"omit"> | Promise<"same-origin">
MDN Reference}) it('Should unset credentials', async () => { const res = await
const data: "include" | "omit" | "same-origin"
client.credentials.$get(undefined, {
const res: ClientResponse<RequestCredentials, StatusCode, "text">
init: {
const client: { credentials: ClientRequest<{ $get: { input: {}; output: RequestCredentials; outputFormat: "text"; status: StatusCode; }; }>; } & { headers: ClientRequest<...>; }
(property) init?: RequestInit | undefined
StandardRequestInit
, caution that this take highest priority and could be used to overwrite things that Hono sets for you, likebody | method | headers
.If you want to add some headers, use in
credentials: undefined } })headers
instead ofinit
expect(res
(property) RequestInit.credentials?: RequestCredentials | undefined
A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials..ok).toBe(true)
const res: ClientResponse<RequestCredentials, StatusCode, "text">
const data = await
(property) ClientResponse<RequestCredentials, StatusCode, "text">.ok: boolean
MDN Referenceres
const data: "include" | "omit" | "same-origin"
.text()
const res: ClientResponse<RequestCredentials, StatusCode, "text">
expect(data).toEqual('same-origin')
(method) ClientResponse<RequestCredentials, StatusCode, "text">.text(): Promise<"include"> | Promise<"omit"> | Promise<"same-origin">
MDN Reference}) }) describe('WebSocket URL Protocol Translation', () => { const app = new
const data: "include" | "omit" | "same-origin"
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.get(
const app: Hono<BlankEnv, BlankSchema, "/">
'/', upgradeWebSocket(
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, { outputFormat: "ws"; }, any>(path: "/", handler: H<any, "/", { outputFormat: "ws"; }, HandlerResponse<any>>) => Hono<...> (+22 overloads)
(c) => ({
(alias) upgradeWebSocket(createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>, options?: UpgradeWebSocketOptions | undefined): MiddlewareHandler<any, string, { outputFormat: "ws"; }> import upgradeWebSocket
onMessage
(parameter) c: Context<any, any, {}>
(event,
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
ws) {
(parameter) event: MessageEvent<WSMessageReceive>
console
(parameter) ws: WSContext<WebSocket>
.log(`Message from client: $
var console: Console
{event
(method) Console.log(...data: any[]): void
MDN Reference.data}`)
(parameter) event: MessageEvent<WSMessageReceive>
ws
(property) MessageEvent<WSMessageReceive>.data: WSMessageReceive
Returns the data of the message..send('Hello from server!')
(parameter) ws: WSContext<WebSocket>
}, onClose: () => {
(method) send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void
console
(property) WSEvents<WebSocket>.onClose?: ((evt: CloseEvent, ws: WSContext<WebSocket>) => void) | undefined
.log('Connection closed')
var console: Console
}, })) ) type AppType = typeof
(method) Console.log(...data: any[]): void
MDN Referenceroute
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
const server = setupServer()
const route: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
const webSocketMock = vi.fn()
const server: any
beforeAll(() => server.listen())
const webSocketMock: any
beforeEach(() => { vi.stubGlobal('WebSocket', webSocketMock)
const server: any
}) afterEach(() => { vi.clearAllMocks() server.resetHandlers()
const webSocketMock: any
}) afterAll(() => server.close())
const server: any
it('Translates HTTP to ws', async () => { const client =
const server: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
client.index
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.$ws()
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
expect(webSocketMock).toHaveBeenCalledWith('ws://localhost/index')
(property) $ws: (args?: {} | undefined) => WebSocket
}) it('Translates HTTPS to wss', async () => { const client =
const webSocketMock: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>('https://localhost')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
client.index
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.$ws()
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
expect(webSocketMock).toHaveBeenCalledWith('wss://localhost/index')
(property) $ws: (args?: {} | undefined) => WebSocket
}) it('Keeps ws unchanged', async () => { const client =
const webSocketMock: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>('ws://localhost')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
client.index
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.$ws()
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
expect(webSocketMock).toHaveBeenCalledWith('ws://localhost/index')
(property) $ws: (args?: {} | undefined) => WebSocket
}) it('Keeps wss unchanged', async () => { const client =
const webSocketMock: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>('wss://localhost')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
client.index
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.$ws()
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
expect(webSocketMock).toHaveBeenCalledWith('wss://localhost/index')
(property) $ws: (args?: {} | undefined) => WebSocket
}) }) describe('WebSocket URL Protocol Translation with Query Parameters', () => { const app = new
const webSocketMock: any
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.get(
const app: Hono<BlankEnv, BlankSchema, "/">
'/', upgradeWebSocket(
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, { outputFormat: "ws"; }, any>(path: "/", handler: H<any, "/", { outputFormat: "ws"; }, HandlerResponse<any>>) => Hono<...> (+22 overloads)
(c) => ({
(alias) upgradeWebSocket(createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>, options?: UpgradeWebSocketOptions | undefined): MiddlewareHandler<any, string, { outputFormat: "ws"; }> import upgradeWebSocket
onMessage
(parameter) c: Context<any, any, {}>
(event,
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
ws) {
(parameter) event: MessageEvent<WSMessageReceive>
ws
(parameter) ws: WSContext<WebSocket>
.send('Hello from server!')
(parameter) ws: WSContext<WebSocket>
}, onClose: () => {
(method) send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void
console
(property) WSEvents<WebSocket>.onClose?: ((evt: CloseEvent, ws: WSContext<WebSocket>) => void) | undefined
.log('Connection closed')
var console: Console
}, })) ) type AppType = typeof
(method) Console.log(...data: any[]): void
MDN Referenceroute
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
const server = setupServer()
const route: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
const webSocketMock = vi.fn()
const server: any
beforeAll(() => server.listen())
const webSocketMock: any
beforeEach(() => { vi.stubGlobal('WebSocket', webSocketMock)
const server: any
}) afterEach(() => { vi.clearAllMocks() server.resetHandlers()
const webSocketMock: any
}) afterAll(() => server.close())
const server: any
it('Translates HTTP to ws and includes query parameters', async () => { const client =
const server: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
client.index
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.$ws({
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
query: {
(property) $ws: (args?: {} | undefined) => WebSocket
id: '123',
(property) query: { id: string; type: string; tag: string[]; }
type: 'test',
(property) id: string
tag: ['a', 'b'],
(property) type: string
}, }) expect(webSocketMock).toHaveBeenCalledWith('ws://localhost/index?id=123&type=test&tag=a&tag=b')
(property) tag: string[]
}) it('Translates HTTPS to wss and includes query parameters', async () => { const client =
const webSocketMock: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>('https://localhost')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
client.index
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.$ws({
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
query: {
(property) $ws: (args?: {} | undefined) => WebSocket
id: '456',
(property) query: { id: string; type: string; }
type: 'secure',
(property) id: string
}, }) expect(webSocketMock).toHaveBeenCalledWith('wss://localhost/index?id=456&type=secure')
(property) type: string
}) it('Keeps ws unchanged and includes query parameters', async () => { const client =
const webSocketMock: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>('ws://localhost')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
client.index
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.$ws({
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
query: {
(property) $ws: (args?: {} | undefined) => WebSocket
id: '789',
(property) query: { id: string; type: string; }
type: 'plain',
(property) id: string
}, }) expect(webSocketMock).toHaveBeenCalledWith('ws://localhost/index?id=789&type=plain')
(property) type: string
}) it('Keeps wss unchanged and includes query parameters', async () => { const client =
const webSocketMock: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>('wss://localhost')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
client.index
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.$ws({
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
query: {
(property) $ws: (args?: {} | undefined) => WebSocket
id: '1011',
(property) query: { id: string; type: string; }
type: 'secure',
(property) id: string
}, }) expect(webSocketMock).toHaveBeenCalledWith('wss://localhost/index?id=1011&type=secure')
(property) type: string
}) }) describe('Client can be console.log in react native', () => { it('Returns a function name with function.name.toString', async () => { const client =
const webSocketMock: any
hc('http://localhost')
const client: { [x: string]: ClientRequest<any>; }
// @ts-ignore expect(client.posts.name.toString()).toEqual('posts')
(alias) hc<Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions): { [x: string]: ClientRequest<any>; } import hc
}) it('Returns a function name with function.name.valueOf', async () => { const client =
const client: { [x: string]: ClientRequest<any>; }
hc('http://localhost')
const client: { [x: string]: ClientRequest<any>; }
// @ts-ignore expect(client.posts.name.valueOf()).toEqual('posts')
(alias) hc<Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions): { [x: string]: ClientRequest<any>; } import hc
}) it('Returns a function with function.valueOf', async () => { const client =
const client: { [x: string]: ClientRequest<any>; }
hc('http://localhost')
const client: { [x: string]: ClientRequest<any>; }
expect(typeof client.posts
(alias) hc<Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions): { [x: string]: ClientRequest<any>; } import hc
.valueOf()).toEqual('function')
const client: { [x: string]: ClientRequest<any>; }
}) it('Returns a function source with function.toString', async () => { const client =
(method) Object.valueOf(): Object
Returns the primitive value of the specified object.hc('http://localhost')
const client: { [x: string]: ClientRequest<any>; }
expect(client.posts
(alias) hc<Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions): { [x: string]: ClientRequest<any>; } import hc
.toString()).toMatch('function proxyCallback')
const client: { [x: string]: ClientRequest<any>; }
}) }) describe('Text response', () => { const text = 'My name is Hono'
(method) Object.toString(): string
Returns a string representation of an object.const obj = {
const text: "My name is Hono"
ok: true }
const obj: { ok: boolean; }
const server = setupServer(
(property) ok: boolean
http.get('http://localhost/about/me', async () => { return HttpResponse.text(text)
const server: any
}), http.get('http://localhost/api', async ({ request }) => {
const text: "My name is Hono"
return HttpResponse.json(obj)
(parameter) request: any
}) ) beforeAll(() => server.listen())
const obj: { ok: boolean; }
afterEach(() => server.resetHandlers())
const server: any
afterAll(() => server.close())
const server: any
const app = new
const server: any
Hono()
const app: Hono<BlankEnv, { "/about/me": { $get: { input: {}; output: "My name is Hono"; outputFormat: "text"; status: StatusCode; }; }; } & { "/api": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/about/me',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/about/me", "/about/me", Response & TypedResponse<"My name is Hono", StatusCode, "text">, BlankInput, BlankEnv>(path: "/about/me", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/about/me", BlankInput>
.text
(parameter) c: Context<BlankEnv, "/about/me", BlankInput>
(text))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"My name is Hono", StatusCode>(text: "My name is Hono", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/api',
const text: "My name is Hono"
(c) =>
(property) Hono<BlankEnv, { "/about/me": { $get: { input: {}; output: "My name is Hono"; outputFormat: "text"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/api", "/api", JSONRespondReturn<{ ok: boolean; }, StatusCode>, BlankInput, BlankEnv>(path: "/api", handler: H<BlankEnv, "/api", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/api", BlankInput>
.json
(parameter) c: Context<BlankEnv, "/api", BlankInput>
(obj))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, StatusCode>(object: { ok: boolean; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, StatusCode> (+1 overload)
const client =
const obj: { ok: boolean; }
hc
const client: { api: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; }
app>('http://localhost/')
(alias) hc<Hono<BlankEnv, { "/about/me": { $get: { input: {}; output: "My name is Hono"; outputFormat: "text"; status: StatusCode; }; }; } & { "/api": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & { ...; } import hc
it('Should be never with res.json() - /about/me', async () => { const res = await
const app: Hono<BlankEnv, { "/about/me": { $get: { input: {}; output: "My name is Hono"; outputFormat: "text"; status: StatusCode; }; }; } & { "/api": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client.about.me.$get()
const res: ClientResponse<"My name is Hono", StatusCode, "text">
type Actual =
const client: { api: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; }
ReturnType
type Actual = Promise<never>
res
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any
Obtain the return type of a function type.json>
const res: ClientResponse<"My name is Hono", StatusCode, "text">
type Expected =
(method) ClientResponse<"My name is Hono", StatusCode, "text">.json(): Promise<never>
MDN ReferencePromise
type Expected = Promise<never>
type verify =
interface Promise<T>
Represents the completion of an asynchronous operationExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual>>
type Expected = Promise<never>
}) it('Should be "Hello, World!" with res.text() - /about/me', async () => { const res = await
type Actual = Promise<never>
client.about.me.$get()
const res: ClientResponse<"My name is Hono", StatusCode, "text">
const data = await
const client: { api: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; }
res
const data: "My name is Hono"
.text()
const res: ClientResponse<"My name is Hono", StatusCode, "text">
expectTypeOf(data).toEqualTypeOf<'My name is Hono'>()
(method) ClientResponse<"My name is Hono", StatusCode, "text">.text(): Promise<"My name is Hono">
MDN Referenceexpect(data).toBe
const data: "My name is Hono"
(text)
const data: "My name is Hono"
}) /** * Also check the type of JSON response with res.text(). */ it('Should be string with res.text() - /api', async () => { const res = await
const text: "My name is Hono"
client.api.$get()
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
type Actual =
const client: { api: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: StatusCode; }; }>; } & { ...; }
ReturnType
type Actual = Promise<string>
res
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any
Obtain the return type of a function type.text>
const res: ClientResponse<{ ok: boolean; }, StatusCode, "json">
type Expected =
(method) ClientResponse<{ ok: boolean; }, StatusCode, "json">.text(): Promise<string>
MDN ReferencePromise
type Expected = Promise<string>
type verify =
interface Promise<T>
Represents the completion of an asynchronous operationExpect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual>>
type Expected = Promise<string>
}) }) describe('Redirect response - only types', () => { const server = setupServer(
type Actual = Promise<string>
http.get('http://localhost/', async () => { return HttpResponse.redirect('/') }) ) beforeAll(() => server.listen())
const server: any
afterEach(() => server.resetHandlers())
const server: any
afterAll(() => server.close())
const server: any
const condition = () => true
const server: any
const app = new
const condition: () => boolean
Hono()
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: 200; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 302; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 301; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/', asyncoptions
— Optional configuration options for the Hono instance.(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Promise<JSONRespondReturn<{ ok: boolean; }, 200> | (Response & TypedResponse<undefined, 302, "redirect">) | (Response & TypedResponse<...>)>, BlankInput, BlankEnv>(path: "/", handler: H<...>) => Hono<...> (+22 overloads)
const ok =
(parameter) c: Context<BlankEnv, "/", BlankInput>
condition()
const ok: boolean
const temporary =
const condition: () => boolean
condition()
const temporary: boolean
if (ok) {
const condition: () => boolean
return c
const ok: boolean
.json({
(parameter) c: Context<BlankEnv, "/", BlankInput>
ok: true }, 200)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ ok: boolean; }, 200>(object: { ok: boolean; }, status?: 200 | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ ok: boolean; }, 200> (+1 overload)
} if (temporary) {
(property) ok: boolean
return c
const temporary: boolean
.redirect('/302')
(parameter) c: Context<BlankEnv, "/", BlankInput>
(property) Context<BlankEnv, "/", BlankInput>.redirect: <302>(location: string, status?: 302 | undefined) => Response & TypedResponse<undefined, 302, "redirect">
.redirect()
can Redirect, default status code is 302.@see — https://hono.dev/docs/api/context#redirect
@example
} return c
ts app.get('/redirect', (c) => { return c.redirect('/') }) app.get('/redirect-permanently', (c) => { return c.redirect('/', 301) })
.redirect('/301', 301)
(parameter) c: Context<BlankEnv, "/", BlankInput>
(property) Context<BlankEnv, "/", BlankInput>.redirect: <301>(location: string, status?: 301 | undefined) => Response & TypedResponse<undefined, 301, "redirect">
.redirect()
can Redirect, default status code is 302.@see — https://hono.dev/docs/api/context#redirect
@example
}) const client =
ts app.get('/redirect', (c) => { return c.redirect('/') }) app.get('/redirect-permanently', (c) => { return c.redirect('/', 301) })
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: 200; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 302; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 301; }; }>; }
app>('http://localhost/')
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: 200; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 302; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 301; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const req =
const app: Hono<BlankEnv, { "/": { $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: 200; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 302; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 301; }; }; }, "/">
client.index.$get
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<{ ok: boolean; }, 200, "json"> | ClientResponse<...> | ClientResponse<...>>
it('Should infer request type the type correctly', () => { type Actual =
const client: { index: ClientRequest<{ $get: { input: {}; output: { ok: boolean; }; outputFormat: "json"; status: 200; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 302; } | { input: {}; output: undefined; outputFormat: "redirect"; status: 301; }; }>; }
InferResponseType
type Actual = { ok: boolean; } | undefined
req>
(alias) type InferResponseType<T, U extends StatusCode = StatusCode> = InferEndpointType<T> extends { output: infer O; status: infer S; } ? S extends U ? O : never : never import InferResponseType
type Expected =
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<{ ok: boolean; }, 200, "json"> | ClientResponse<...> | ClientResponse<...>>
| { ok: boolean
type Expected = { ok: boolean; } | undefined
} | undefined type verify =
(property) ok: boolean
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected,
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
Actual>>
type Expected = { ok: boolean; } | undefined
}) it('Should infer response type correctly', async () => { const res = await
type Actual = { ok: boolean; } | undefined
req()
const res: ClientResponse<{ ok: boolean; }, 200, "json"> | ClientResponse<undefined, 302, "redirect"> | ClientResponse<undefined, 301, "redirect">
if (res
const req: (args?: {} | undefined, options?: ClientRequestOptions) => Promise<ClientResponse<{ ok: boolean; }, 200, "json"> | ClientResponse<...> | ClientResponse<...>>
.ok) {
const res: ClientResponse<{ ok: boolean; }, 200, "json"> | ClientResponse<undefined, 302, "redirect"> | ClientResponse<undefined, 301, "redirect">
const data = await
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.ok: boolean
MDN Referenceres
const data: { ok: boolean; }
.json()
const res: ClientResponse<{ ok: boolean; }, 200, "json">
expectTypeOf(data).toMatchTypeOf({
(method) ClientResponse<{ ok: boolean; }, 200, "json">.json(): Promise<{ ok: boolean; }>
MDN Referenceok: true })
const data: { ok: boolean; }
} if (res
(property) ok: boolean
.status === 301) {
const res: ClientResponse<{ ok: boolean; }, 200, "json"> | ClientResponse<undefined, 302, "redirect"> | ClientResponse<undefined, 301, "redirect">
type Expected =
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.status: 200 | 301 | 302
MDN ReferenceClientResponse
type Expected = ClientResponse<undefined, 301, "redirect">
type verify =
(alias) interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string> import ClientResponse
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected, typeof
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
res>>
type Expected = ClientResponse<undefined, 301, "redirect">
} if (res
const res: ClientResponse<undefined, 301, "redirect">
.status === 302) {
const res: ClientResponse<{ ok: boolean; }, 200, "json"> | ClientResponse<undefined, 302, "redirect"> | ClientResponse<undefined, 301, "redirect">
type Expected =
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.status: 200 | 301 | 302
MDN ReferenceClientResponse
type Expected = ClientResponse<undefined, 302, "redirect">
type verify =
(alias) interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string> import ClientResponse
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<Expected, typeof
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
res>>
type Expected = ClientResponse<undefined, 302, "redirect">
} }) }) describe('WebSocket Provider Integration', () => { const app = new
const res: ClientResponse<undefined, 302, "redirect">
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route =options
— Optional configuration options for the Hono instance.app
const route: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
.get(
const app: Hono<BlankEnv, BlankSchema, "/">
'/', upgradeWebSocket(
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, { outputFormat: "ws"; }, any>(path: "/", handler: H<any, "/", { outputFormat: "ws"; }, HandlerResponse<any>>) => Hono<...> (+22 overloads)
(c) => ({
(alias) upgradeWebSocket(createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>, options?: UpgradeWebSocketOptions | undefined): MiddlewareHandler<any, string, { outputFormat: "ws"; }> import upgradeWebSocket
onMessage
(parameter) c: Context<any, any, {}>
(event,
(property) WSEvents<WebSocket>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<WebSocket>) => void) | undefined
ws) {
(parameter) event: MessageEvent<WSMessageReceive>
ws
(parameter) ws: WSContext<WebSocket>
.send('Hello from server!')
(parameter) ws: WSContext<WebSocket>
}, onClose() {
(method) send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void
console
(property) WSEvents<WebSocket>.onClose?: ((evt: CloseEvent, ws: WSContext<WebSocket>) => void) | undefined
.log('Connection closed')
var console: Console
}, })) ) type AppType = typeof
(method) Console.log(...data: any[]): void
MDN Referenceroute
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
const server = setupServer()
const route: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
beforeAll(() => server.listen())
const server: any
afterEach(() => { vi.clearAllMocks() server.resetHandlers()
const server: any
}) afterAll(() => server.close())
const server: any
it.each([ { description: 'should initialize the WebSocket provider correctly',
const server: any
url: 'http://localhost',
(property) description: string
query: undefined,
(property) url: string
expectedUrl: 'ws://localhost/index',
(property) query: undefined
}, { description: 'should correctly add query parameters to the WebSocket URL',
(property) expectedUrl: string
url: 'http://localhost',
(property) description: string
query: {
(property) url: string
id: '123',
(property) query: { id: string; type: string; tag: string[]; }
type: 'test',
(property) id: string
tag: ['a', 'b'] },
(property) type: string
expectedUrl: 'ws://localhost/index?id=123&type=test&tag=a&tag=b',
(property) tag: string[]
}, ])('$description', ({ url,
(property) expectedUrl: string
expectedUrl,
(parameter) url: any
query }) => {
(parameter) expectedUrl: any
const webSocketMock = vi.fn()
(parameter) query: any
const client =
const webSocketMock: any
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
<AppType>
(alias) hc<Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
(url, {
type AppType = Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">
webSocket
(parameter) url: any
(url,
(property) webSocket?: ((url: string | URL, protocols?: string | string[] | undefined) => WebSocket) | undefined
options) {
(parameter) url: string | URL
return webSocketMock
(parameter) options: string | string[] | undefined
(url,
const webSocketMock: any
options)
(parameter) url: string | URL
}, }) client.index
(parameter) options: string | string[] | undefined
.$ws({
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
query })
(property) $ws: (args?: {} | undefined) => WebSocket
expect(webSocketMock).toHaveBeenCalledWith
(property) query: any
(expectedUrl, undefined)
const webSocketMock: any
}) })
(parameter) expectedUrl: any
import type { Hono } from '../hono' import type { FormValue, ValidationTargets } from '../types' import { serialize } from '../utils/cookie' import type { UnionToIntersection } from '../utils/types' import type { Callback, Client, ClientRequestOptions } from './types' import { deepMerge, mergePath, removeIndexString, replaceUrlParam, replaceUrlProtocol, } from './utils' const createProxy =(callback:
const createProxy: (callback: Callback, path: string[]) => unknown
Callback,
(parameter) callback: Callback
path: string[]) => {
(alias) type Callback = (opts: CallbackOptions) => unknown import Callback
const proxy: unknown = new
(parameter) path: string[]
Proxy(() => {}, {
const proxy: unknown
var Proxy: ProxyConstructor new <() => void>(target: () => void, handler: ProxyHandler<() => void>) => () => void
Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the original object, but which may redefine fundamental Object operations like getting, setting, and defining properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.@param
target
— A target object to wrap with Proxy.@param
gethandler
— An object whose properties define the behavior of Proxy when an operation is attempted on it.
(method) ProxyHandler<() => void>.get?(target: () => void, p: string | symbol, receiver: any): any
A trap for getting a property value.@param
target
— The original object which is being proxied.@param
p
— The name orSymbol
of the property to get.@param
(_obj,receiver
— The proxy or an object that inherits from the proxy.key) {
(parameter) _obj: () => void
if (typeof key !== 'string' ||
(parameter) key: string | symbol
key === 'then') {
(parameter) key: string | symbol
return undefined } return createProxy
(parameter) key: string
(callback, [..
const createProxy: (callback: Callback, path: string[]) => unknown
.path,
(parameter) callback: Callback
key])
(parameter) path: string[]
}, apply
(parameter) key: string
(method) ProxyHandler<() => void>.apply?(target: () => void, thisArg: any, argArray: any[]): any
A trap method for a function call.@param
(_1,target
— The original callable object which is being proxied._2,
(parameter) _1: () => void
args) {
(parameter) _2: any
return callback({
(parameter) args: any[]
path,
(parameter) callback: (opts: CallbackOptions) => unknown
args,
(property) CallbackOptions.path: string[]
}) }, }) return proxy
(property) CallbackOptions.args: any[]
} class ClientRequestImpl {
const proxy: unknown
private url: string
class ClientRequestImpl
private method: string
(property) ClientRequestImpl.url: string
private queryParams:
(property) ClientRequestImpl.method: string
URLSearchParams | undefined = undefined
(property) ClientRequestImpl.queryParams: URLSearchParams | undefined
private pathParams:
interface URLSearchParams
MDN ReferenceRecord
(property) ClientRequestImpl.pathParams: Record<string, string>
= {} private rBody:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TBodyInit | undefined
(property) ClientRequestImpl.rBody: BodyInit | undefined
private cType: string | undefined = undefined
type BodyInit = ReadableStream<any> | XMLHttpRequestBodyInit
constructor(url: string,
(property) ClientRequestImpl.cType: string | undefined
method: string) {
(parameter) url: string
this.url =
(parameter) method: string
url
(property) ClientRequestImpl.url: string
this.method =
(parameter) url: string
method
(property) ClientRequestImpl.method: string
} fetch = async (
(parameter) method: string
args?:
(property) ClientRequestImpl.fetch: (args?: ValidationTargets<FormValue> & { param?: Record<string, string>; }, opt?: ClientRequestOptions) => Promise<Response>
ValidationTargets
(parameter) args: (ValidationTargets<FormValue> & { param?: Record<string, string>; }) | undefined
<FormValue> & {
(alias) 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<string, string>; cookie: Record<string, string>; } import ValidationTargets
param?:
(alias) type FormValue = string | Blob import FormValue
Record
(property) param?: Record<string, string> | undefined
}, opt?:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TClientRequestOptions
(parameter) opt: ClientRequestOptions | undefined
) => { if (args) {
(alias) type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>); webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { ...; } : { ...; }) import ClientRequestOptions
if (args
(parameter) args: (ValidationTargets<FormValue> & { param?: Record<string, string>; }) | undefined
.query) {
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
for (const [k,
(property) query: Record<string, string | string[]>
v] of
const k: string
Object
const v: string | string[]
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | string[]>(o: { [s: string]: string | string[]; } | ArrayLike<string | string[]>): [string, string | string[]][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(argso
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..query)) {
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
if (v === undefined) {
(property) query: Record<string, string | string[]>
continue } this.queryParams ||= new
const v: string | string[]
URLSearchParams()
(property) ClientRequestImpl.queryParams: URLSearchParams | undefined
if (Array
var URLSearchParams: new (init?: string[][] | Record<string, string> | string | URLSearchParams) => URLSearchParams
MDN Reference.isArray
var Array: ArrayConstructor
(v)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
for (const v2 of
const v: string | string[]
v) {
const v2: string
this.queryParams
const v: string[]
.append
(property) ClientRequestImpl.queryParams: URLSearchParams
(k,
(method) URLSearchParams.append(name: string, value: string): void
Appends a specified key/value pair as a new search parameter.v2)
const k: string
} } else { this.queryParams
const v2: string
.set
(property) ClientRequestImpl.queryParams: URLSearchParams
(k,
(method) URLSearchParams.set(name: string, value: string): void
Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.v)
const k: string
} } } if (args
const v: string
.form) {
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
const form = new
(property) form: Record<string, FormValue | FormValue[]>
FormData()
const form: FormData
for (const [k,
var FormData: new (form?: HTMLFormElement, submitter?: HTMLElement | null) => FormData
Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".v] of
const k: string
Object
const v: FormValue | FormValue[]
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<FormValue | FormValue[]>(o: { [s: string]: FormValue | FormValue[]; } | ArrayLike<FormValue | FormValue[]>): [...][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(argso
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..form)) {
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
if (Array
(property) form: Record<string, FormValue | FormValue[]>
.isArray
var Array: ArrayConstructor
(v)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
for (const v2 of
const v: FormValue | FormValue[]
v) {
const v2: FormValue
form
const v: FormValue[]
.append
const form: FormData
(k,
(method) FormData.append(name: string, value: string | Blob): void (+2 overloads)
MDN Referencev2)
const k: string
} } else { form
const v2: FormValue
.append
const form: FormData
(k,
(method) FormData.append(name: string, value: string | Blob): void (+2 overloads)
MDN Referencev)
const k: string
} } this.rBody =
const v: FormValue
form
(property) ClientRequestImpl.rBody: BodyInit | undefined
} if (args
const form: FormData
.json) {
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
this.rBody =
(property) json: any
JSON
(property) ClientRequestImpl.rBody: BodyInit | undefined
.stringify
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
(argsspace
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read..json)
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
this.cType = 'application/json'
(property) json: any
} if (args
(property) ClientRequestImpl.cType: string | undefined
.param) {
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
this.pathParams =
(property) param: Record<string, string>
args
(property) ClientRequestImpl.pathParams: Record<string, string>
.param
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
} } let methodUpperCase = this
(property) param: Record<string, string>
.method
let methodUpperCase: string
.toUpperCase()
(property) ClientRequestImpl.method: string
const headerValues:
(method) String.toUpperCase(): string
Converts all the alphabetic characters in a string to uppercase.Record
const headerValues: Record<string, string>
= { ...(args?
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T.header ?? {}),
(parameter) args: (ValidationTargets<FormValue> & { param?: Record<string, string>; }) | undefined
...(typeof opt?
(property) header: Record<string, string> | undefined
.headers === 'function'
(parameter) opt: ClientRequestOptions | undefined
? await opt
(property) headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>) | undefined
.headers()
(parameter) opt: ClientRequestOptions
: opt?
(property) headers?: () => Record<string, string> | Promise<Record<string, string>>
.headers
(parameter) opt: ClientRequestOptions | undefined
? opt
(property) headers?: Record<string, string> | undefined
.headers
(parameter) opt: ClientRequestOptions
: {}), } if (args?
(property) headers?: Record<string, string>
.cookie) {
(parameter) args: (ValidationTargets<FormValue> & { param?: Record<string, string>; }) | undefined
const cookies: string[] = []
(property) cookie: Record<string, string> | undefined
for (const [key,
const cookies: string[]
value] of
const key: string
Object
const value: string
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string>(o: { [s: string]: string; } | ArrayLike<string>): [string, string][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(argso
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..cookie)) {
(parameter) args: ValidationTargets<FormValue> & { param?: Record<string, string>; }
cookies
(property) cookie: Record<string, string>
.push
const cookies: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(serializeitems
— New elements to add to the array.(key,
(alias) serialize<string>(name: string, value: string, opt?: CookieOptions | undefined): string import serialize
value, {
const key: string
path: '/' }))
const value: string
} headerValues['Cookie'] =
(property) path?: string | undefined
cookies
const headerValues: Record<string, string>
.join(',')
const cookies: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} if (this.cType) {separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.headerValues['Content-Type'] = this
(property) ClientRequestImpl.cType: string | undefined
.cType
const headerValues: Record<string, string>
} const headers = new
(property) ClientRequestImpl.cType: string
Headers
const headers: Headers
(headerValues ?? undefined)
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.let url = this
const headerValues: Record<string, string>
.url
let url: string
url =
(property) ClientRequestImpl.url: string
removeIndexString
let url: string
(url)
(alias) removeIndexString(urlSting: string): string import removeIndexString
url =
let url: string
replaceUrlParam
let url: string
(url, this
(alias) replaceUrlParam(urlString: string, params: Record<string, string | undefined>): string import replaceUrlParam
.pathParams)
let url: string
if (this.queryParams) {
(property) ClientRequestImpl.pathParams: Record<string, string>
url =
(property) ClientRequestImpl.queryParams: URLSearchParams | undefined
url + '?' + this
let url: string
.queryParams
let url: string
.toString()
(property) ClientRequestImpl.queryParams: URLSearchParams
} methodUpperCase = this
(method) URLSearchParams.toString(): string
Returns a string containing a query string suitable for use in a URL. Does not include the question mark..method
let methodUpperCase: string
.toUpperCase()
(property) ClientRequestImpl.method: string
const setBody = !
(method) String.toUpperCase(): string
Converts all the alphabetic characters in a string to uppercase.(methodUpperCase === 'GET' ||
const setBody: boolean
methodUpperCase === 'HEAD')
let methodUpperCase: string
// Pass URL string to 1st arg for testing with MSW and node-fetch return (opt?
let methodUpperCase: string
.fetch ||
(parameter) opt: ClientRequestOptions | undefined
fetch)
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | undefined
(url, {
function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>
MDN Referencebody:
let url: string
setBody ? this
(property) RequestInit.body?: BodyInit | null | undefined
A BodyInit object or null to set request's body..rBody : undefined,
const setBody: boolean
method:
(property) ClientRequestImpl.rBody: BodyInit | undefined
methodUpperCase,
(property) RequestInit.method?: string | undefined
A string to set request's method.headers:
let methodUpperCase: string
headers,
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers....opt?
const headers: Headers
.init,
(parameter) opt: ClientRequestOptions | undefined
(property) init?: RequestInit | undefined
StandardRequestInit
, caution that this take highest priority and could be used to overwrite things that Hono sets for you, likebody | method | headers
.If you want to add some headers, use in
}) } } // eslint-disable-next-line @typescript-eslint/no-explicit-any export const hc =headers
instead ofinit
<T extends
const hc: <T extends Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions) => UnionToIntersection<Client<T>>
Hono
(type parameter) T in <T extends Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions): UnionToIntersection<Client<T>>
>( baseUrl: string,
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.options?:
(parameter) baseUrl: string
ClientRequestOptions
(parameter) options: ClientRequestOptions | undefined
) => createProxy(function
(alias) type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>); webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { ...; } : { ...; }) import ClientRequestOptions
proxyCallback
const createProxy: (callback: Callback, path: string[]) => unknown
(opts) {
(local function) proxyCallback(opts: CallbackOptions): string | Promise<Response> | URL | WebSocket | ((opts: CallbackOptions) => string | ... 4 more ... | ClientRequestImpl) | ClientRequestImpl
const parts = [..
(parameter) opts: CallbackOptions
.opts
const parts: string[]
.path]
(parameter) opts: CallbackOptions
// allow calling .toString() and .valueOf() on the proxy if (parts
(property) CallbackOptions.path: string[]
[parts
const parts: string[]
.length - 1] === 'toString') {
const parts: string[]
if (parts
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.[parts
const parts: string[]
.length - 2] === 'name') {
const parts: string[]
// e.g. hc().somePath.name.toString() -> "somePath" return parts
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.[parts
const parts: string[]
.length - 3] || ''
const parts: string[]
} // e.g. hc().somePath.toString() return proxyCallback
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array..toString()
(local function) proxyCallback(opts: CallbackOptions): string | Promise<Response> | URL | WebSocket | ((opts: CallbackOptions) => string | ... 4 more ... | ClientRequestImpl) | ClientRequestImpl
} if (parts
(method) Function.toString(): string
Returns a string representation of a function.[parts
const parts: string[]
.length - 1] === 'valueOf') {
const parts: string[]
if (parts
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.[parts
const parts: string[]
.length - 2] === 'name') {
const parts: string[]
// e.g. hc().somePath.name.valueOf() -> "somePath" return parts
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.[parts
const parts: string[]
.length - 3] || ''
const parts: string[]
} // e.g. hc().somePath.valueOf() return proxyCallback
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.} let method = ''
(local function) proxyCallback(opts: CallbackOptions): string | Promise<Response> | URL | WebSocket | ((opts: CallbackOptions) => string | ... 4 more ... | ClientRequestImpl) | ClientRequestImpl
if (/^\$/.test
let method: string
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
(partsstring
— String on which to perform the search.[parts
const parts: string[]
.length - 1])) {
const parts: string[]
const last =
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.parts
const last: string | undefined
.pop()
const parts: string[]
if (last) {
(method) Array<string>.pop(): string | undefined
Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.method =
const last: string | undefined
last
let method: string
.replace(/^\$/, '')
const last: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
} } const path =replaceValue
— The replacement text.parts
const path: string
.join('/')
const parts: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
const url =separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.mergePath
const url: string
(baseUrl,
(alias) mergePath(base: string, path: string): string import mergePath
path)
(parameter) baseUrl: string
if (method === 'url') {
const path: string
if (opts
let method: string
.args[0] &&
(parameter) opts: CallbackOptions
opts
(property) CallbackOptions.args: any[]
.args[0].param) {
(parameter) opts: CallbackOptions
return new URL
(property) CallbackOptions.args: any[]
(replaceUrlParam
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs.(url,
(alias) replaceUrlParam(urlString: string, params: Record<string, string | undefined>): string import replaceUrlParam
opts
const url: string
.args[0].param))
(parameter) opts: CallbackOptions
} return new URL
(property) CallbackOptions.args: any[]
(url)
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs.} if (method === 'ws') {
const url: string
const webSocketUrl =
let method: string
replaceUrlProtocol(
const webSocketUrl: string
opts
(alias) replaceUrlProtocol(urlString: string, protocol: "ws" | "http"): string import replaceUrlProtocol
.args[0] &&
(parameter) opts: CallbackOptions
opts
(property) CallbackOptions.args: any[]
.args[0].param ?
(parameter) opts: CallbackOptions
replaceUrlParam
(property) CallbackOptions.args: any[]
(url,
(alias) replaceUrlParam(urlString: string, params: Record<string, string | undefined>): string import replaceUrlParam
opts
const url: string
.args[0].param) :
(parameter) opts: CallbackOptions
url,
(property) CallbackOptions.args: any[]
'ws' ) const targetUrl = new
const url: string
URL
const targetUrl: URL
(webSocketUrl)
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs.const queryParams:
const webSocketUrl: string
Record
const queryParams: Record<string, string | string[]> | undefined
| undefined = opts
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T.args[0]?.query
(parameter) opts: CallbackOptions
if (queryParams) {
(property) CallbackOptions.args: any[]
Object
const queryParams: Record<string, string | string[]> | undefined
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | string[]>(o: { [s: string]: string | string[]; } | ArrayLike<string | string[]>): [string, string | string[]][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(queryParams)o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..forEach((
const queryParams: Record<string, string | string[]>
(method) Array<[string, string | string[]]>.forEach(callbackfn: (value: [string, string | string[]], index: number, array: [string, string | string[]][]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
[key,thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.value]) => {
(parameter) key: string
if (Array
(parameter) value: string | string[]
.isArray
var Array: ArrayConstructor
(value)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
value
(parameter) value: string | string[]
.forEach(
(parameter) value: string[]
(method) Array<string>.forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(item) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.targetUrl
(parameter) item: string
.searchParams
const targetUrl: URL
.append
(property) URL.searchParams: URLSearchParams
MDN Reference(key,
(method) URLSearchParams.append(name: string, value: string): void
Appends a specified key/value pair as a new search parameter.item))
(parameter) key: string
} else { targetUrl
(parameter) item: string
.searchParams
const targetUrl: URL
.set
(property) URL.searchParams: URLSearchParams
MDN Reference(key,
(method) URLSearchParams.set(name: string, value: string): void
Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.value)
(parameter) key: string
} }) } const establishWebSocket = (..
(parameter) value: string
.args:
const establishWebSocket: (url: string | URL, protocols?: string | string[] | undefined) => WebSocket
ConstructorParameters
(parameter) args: [url: string | URL, protocols?: string | string[] | undefined]
WebSocket>) => {
type ConstructorParameters<T extends abstract new (...args: any) => any> = T extends abstract new (...args: infer P) => any ? P : never
Obtain the parameters of a constructor function type in a tupleif (options?
var WebSocket: { new (url: string | URL, protocols?: string | string[]): WebSocket; prototype: WebSocket; readonly CONNECTING: 0; readonly OPEN: 1; readonly CLOSING: 2; readonly CLOSED: 3; }
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection..webSocket !== undefined && typeof
(parameter) options: ClientRequestOptions | undefined
options
(property) webSocket?: ((url: string | URL, protocols?: string | string[] | undefined) => WebSocket) | undefined
.webSocket === 'function') {
(parameter) options: ClientRequestOptions
return options
(property) webSocket?: (url: string | URL, protocols?: string | string[] | undefined) => WebSocket
.webSocket(..
(parameter) options: ClientRequestOptions
.args)
(property) webSocket?: (url: string | URL, protocols?: string | string[] | undefined) => WebSocket
} return new WebSocket(..
(parameter) args: [url: string | URL, protocols?: string | string[] | undefined]
.args)
var WebSocket: new (url: string | URL, protocols?: string | string[]) => WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.} return establishWebSocket
(parameter) args: [url: string | URL, protocols?: string | string[] | undefined]
(targetUrl
const establishWebSocket: (url: string | URL, protocols?: string | string[] | undefined) => WebSocket
.toString())
const targetUrl: URL
} const req = new
(method) URL.toString(): string
ClientRequestImpl
const req: ClientRequestImpl
(url,
constructor ClientRequestImpl(url: string, method: string): ClientRequestImpl
method)
const url: string
if (method) {
let method: string
options ??= {}
let method: string
const args =
(parameter) options: ClientRequestOptions | undefined
deepMerge
const args: ClientRequestOptions
<ClientRequestOptions>
(alias) deepMerge<ClientRequestOptions>(target: ClientRequestOptions, source: Record<string, unknown>): ClientRequestOptions import deepMerge
(options, { ...
(alias) type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>); webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { ...; } : { ...; }) import ClientRequestOptions
(opts
(parameter) options: ClientRequestOptions
.args[1] ?? {}) })
(parameter) opts: CallbackOptions
return req
(property) CallbackOptions.args: any[]
.fetch
const req: ClientRequestImpl
(opts
(property) ClientRequestImpl.fetch: (args?: ValidationTargets<FormValue> & { param?: Record<string, string>; }, opt?: ClientRequestOptions) => Promise<Response>
.args[0],
(parameter) opts: CallbackOptions
args)
(property) CallbackOptions.args: any[]
} return req
const args: ClientRequestOptions
}, []) as UnionToIntersection
const req: ClientRequestImpl
<Client
(alias) type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never import UnionToIntersection
<T>>
(alias) type Client<T> = T extends Hono<any, infer S extends Schema, any> ? S extends Record<infer K extends string | number | symbol, Schema> ? K extends string ? PathToChain<...> : never : never : never import Client
(type parameter) T in <T extends Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions): UnionToIntersection<Client<T>>
/** * @module * The HTTP Client for Hono. */ export { hc } from './client'export type { InferResponseType,
(alias) const hc: <T extends Hono<any, any, any>>(baseUrl: string, options?: ClientRequestOptions) => UnionToIntersection<Client<T>> export hc
InferRequestType,
(alias) type InferResponseType<T, U extends StatusCode = StatusCode> = InferEndpointType<T> extends { output: infer O; status: infer S; } ? S extends U ? O : never : never export InferResponseType
Fetch,
(alias) type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never export InferRequestType
ClientRequestOptions,
(alias) type Fetch<T> = (args?: InferRequestType<T>, opt?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<...>> export Fetch
ClientRequest,
(alias) type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>); webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { ...; } : { ...; }) export ClientRequestOptions
ClientResponse,
(alias) type ClientRequest<S extends Schema> = { [M in keyof S]: S[M] extends Endpoint & { input: infer R; } ? R extends object ? HasRequiredKeys<R> extends true ? (args: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<...>> : (args?: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<...>> : never : never; } & { ...; } & (S["$get"] extends { ...; } ? S["$get"] extends { ...; } ? { ...; } : {} : {}) export ClientRequest
} from './types'
(alias) interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string> export ClientResponse
/* eslint-disable @typescript-eslint/no-unused-vars */ import { expectTypeOf } from 'vitest' import { Hono } from '..' import { upgradeWebSocket } from '../adapter/deno/websocket' import { hc } from '.' describe('WebSockets', () => { const app = newHono()
const app: Hono<BlankEnv, { "/ws": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; } & { ...; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get(options
— Optional configuration options for the Hono instance.'/ws', upgradeWebSocket(() => ({}))
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/ws", "/ws", HandlerResponse<any>, { outputFormat: "ws"; }, any>(path: "/ws", handler: H<any, "/ws", { outputFormat: "ws"; }, HandlerResponse<any>>) => Hono<...> (+22 overloads)
) .get('/',
(alias) upgradeWebSocket(createEvents: (c: Context) => WSEvents<WebSocket> | Promise<WSEvents<WebSocket>>, options?: UpgradeWebSocketOptions | undefined): MiddlewareHandler<any, string, { outputFormat: "ws"; }> import upgradeWebSocket
(c) =>
(property) Hono<BlankEnv, { "/ws": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/", "/", JSONRespondReturn<{}, StatusCode>, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.json({}))
(parameter) c: Context<BlankEnv, "/", BlankInput>
const client =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, StatusCode>(object: {}, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, StatusCode> (+1 overload)
hc
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { ws: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
app>('/')
(alias) hc<Hono<BlankEnv, { "/ws": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; } & { ...; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & { ...; } import hc
it('WebSocket route', () => { expectTypeOf(client.ws).toMatchTypeOf<{
const app: Hono<BlankEnv, { "/ws": { $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }; } & { ...; }, "/">
$ws: () =>
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { ws: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
WebSocket
(property) $ws: () => WebSocket
}>() }) it('Not WebSocket Route', () => { expectTypeOf< typeof client.index extends {
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.$ws: () =>
const client: { index: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { ws: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; } | { input: {}; output: {}; outputFormat: "ws"; status: StatusCode; }; }>; }
WebSocket } ? false : true
(property) $ws: () => WebSocket
>().toEqualTypeOf(true) }) }) describe('without the leading slash', () => { const app = new
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.Hono()
const app: Hono<BlankEnv, { foo: { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { "foo/bar": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('foo',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"foo", "foo", JSONRespondReturn<{}, StatusCode>, BlankInput, BlankEnv>(path: "foo", handler: H<BlankEnv, "foo", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "foo", BlankInput>
.json({}))
(parameter) c: Context<BlankEnv, "foo", BlankInput>
.get('foo/bar',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, StatusCode>(object: {}, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, StatusCode> (+1 overload)
(c) =>
(property) Hono<BlankEnv, { foo: { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"foo/bar", "foo/bar", JSONRespondReturn<{}, StatusCode>, BlankInput, BlankEnv>(path: "foo/bar", handler: H<BlankEnv, "foo/bar", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "foo/bar", BlankInput>
.json({}))
(parameter) c: Context<BlankEnv, "foo/bar", BlankInput>
.get('foo/:id/baz',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, StatusCode>(object: {}, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, StatusCode> (+1 overload)
(c) =>
(property) Hono<BlankEnv, { foo: { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { "foo/bar": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"foo/:id/baz", "foo/:id/baz", JSONRespondReturn<{}, StatusCode>, BlankInput, BlankEnv>(path: "foo/:id/baz", handler: H<BlankEnv, "foo/:id/baz", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "foo/:id/baz", BlankInput>
.json({}))
(parameter) c: Context<BlankEnv, "foo/:id/baz", BlankInput>
const client =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, StatusCode>(object: {}, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, StatusCode> (+1 overload)
hc
const client: { foo: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { foo: { bar: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; }
app>('')
(alias) hc<Hono<BlankEnv, { foo: { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { "foo/bar": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & ... 1 more ... & { ...; } import hc
it('`foo` should have `$get`', () => { expectTypeOf(client.foo).toHaveProperty('$get')
const app: Hono<BlankEnv, { foo: { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { "foo/bar": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">
}) it('`foo.bar` should not have `$get`', () => { expectTypeOf(client.foo.bar).toHaveProperty('$get')
const client: { foo: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { foo: { bar: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; }
}) it('`foo[":id"].baz` should have `$get`', () => { expectTypeOf(client.foo[':id'].baz).toHaveProperty('$get')
const client: { foo: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { foo: { bar: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; }
}) }) describe('with the leading slash', () => { const app = new
const client: { foo: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { foo: { bar: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; }
Hono()
const app: Hono<BlankEnv, { "/foo": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { "/foo/bar": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/foo',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo", "/foo", JSONRespondReturn<{}, StatusCode>, BlankInput, BlankEnv>(path: "/foo", handler: H<BlankEnv, "/foo", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.json({}))
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.get('/foo/bar',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, StatusCode>(object: {}, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, StatusCode> (+1 overload)
(c) =>
(property) Hono<BlankEnv, { "/foo": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/foo/bar", "/foo/bar", JSONRespondReturn<{}, StatusCode>, BlankInput, BlankEnv>(path: "/foo/bar", handler: H<BlankEnv, "/foo/bar", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/foo/bar", BlankInput>
.json({}))
(parameter) c: Context<BlankEnv, "/foo/bar", BlankInput>
.get('/foo/:id/baz',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, StatusCode>(object: {}, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, StatusCode> (+1 overload)
(c) =>
(property) Hono<BlankEnv, { "/foo": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { "/foo/bar": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/foo/:id/baz", "/foo/:id/baz", JSONRespondReturn<{}, StatusCode>, BlankInput, BlankEnv>(path: "/foo/:id/baz", handler: H<BlankEnv, "/foo/:id/baz", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/foo/:id/baz", BlankInput>
.json({}))
(parameter) c: Context<BlankEnv, "/foo/:id/baz", BlankInput>
const client =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, StatusCode>(object: {}, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, StatusCode> (+1 overload)
hc
const client: { foo: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { foo: { bar: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; }
app>('')
(alias) hc<Hono<BlankEnv, { "/foo": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { "/foo/bar": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } & ... 1 more ... & { ...; } import hc
it('`foo` should have `$get`', () => { expectTypeOf(client.foo).toHaveProperty('$get')
const app: Hono<BlankEnv, { "/foo": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { "/foo/bar": { $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }; } & { ...; }, "/">
}) it('`foo.bar` should not have `$get`', () => { expectTypeOf(client.foo.bar).toHaveProperty('$get')
const client: { foo: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { foo: { bar: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; }
}) it('`foo[":id"].baz` should have `$get`', () => { expectTypeOf(client.foo[':id'].baz).toHaveProperty('$get')
const client: { foo: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { foo: { bar: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; }
}) })
const client: { foo: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; } & { foo: { bar: ClientRequest<{ $get: { input: {}; output: {}; outputFormat: "json"; status: StatusCode; }; }>; }; } & { ...; }
import type { Hono } from '../hono' import type { Endpoint, ResponseFormat, Schema } from '../types' import type { StatusCode, SuccessStatusCode } from '../utils/http-status' import type { HasRequiredKeys } from '../utils/types' type HonoRequest = (typeofHono.prototype)['request']
type HonoRequest = (input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => globalThis.Response | Promise<globalThis.Response>
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
export type ClientRequestOptionsBasePath
— The base path type.<T = unknown> = {
type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | HonoRequest; webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>); } : { ...; })
fetch?: typeof
(type parameter) T in type ClientRequestOptions<T = unknown>
fetch |
(property) fetch?: ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => globalThis.Response | Promise<globalThis.Response>) | ((input: RequestInfo | URL, init?: RequestInit) => Promise<globalThis.Response>) | undefined
HonoRequest
function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<globalThis.Response>
MDN ReferencewebSocket?: (..
type HonoRequest = (input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => globalThis.Response | Promise<globalThis.Response>
.args:
(property) webSocket?: ((url: string | URL, protocols?: string | string[] | undefined) => WebSocket) | undefined
ConstructorParameters
(parameter) args: [url: string | URL, protocols?: string | string[] | undefined]
WebSocket>) =>
type ConstructorParameters<T extends abstract new (...args: any) => any> = T extends abstract new (...args: infer P) => any ? P : never
Obtain the parameters of a constructor function type in a tupleWebSocket
var WebSocket: { new (url: string | URL, protocols?: string | string[]): WebSocket; prototype: WebSocket; readonly CONNECTING: 0; readonly OPEN: 1; readonly CLOSING: 2; readonly CLOSED: 3; }
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection./** * Standard `RequestInit`, caution that this take highest priority * and could be used to overwrite things that Hono sets for you, like `body | method | headers`. * * If you want to add some headers, use in `headers` instead of `init` */ init?:
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
(property) init?: RequestInit | undefined
StandardRequestInit
, caution that this take highest priority and could be used to overwrite things that Hono sets for you, likebody | method | headers
.If you want to add some headers, use in
RequestInitheaders
instead ofinit
} & (keyof T extends never
interface RequestInit
? { headers?:
(type parameter) T in type ClientRequestOptions<T = unknown>
| Record
(property) headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>) | undefined
| (() => Record
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T| Promise
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T<Record
interface Promise<T>
Represents the completion of an asynchronous operation>) } : { headers:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TT | (() =>
(property) headers: T | (() => T | Promise<T>)
T |
(type parameter) T in type ClientRequestOptions<T = unknown>
Promise
(type parameter) T in type ClientRequestOptions<T = unknown>
<T>)
interface Promise<T>
Represents the completion of an asynchronous operation}) export type ClientRequest
(type parameter) T in type ClientRequestOptions<T = unknown>
<S extends
type ClientRequest<S extends Schema> = { [M in keyof S]: S[M] extends Endpoint & { input: infer R; } ? R extends object ? HasRequiredKeys<R> extends true ? (args: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<S[M]>> : (args?: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<S[M]>> : never : never; } & { ...; } & (S["$get"] extends { ...; } ? S["$get"] extends { ...; } ? { ...; } : {} : {})
Schema> = {
(type parameter) S in type ClientRequest<S extends Schema>
[M in keyof
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
S]:
(type parameter) M
S
(type parameter) S in type ClientRequest<S extends Schema>
[M] extends
(type parameter) S in type ClientRequest<S extends Schema>
Endpoint & {
(type parameter) M
input: infer
(alias) type Endpoint = { input: any; output: any; outputFormat: ResponseFormat; status: StatusCode; } import Endpoint
R }
(property) input: R
? R extends object
(type parameter) R
? HasRequiredKeys
(type parameter) R
<R> extends true
(alias) type HasRequiredKeys<BaseType extends object> = Exclude<{ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never; }[keyof BaseType], undefined> extends never ? false : true import HasRequiredKeys
? (args:
(type parameter) R
R,
(parameter) args: R
options?:
(type parameter) R
ClientRequestOptions) =>
(parameter) options: ClientRequestOptions<unknown> | undefined
Promise
type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | HonoRequest; webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>); } : { ...; })
<ClientResponseOfEndpoint
interface Promise<T>
Represents the completion of an asynchronous operation<S
type ClientResponseOfEndpoint<T extends Endpoint = Endpoint> = T extends { output: infer O; outputFormat: infer F; status: infer S; } ? ClientResponse<O, S extends number ? S : never, F extends string ? F : never> : never
[M]>>
(type parameter) S in type ClientRequest<S extends Schema>
: (args?:
(type parameter) M
R,
(parameter) args: R | undefined
options?:
(type parameter) R
ClientRequestOptions) =>
(parameter) options: ClientRequestOptions<unknown> | undefined
Promise
type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | HonoRequest; webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>); } : { ...; })
<ClientResponseOfEndpoint
interface Promise<T>
Represents the completion of an asynchronous operation<S
type ClientResponseOfEndpoint<T extends Endpoint = Endpoint> = T extends { output: infer O; outputFormat: infer F; status: infer S; } ? ClientResponse<O, S extends number ? S : never, F extends string ? F : never> : never
[M]>>
(type parameter) S in type ClientRequest<S extends Schema>
: never : never } & { $url: (
(type parameter) M
arg?:
(property) $url: (arg?: S[keyof S] extends { input: infer R; } ? R extends { param: infer P; } ? { param: P; } : {} : {}) => URL
S[keyof
(parameter) arg: (S[keyof S] extends { input: infer R; } ? R extends { param: infer P; } ? { param: P; } : {} : {}) | undefined
S] extends {
(type parameter) S in type ClientRequest<S extends Schema>
input: infer
(type parameter) S in type ClientRequest<S extends Schema>
R }
(property) input: R
? R extends {
(type parameter) R
param: infer
(type parameter) R
P }
(property) param: P
? { param:
(type parameter) P
P }
(property) param: P
: {} : {} ) => URL
(type parameter) P
} & (S['$get'] extends {
interface URL
The URL interface represents an object providing static methods used for creating object URLs.outputFormat: 'ws' }
(type parameter) S in type ClientRequest<S extends Schema>
? S['$get'] extends {
(property) outputFormat: "ws"
input: infer
(type parameter) S in type ClientRequest<S extends Schema>
I }
(property) input: I
? { $ws:
(type parameter) I
(args?:
(property) $ws: (args?: I) => WebSocket
I) =>
(parameter) args: I | undefined
WebSocket
(type parameter) I
} : {} : {}) // eslint-disable-next-line @typescript-eslint/no-explicit-any type BlankRecordToNever
interface WebSocket
Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.<T> =
type BlankRecordToNever<T> = T extends any ? T extends null ? null : keyof T extends never ? never : T : never
T extends any
(type parameter) T in type BlankRecordToNever<T>
? T extends null
(type parameter) T in type BlankRecordToNever<T>
? null : keyof T extends never
(type parameter) T in type BlankRecordToNever<T>
? never : T
(type parameter) T in type BlankRecordToNever<T>
: never type ClientResponseOfEndpoint
(type parameter) T in type BlankRecordToNever<T>
<T extends
type ClientResponseOfEndpoint<T extends Endpoint = Endpoint> = T extends { output: infer O; outputFormat: infer F; status: infer S; } ? ClientResponse<O, S extends number ? S : never, F extends string ? F : never> : never
Endpoint =
(type parameter) T in type ClientResponseOfEndpoint<T extends Endpoint = Endpoint>
Endpoint> =
(alias) type Endpoint = { input: any; output: any; outputFormat: ResponseFormat; status: StatusCode; } import Endpoint
T extends {
(alias) type Endpoint = { input: any; output: any; outputFormat: ResponseFormat; status: StatusCode; } import Endpoint
output: infer
(type parameter) T in type ClientResponseOfEndpoint<T extends Endpoint = Endpoint>
O
(property) output: O
outputFormat: infer
(type parameter) O
F
(property) outputFormat: F
status: infer
(type parameter) F
S
(property) status: S
} ? ClientResponse
(type parameter) S
<O,
interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
S extends number ?
(type parameter) O
S : never,
(type parameter) S
F extends
(type parameter) S
ResponseFormat ?
(type parameter) F
F : never>
(alias) type ResponseFormat = string import ResponseFormat
: never export interface ClientResponse<
(type parameter) F
T,
interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
U extends number =
(type parameter) T in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
StatusCode,
(type parameter) U in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
F extends
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.ResponseFormat =
(type parameter) F in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
ResponseFormat
(alias) type ResponseFormat = string import ResponseFormat
> extends globalThis.Response {
(alias) type ResponseFormat = string import ResponseFormat
readonly body:
interface Response
This Fetch API interface represents the response to a request.ReadableStream | null
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.body: ReadableStream<any> | null
MDN Referencereadonly bodyUsed: boolean
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.ok:
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.bodyUsed: boolean
MDN ReferenceU extends
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.ok: U extends SuccessStatusCode ? true : U extends InfoStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 ? false : boolean
MDN ReferenceSuccessStatusCode
(type parameter) U in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
? true : U extends
(alias) type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 import SuccessStatusCode
Exclude
(type parameter) U in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
<StatusCode,
type Exclude<T, U> = T extends U ? never : T
Exclude from T those types that are assignable to USuccessStatusCode>
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.? false : boolean status:
(alias) type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 import SuccessStatusCode
U
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.status: U extends number = StatusCode
MDN ReferencestatusText: string
(type parameter) U in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
headers:
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.statusText: string
MDN ReferenceHeaders
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.headers: Headers
MDN Referenceurl: string
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.redirect
(property) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.url: string
MDN Reference(url: string,
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.redirect(url: string, status: number): Response
status: number):
(parameter) url: string
Response
(parameter) status: number
clone():
interface Response
Response
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.clone(): Response
MDN Referencejson():
interface Response
F extends 'text'
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.json(): F extends "text" ? Promise<never> : F extends "json" ? Promise<BlankRecordToNever<T>> : Promise<unknown>
MDN Reference? Promise
(type parameter) F in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
: F extends 'json'
interface Promise<T>
Represents the completion of an asynchronous operation? Promise
(type parameter) F in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
<BlankRecordToNever
interface Promise<T>
Represents the completion of an asynchronous operation<T>>
type BlankRecordToNever<T> = T extends any ? T extends null ? null : keyof T extends never ? never : T : never
: Promise
(type parameter) T in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
text():
interface Promise<T>
Represents the completion of an asynchronous operationF extends 'text' ?
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.text(): F extends "text" ? (T extends string ? Promise<T> : Promise<never>) : Promise<string>
MDN Reference(T extends string ?
(type parameter) F in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
Promise
(type parameter) T in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
<T> :
interface Promise<T>
Represents the completion of an asynchronous operationPromise
(type parameter) T in ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
) : Promise
interface Promise<T>
Represents the completion of an asynchronous operationblob():
interface Promise<T>
Represents the completion of an asynchronous operationPromise
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.blob(): Promise<Blob>
MDN Reference<Blob>
interface Promise<T>
Represents the completion of an asynchronous operationformData():
interface Blob
A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.Promise
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.formData(): Promise<FormData>
MDN Reference<FormData>
interface Promise<T>
Represents the completion of an asynchronous operationarrayBuffer():
interface FormData
Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".Promise
(method) ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>.arrayBuffer(): Promise<ArrayBuffer>
MDN Reference<ArrayBuffer>
interface Promise<T>
Represents the completion of an asynchronous operation} export interface Response extends
interface ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.ClientResponse
interface Response
{} export type Fetch
interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
<T> = (
type Fetch<T> = (args?: InferRequestType<T>, opt?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<InferEndpointType<T>>>
args?:
(type parameter) T in type Fetch<T>
InferRequestType
(parameter) args: InferRequestType<T> | undefined
<T>,
type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never
opt?:
(type parameter) T in type Fetch<T>
ClientRequestOptions
(parameter) opt: ClientRequestOptions<unknown> | undefined
) => Promise
type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | HonoRequest; webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>); } : { ...; })
<ClientResponseOfEndpoint
interface Promise<T>
Represents the completion of an asynchronous operation<InferEndpointType
type ClientResponseOfEndpoint<T extends Endpoint = Endpoint> = T extends { output: infer O; outputFormat: infer F; status: infer S; } ? ClientResponse<O, S extends number ? S : never, F extends string ? F : never> : never
<T>>>
type InferEndpointType<T> = T extends (args: infer R, options: any | undefined) => Promise<infer U> ? U extends ClientResponse<infer O, infer S extends number, infer F extends string> ? { ...; } extends Endpoint ? { ...; } : never : never : never
type InferEndpointType
(type parameter) T in type Fetch<T>
<T> =
type InferEndpointType<T> = T extends (args: infer R, options: any | undefined) => Promise<infer U> ? U extends ClientResponse<infer O, infer S extends number, infer F extends string> ? { ...; } extends Endpoint ? { ...; } : never : never : never
T extends (
(type parameter) T in type InferEndpointType<T>
args: infer
(type parameter) T in type InferEndpointType<T>
R,
(parameter) args: R
// eslint-disable-next-line @typescript-eslint/no-explicit-any options: any | undefined
(type parameter) R
) => Promise
(parameter) options: any
U>
interface Promise<T>
Represents the completion of an asynchronous operation? U extends
(type parameter) U
ClientResponse
(type parameter) U
O, infer
interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
S, infer
(type parameter) O
F>
(type parameter) S
? { input:
(type parameter) F
NonNullable
(property) input: NonNullable<R>
<R>;
type NonNullable<T> = T & {}
Exclude null and undefined from Toutput:
(type parameter) R
O;
(property) output: O
outputFormat:
(type parameter) O
F;
(property) outputFormat: F extends string
status:
(type parameter) F
S } extends
(property) status: S extends number
Endpoint
(type parameter) S
? { input:
(alias) type Endpoint = { input: any; output: any; outputFormat: ResponseFormat; status: StatusCode; } import Endpoint
NonNullable
(property) input: NonNullable<R>
<R>;
type NonNullable<T> = T & {}
Exclude null and undefined from Toutput:
(type parameter) R
O;
(property) output: O
outputFormat:
(type parameter) O
F;
(property) outputFormat: F extends string
status:
(type parameter) F
S }
(property) status: S extends number
: never : never : never export type InferResponseType
(type parameter) S
<T,
type InferResponseType<T, U extends StatusCode = StatusCode> = InferEndpointType<T> extends { output: infer O; status: infer S; } ? S extends U ? O : never : never
U extends
(type parameter) T in type InferResponseType<T, U extends StatusCode = StatusCode>
StatusCode =
(type parameter) U in type InferResponseType<T, U extends StatusCode = StatusCode>
StatusCode> =
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.InferResponseTypeFromEndpoint<
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.InferEndpointType
type InferResponseTypeFromEndpoint<T extends Endpoint, U extends StatusCode> = T extends { output: infer O; status: infer S; } ? S extends U ? O : never : never
<T>,
type InferEndpointType<T> = T extends (args: infer R, options: any | undefined) => Promise<infer U> ? U extends ClientResponse<infer O, infer S extends number, infer F extends string> ? { ...; } extends Endpoint ? { ...; } : never : never : never
U
(type parameter) T in type InferResponseType<T, U extends StatusCode = StatusCode>
> type InferResponseTypeFromEndpoint
(type parameter) U in type InferResponseType<T, U extends StatusCode = StatusCode>
<T extends
type InferResponseTypeFromEndpoint<T extends Endpoint, U extends StatusCode> = T extends { output: infer O; status: infer S; } ? S extends U ? O : never : never
Endpoint,
(type parameter) T in type InferResponseTypeFromEndpoint<T extends Endpoint, U extends StatusCode>
U extends
(alias) type Endpoint = { input: any; output: any; outputFormat: ResponseFormat; status: StatusCode; } import Endpoint
StatusCode> =
(type parameter) U in type InferResponseTypeFromEndpoint<T extends Endpoint, U extends StatusCode>
T extends {
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.output: infer
(type parameter) T in type InferResponseTypeFromEndpoint<T extends Endpoint, U extends StatusCode>
O
(property) output: O
status: infer
(type parameter) O
S
(property) status: S
} ? S extends
(type parameter) S
U
(type parameter) S
? O
(type parameter) U in type InferResponseTypeFromEndpoint<T extends Endpoint, U extends StatusCode>
: never : never export type InferRequestType
(type parameter) O
<T> =
type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never
T extends (
(type parameter) T in type InferRequestType<T>
args: infer
(type parameter) T in type InferRequestType<T>
R,
(parameter) args: R
// eslint-disable-next-line @typescript-eslint/no-explicit-any options: any | undefined
(type parameter) R
) => Promise
(parameter) options: any
<ClientResponse
interface Promise<T>
Represents the completion of an asynchronous operation> ? NonNullable
interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
<R>
type NonNullable<T> = T & {}
Exclude null and undefined from T: never export type InferRequestOptionsType
(type parameter) R
<T> =
type InferRequestOptionsType<T> = T extends (args: any, options: infer R) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never
T extends (
(type parameter) T in type InferRequestOptionsType<T>
// eslint-disable-next-line @typescript-eslint/no-explicit-any args: any,
(type parameter) T in type InferRequestOptionsType<T>
options: infer
(parameter) args: any
R
(parameter) options: R
) => Promise
(type parameter) R
<ClientResponse
interface Promise<T>
Represents the completion of an asynchronous operation> ? NonNullable
interface ClientResponse<T, U extends number = StatusCode, F extends ResponseFormat = string>
<R>
type NonNullable<T> = T & {}
Exclude null and undefined from T: never type PathToChain<
(type parameter) R
Path extends string,
type PathToChain<Path extends string, E extends Schema, Original extends string = Path> = Path extends `/${infer P}` ? PathToChain<P, E, Path> : Path extends `${infer P}/${infer R}` ? { [K in P]: PathToChain<R, E, Original>; } : { [K in Path extends "" ? "index" : Path]: ClientRequest<...>; }
E extends
(type parameter) Path in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
Schema,
(type parameter) E in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
Original extends string =
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
Path
(type parameter) Original in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
> = Path extends `/${infer
(type parameter) Path in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
P}`
(type parameter) Path in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
? PathToChain
(type parameter) P
<P,
type PathToChain<Path extends string, E extends Schema, Original extends string = Path> = Path extends `/${infer P}` ? PathToChain<P, E, Path> : Path extends `${infer P}/${infer R}` ? { [K in P]: PathToChain<R, E, Original>; } : { [K in Path extends "" ? "index" : Path]: ClientRequest<...>; }
E,
(type parameter) P
Path>
(type parameter) E in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
: Path extends `${infer
(type parameter) Path in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
P}/${infer
(type parameter) Path in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
R}`
(type parameter) P
? { [K in
(type parameter) R
P]:
(type parameter) K
PathToChain
(type parameter) P
<R,
type PathToChain<Path extends string, E extends Schema, Original extends string = Path> = Path extends `/${infer P}` ? PathToChain<P, E, Path> : Path extends `${infer P}/${infer R}` ? { [K in P]: PathToChain<R, E, Original>; } : { [K in Path extends "" ? "index" : Path]: ClientRequest<...>; }
E,
(type parameter) R
Original> }
(type parameter) E in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
: { [K in
(type parameter) Original in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
Path extends '' ? 'index' :
(type parameter) K
Path]:
(type parameter) Path in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
ClientRequest<
(type parameter) Path in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
E extends
type ClientRequest<S extends Schema> = { [M in keyof S]: S[M] extends Endpoint & { input: infer R; } ? R extends object ? HasRequiredKeys<R> extends true ? (args: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<S[M]>> : (args?: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<S[M]>> : never : never; } & { ...; } & (S["$get"] extends { ...; } ? S["$get"] extends { ...; } ? { ...; } : {} : {})
Record
(type parameter) E in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
? E
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T[Original] : never
(type parameter) E in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
> } // eslint-disable-next-line @typescript-eslint/no-explicit-any export type Client
(type parameter) Original in type PathToChain<Path extends string, E extends Schema, Original extends string = Path>
<T> =
type Client<T> = T extends Hono<any, infer S extends Schema, any> ? S extends Record<infer K extends string | number | symbol, Schema> ? K extends string ? PathToChain<...> : never : never : never
T extends
(type parameter) T in type Client<T>
Hono
(type parameter) T in type Client<T>
S, any>
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.? S extends
(type parameter) S
Record
(type parameter) S
K,
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TSchema>
(type parameter) K
? K extends string
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
? PathToChain
(type parameter) K
<K,
type PathToChain<Path extends string, E extends Schema, Original extends string = Path> = Path extends `/${infer P}` ? PathToChain<P, E, Path> : Path extends `${infer P}/${infer R}` ? { [K in P]: PathToChain<R, E, Original>; } : { [K in Path extends "" ? "index" : Path]: ClientRequest<...>; }
S>
(type parameter) K
: never : never : never export type Callback =
(type parameter) S
(opts:
type Callback = (opts: CallbackOptions) => unknown
CallbackOptions) => unknown
(parameter) opts: CallbackOptions
interface CallbackOptions {
interface CallbackOptions
path: string[]
interface CallbackOptions
// eslint-disable-next-line @typescript-eslint/no-explicit-any args: any[]
(property) CallbackOptions.path: string[]
} export type ObjectType
(property) CallbackOptions.args: any[]
<T = unknown> = {
type ObjectType<T = unknown> = { [key: string]: T; }
[key: string]:
(type parameter) T in type ObjectType<T = unknown>
T
(parameter) key: string
}
(type parameter) T in type ObjectType<T = unknown>
import { deepMerge, mergePath, removeIndexString, replaceUrlParam, replaceUrlProtocol, } from './utils' describe('mergePath', () => { it('Should merge paths correctly', () => { expect(mergePath('http://localhost', '/api')).toBe('http://localhost/api')expect(mergePath('http://localhost/', '/api')).toBe('http://localhost/api')
(alias) mergePath(base: string, path: string): string import mergePath
expect(mergePath('http://localhost', 'api')).toBe('http://localhost/api')
(alias) mergePath(base: string, path: string): string import mergePath
expect(mergePath('http://localhost/', 'api')).toBe('http://localhost/api')
(alias) mergePath(base: string, path: string): string import mergePath
expect(mergePath('http://localhost/', '/')).toBe('http://localhost/')
(alias) mergePath(base: string, path: string): string import mergePath
}) }) describe('replaceUrlParams', () => { it('Should replace correctly', () => { const url = 'http://localhost/posts/:postId/comments/:commentId'
(alias) mergePath(base: string, path: string): string import mergePath
const params = {
const url: "http://localhost/posts/:postId/comments/:commentId"
postId: '123',
const params: { postId: string; commentId: string; }
commentId: '456',
(property) postId: string
} const replacedUrl =
(property) commentId: string
replaceUrlParam
const replacedUrl: string
(url,
(alias) replaceUrlParam(urlString: string, params: Record<string, string | undefined>): string import replaceUrlParam
params)
const url: "http://localhost/posts/:postId/comments/:commentId"
expect(replacedUrl).toBe('http://localhost/posts/123/comments/456')
const params: { postId: string; commentId: string; }
}) it('Should replace correctly when there is regex pattern', () => { const url = 'http://localhost/posts/:postId{[abc]+}/comments/:commentId{[0-9]+}'
const replacedUrl: string
const params = {
const url: "http://localhost/posts/:postId{[abc]+}/comments/:commentId{[0-9]+}"
postId: 'abc',
const params: { postId: string; commentId: string; }
commentId: '456',
(property) postId: string
} const replacedUrl =
(property) commentId: string
replaceUrlParam
const replacedUrl: string
(url,
(alias) replaceUrlParam(urlString: string, params: Record<string, string | undefined>): string import replaceUrlParam
params)
const url: "http://localhost/posts/:postId{[abc]+}/comments/:commentId{[0-9]+}"
expect(replacedUrl).toBe('http://localhost/posts/abc/comments/456')
const params: { postId: string; commentId: string; }
}) it('Should replace correctly when there is regex pattern with length limit', () => { const url = 'http://localhost/year/:year{[1-9]{1}[0-9]{3}}/month/:month{[0-9]{2}}'
const replacedUrl: string
const params = {
const url: "http://localhost/year/:year{[1-9]{1}[0-9]{3}}/month/:month{[0-9]{2}}"
year: '2024',
const params: { year: string; month: string; }
month: '2',
(property) year: string
} const replacedUrl =
(property) month: string
replaceUrlParam
const replacedUrl: string
(url,
(alias) replaceUrlParam(urlString: string, params: Record<string, string | undefined>): string import replaceUrlParam
params)
const url: "http://localhost/year/:year{[1-9]{1}[0-9]{3}}/month/:month{[0-9]{2}}"
expect(replacedUrl).toBe('http://localhost/year/2024/month/2')
const params: { year: string; month: string; }
}) it('Should replace correctly when it has optional parameters', () => { const url = 'http://localhost/something/:firstId/:secondId/:version?'
const replacedUrl: string
const params = {
const url: "http://localhost/something/:firstId/:secondId/:version?"
firstId: '123',
const params: { firstId: string; secondId: string; version: undefined; }
secondId: '456',
(property) firstId: string
version: undefined,
(property) secondId: string
} const replacedUrl =
(property) version: undefined
replaceUrlParam
const replacedUrl: string
(url,
(alias) replaceUrlParam(urlString: string, params: Record<string, string | undefined>): string import replaceUrlParam
params)
const url: "http://localhost/something/:firstId/:secondId/:version?"
expect(replacedUrl).toBe('http://localhost/something/123/456')
const params: { firstId: string; secondId: string; version: undefined; }
}) }) describe('replaceUrlProtocol', () => { it('Should replace http to ws', () => { const url = 'http://localhost'
const replacedUrl: string
const newUrl =
const url: "http://localhost"
replaceUrlProtocol
const newUrl: string
(url, 'ws')
(alias) replaceUrlProtocol(urlString: string, protocol: "ws" | "http"): string import replaceUrlProtocol
expect(newUrl).toBe('ws://localhost')
const url: "http://localhost"
}) it('Should replace https to wss', () => { const url = 'https://localhost'
const newUrl: string
const newUrl =
const url: "https://localhost"
replaceUrlProtocol
const newUrl: string
(url, 'ws')
(alias) replaceUrlProtocol(urlString: string, protocol: "ws" | "http"): string import replaceUrlProtocol
expect(newUrl).toBe('wss://localhost')
const url: "https://localhost"
}) it('Should replace ws to http', () => { const url = 'ws://localhost'
const newUrl: string
const newUrl =
const url: "ws://localhost"
replaceUrlProtocol
const newUrl: string
(url, 'http')
(alias) replaceUrlProtocol(urlString: string, protocol: "ws" | "http"): string import replaceUrlProtocol
expect(newUrl).toBe('http://localhost')
const url: "ws://localhost"
}) it('Should replace wss to https', () => { const url = 'wss://localhost'
const newUrl: string
const newUrl =
const url: "wss://localhost"
replaceUrlProtocol
const newUrl: string
(url, 'http')
(alias) replaceUrlProtocol(urlString: string, protocol: "ws" | "http"): string import replaceUrlProtocol
expect(newUrl).toBe('https://localhost')
const url: "wss://localhost"
}) }) describe('removeIndexString', () => { it('Should remove last `/index` string', () => { let url = 'http://localhost/index'
const newUrl: string
let newUrl =
let url: string
removeIndexString
let newUrl: string
(url)
(alias) removeIndexString(urlSting: string): string import removeIndexString
expect(newUrl).toBe('http://localhost/')
let url: string
url = '/index'
let newUrl: string
newUrl =
let url: string
removeIndexString
let newUrl: string
(url)
(alias) removeIndexString(urlSting: string): string import removeIndexString
expect(newUrl).toBe('')
let url: string
url = '/sub/index'
let newUrl: string
newUrl =
let url: string
removeIndexString
let newUrl: string
(url)
(alias) removeIndexString(urlSting: string): string import removeIndexString
expect(newUrl).toBe('/sub')
let url: string
url = '/subindex'
let newUrl: string
newUrl =
let url: string
removeIndexString
let newUrl: string
(url)
(alias) removeIndexString(urlSting: string): string import removeIndexString
expect(newUrl).toBe('/subindex')
let url: string
}) }) describe('deepMerge', () => { it('should return the source object if the target object is not an object', () => { const target = null
let newUrl: string
const source = 'not an object' as unknown as
const target: null
Record
const source: Record<string, unknown>
const result =
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TdeepMerge
const result: null
(target,
(alias) deepMerge<null>(target: null, source: Record<string, unknown>): null import deepMerge
source)
const target: null
expect(result).toEqual
const source: Record<string, unknown>
(source)
const result: null
}) it('should merge two objects with object properties', () => { expect( deepMerge(
const source: Record<string, unknown>
{ headers: {
(alias) deepMerge<{ headers: { hono: string; }; timeout: number; params: {}; }>(target: { headers: { hono: string; }; timeout: number; params: {}; }, source: Record<string, unknown>): { headers: { hono: string; }; timeout: number; params: {}; } import deepMerge
hono: '1' },
(property) headers: { hono: string; }
timeout: 2,
(property) hono: string
params: {} },
(property) timeout: number
{ headers: {
(property) params: {}
hono: '2',
(property) headers: { hono: string; demo: number; }
demo: 2 },
(property) hono: string
params: undefined }
(property) demo: number
) ).toStrictEqual({ params: undefined,
(property) params: undefined
headers: {
(property) params: undefined
hono: '2',
(property) headers: { hono: string; demo: number; }
demo: 2 },
(property) hono: string
timeout: 2,
(property) demo: number
}) }) })
(property) timeout: number
import type { ObjectType } from './types' export const mergePath =(base: string,
const mergePath: (base: string, path: string) => string
path: string) => {
(parameter) base: string
base =
(parameter) path: string
base
(parameter) base: string
.replace(/\/+$/, '')
(parameter) base: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
base =replaceValue
— The replacement text.base + '/'
(parameter) base: string
path =
(parameter) base: string
path
(parameter) path: string
.replace(/^\/+/, '')
(parameter) path: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
return base +replaceValue
— The replacement text.path
(parameter) base: string
} export const replaceUrlParam =
(parameter) path: string
(urlString: string,
const replaceUrlParam: (urlString: string, params: Record<string, string | undefined>) => string
params:
(parameter) urlString: string
Record
(parameter) params: Record<string, string | undefined>
) => { for (const [k,
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tv] of
const k: string
Object
const v: string | undefined
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | undefined>(o: { [s: string]: string | undefined; } | ArrayLike<string | undefined>): [string, string | undefined][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(params)) {o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.const reg = new
(parameter) params: Record<string, string | undefined>
RegExp('/:' +
const reg: RegExp
k + '(?:{[^/]+})?\\??')
var RegExp: RegExpConstructor new (pattern: RegExp | string, flags?: string) => RegExp (+2 overloads)
urlString =
const k: string
urlString
(parameter) urlString: string
.replace
(parameter) urlString: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
(reg,replaceValue
— The replacement text.v ? `/$
const reg: RegExp
{v}` : '')
const v: string | undefined
} return urlString
const v: string
} export const replaceUrlProtocol =
(parameter) urlString: string
(urlString: string,
const replaceUrlProtocol: (urlString: string, protocol: "ws" | "http") => string
protocol: 'ws' | 'http') => {
(parameter) urlString: string
switch (protocol) {
(parameter) protocol: "ws" | "http"
case 'ws': return urlString
(parameter) protocol: "ws" | "http"
.replace(/^http/, 'ws')
(parameter) urlString: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
case 'http': return urlStringreplaceValue
— The replacement text..replace(/^ws/, 'http')
(parameter) urlString: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
} } export const removeIndexString =replaceValue
— The replacement text.(urlSting: string) => {
const removeIndexString: (urlSting: string) => string
if (/^https?:\/\/[^\/]+?\/index$/.test
(parameter) urlSting: string
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
(urlSting)) {string
— String on which to perform the search.return urlSting
(parameter) urlSting: string
.replace(/\/index$/, '/')
(parameter) urlSting: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
} return urlStingreplaceValue
— The replacement text..replace(/\/index$/, '')
(parameter) urlSting: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
} function isObjectreplaceValue
— The replacement text.(item: unknown):
function isObject(item: unknown): item is ObjectType
item is
(parameter) item: unknown
ObjectType {
(parameter) item: unknown
return typeof item === 'object' &&
(alias) type ObjectType<T = unknown> = { [key: string]: T; } import ObjectType
item !== null &&
(parameter) item: unknown
!Array
(parameter) item: object | null
.isArray
var Array: ArrayConstructor
(item)
(method) ArrayConstructor.isArray(arg: any): arg is any[]
} export function deepMerge
(parameter) item: object
<T>
function deepMerge<T>(target: T, source: Record<string, unknown>): T
(target:
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
T,
(parameter) target: T
source:
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
Record
(parameter) source: Record<string, unknown>
): T {
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tif (!isObject
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
(target) &&
function isObject(item: unknown): item is ObjectType
!isObject
(parameter) target: T
(source)) {
function isObject(item: unknown): item is ObjectType
return source as
(parameter) source: Record<string, unknown>
T
(parameter) source: never
} const merged = { ..
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
.target } as
const merged: ObjectType<T>
ObjectType
(parameter) target: T
<T>
(alias) type ObjectType<T = unknown> = { [key: string]: T; } import ObjectType
for (const key in
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
source) {
const key: string
const value =
(parameter) source: Record<string, unknown>
source
const value: unknown
[key]
(parameter) source: Record<string, unknown>
if (isObject
const key: string
(merged
function isObject(item: unknown): item is ObjectType
[key]) &&
const merged: ObjectType<T>
isObject
const key: string
(value)) {
function isObject(item: unknown): item is ObjectType
merged
const value: unknown
[key] =
const merged: ObjectType<T>
deepMerge
const key: string
(merged
function deepMerge<T>(target: T, source: Record<string, unknown>): T
[key],
const merged: ObjectType<T>
value)
const key: string
} else { merged
const value: ObjectType
[key] =
const merged: ObjectType<T>
value as
const key: string
T[keyof
const value: unknown
T] &
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
T
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
} } return merged as
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
T
const merged: ObjectType<T>
}
(type parameter) T in deepMerge<T>(target: T, source: Record<string, unknown>): T
import { compose } from './compose' import { Context } from './context' import type { Params } from './router' type C = {req:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Record
(property) req: Record<string, string>
res:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TRecord
(property) res: Record<string, string>
finalized: boolean
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T} type MiddlewareTuple = [
(property) finalized: boolean
[Function, unknown],
type MiddlewareTuple = [[Function, unknown], Params]
Params]
interface Function
Creates a new function.class ExpectedError extends
(alias) type Params = { [x: string]: string; } import Params
Type representing a map of parameters.Error {}
class ExpectedError
function buildMiddlewareTuple
var Error: ErrorConstructor
(fn:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
Function,
(parameter) fn: Function
params?:
interface Function
Creates a new function.Params):
(parameter) params: Params | undefined
MiddlewareTuple {
(alias) type Params = { [x: string]: string; } import Params
Type representing a map of parameters.return [[fn, undefined],
type MiddlewareTuple = [[Function, unknown], Params]
params || {}]
(parameter) fn: Function
} describe('compose', () => { const middleware:
(parameter) params: Params | undefined
MiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const a = async
type MiddlewareTuple = [[Function, unknown], Params]
(c:
const a: (c: C, next: Function) => Promise<void>
C,
(parameter) c: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
c
interface Function
Creates a new function..req['log'] = 'log'
(parameter) c: C
await next()
(property) req: Record<string, string>
} const b = async
(parameter) next: Function
(c:
const b: (c: C, next: Function) => Promise<void>
C,
(parameter) c: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.c
(parameter) next: Function
.res['headers'] = 'custom-header'
(parameter) c: C
} const c = async
(property) res: Record<string, string>
(c:
const c: (c: C, next: Function) => Promise<void>
C,
(parameter) c: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
c
interface Function
Creates a new function..req['xxx'] = 'yyy'
(parameter) c: C
await next()
(property) req: Record<string, string>
c
(parameter) next: Function
.res['zzz'] =
(parameter) c: C
c
(property) res: Record<string, string>
.req['xxx']
(parameter) c: C
} const handler = async
(property) req: Record<string, string>
(c:
const handler: (c: C, next: Function) => Promise<void>
C,
(parameter) c: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
c
interface Function
Creates a new function..req['log'] = `$
(parameter) c: C
{c
(property) req: Record<string, string>
.req.log} message`
(parameter) c: C
await next()
(property) req: Record<string, string>
c
(parameter) next: Function
.res = {
(parameter) c: C
message: 'new response' }
(property) res: Record<string, string>
} middleware
(property) message: string
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(a))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const a: (c: C, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(b))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const b: (c: C, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(c))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const c: (c: C, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(handler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
it('Request', async () => { const c:
const handler: (c: C, next: Function) => Promise<void>
C = {
const c: C
req: {},
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
res: {},
(property) req: Record<string, string>
finalized: false }
(property) res: Record<string, string>
const composed =
(property) finalized: boolean
compose
const composed: (context: C, next?: Function) => Promise<C>
(alias) compose<C, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: C, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<C>(middleware)
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
const context = await
const middleware: MiddlewareTuple[]
composed
const context: C
(c)
const composed: (context: C, next?: Function) => Promise<C>
expect(context
const c: C
.req['log']).not.toBeNull()
const context: C
expect(context
(property) req: Record<string, string>
.req['log']).toBe('log message')
const context: C
expect(context
(property) req: Record<string, string>
.req['xxx']).toBe('yyy')
const context: C
}) it('Response', async () => { const c:
(property) req: Record<string, string>
C = {
const c: C
req: {},
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
res: {},
(property) req: Record<string, string>
finalized: false }
(property) res: Record<string, string>
const composed =
(property) finalized: boolean
compose
const composed: (context: C, next?: Function) => Promise<C>
(alias) compose<C, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: C, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<C>(middleware)
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
const context = await
const middleware: MiddlewareTuple[]
composed
const context: C
(c)
const composed: (context: C, next?: Function) => Promise<C>
expect(context
const c: C
.res['headers']).not.toBeNull()
const context: C
expect(context
(property) res: Record<string, string>
.res['headers']).toBe('custom-header')
const context: C
expect(context
(property) res: Record<string, string>
.res['message']).toBe('new response')
const context: C
expect(context
(property) res: Record<string, string>
.res['zzz']).toBe('yyy')
const context: C
}) }) describe('compose with returning a promise, non-async function', () => { const handlers:
(property) res: Record<string, string>
MiddlewareTuple[] = [
const handlers: MiddlewareTuple[]
buildMiddlewareTuple(() => {
type MiddlewareTuple = [[Function, unknown], Params]
return new Promise(
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
var Promise: PromiseConstructor new <unknown>(executor: (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void) => Promise<unknown>
Creates a new Promise.@param
(resolve) =>executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.setTimeout(() => {
(parameter) resolve: (value: unknown) => void
resolve({
function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
MDN Referencemessage: 'new response' })
(parameter) resolve: (value: unknown) => void
}, 1) ) }), ] it('Response', async () => { const c:
(property) message: string
C = {
const c: C
req: {},
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
res: {},
(property) req: Record<string, string>
finalized: false }
(property) res: Record<string, string>
const composed =
(property) finalized: boolean
compose
const composed: (context: C, next?: Function) => Promise<C>
(alias) compose<C, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: C, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<C>(handlers)
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
const context = await
const handlers: MiddlewareTuple[]
composed
const context: C
(c)
const composed: (context: C, next?: Function) => Promise<C>
expect(context
const c: C
.res['message']).toBe('new response')
const context: C
}) }) describe('Handler and middlewares', () => { const middleware:
(property) res: Record<string, string>
MiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const req = new
type MiddlewareTuple = [[Function, unknown], Params]
Request('http://localhost/')
const req: Request
const c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context = new
const c: Context<any, any, {}>
Context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const mHandlerFoo = async
const req: Request
(c:
const mHandlerFoo: (c: Context, next: Function) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
c
interface Function
Creates a new function..req
(parameter) c: Context<any, any, {}>
.raw
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.headers
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.append('x-header-foo', 'foo')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.await next()
(method) Headers.append(name: string, value: string): void
MDN Reference} const mHandlerBar = async
(parameter) next: Function
(c:
const mHandlerBar: (c: Context, next: Function) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.c
(parameter) next: Function
.header('x-header-bar', 'bar')
(parameter) c: Context<any, any, {}>
} const handler =
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
(c:
const handler: (c: Context) => Response & TypedResponse<string, StatusCode, "text">
Context) => {
(parameter) c: Context<any, any, {}>
const foo =
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
c
const foo: string
.req
(parameter) c: Context<any, any, {}>
.header('x-header-foo') || ''
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
return c
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
.text
(parameter) c: Context<any, any, {}>
(foo)
(property) Context<any, any, {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
} middleware
const foo: string
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandlerFoo))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const mHandlerFoo: (c: Context, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandlerBar))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const mHandlerBar: (c: Context, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(handler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
it('Should return 200 Response', async () => { const composed =
const handler: (c: Context) => Response & TypedResponse<string, StatusCode, "text">
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware)
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
const context = await
const middleware: MiddlewareTuple[]
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
const res =
const c: Context<any, any, {}>
context
const res: Response
.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(res).not.toBeNull()_res
— The Response object to set.expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('foo')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('x-header-bar')).toBe('bar')
(property) Response.headers: Headers
MDN Reference}) }) describe('compose with Context - 200 success', () => { const middleware:
(method) Headers.get(name: string): string | null
MDN ReferenceMiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const req = new
type MiddlewareTuple = [[Function, unknown], Params]
Request('http://localhost/')
const req: Request
const c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context = new
const c: Context<any, any, {}>
Context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const handler =
const req: Request
(c:
const handler: (c: Context) => Response & TypedResponse<"Hello", StatusCode, "text">
Context) => {
(parameter) c: Context<any, any, {}>
return c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('Hello')
(parameter) c: Context<any, any, {}>
} const mHandler = async
(property) Context<any, any, {}>.text: TextRespond <"Hello", StatusCode>(text: "Hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
(_c:
const mHandler: (_c: Context, next: Function) => Promise<void>
Context,
(parameter) _c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.} middleware
(parameter) next: Function
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(handler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const handler: (c: Context) => Response & TypedResponse<"Hello", StatusCode, "text">
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
it('Should return 200 Response', async () => { const composed =
const mHandler: (_c: Context, next: Function) => Promise<void>
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware)
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
const context = await
const middleware: MiddlewareTuple[]
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.res).not.toBeNull()
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(context_res
— The Response object to set..res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.status).toBe(200)_res
— The Response object to set.expect(await context
(property) Response.status: number
MDN Reference.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).toBe('Hello')_res
— The Response object to set.}) }) describe('compose with Context - 404 not found', () => { const middleware:
(method) Body.text(): Promise<string>
MDN ReferenceMiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const req = new
type MiddlewareTuple = [[Function, unknown], Params]
Request('http://localhost/')
const req: Request
const onNotFound =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.(c:
const onNotFound: (c: Context) => Response & TypedResponse<"onNotFound", 404, "text">
Context) => {
(parameter) c: Context<any, any, {}>
return c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('onNotFound', 404)
(parameter) c: Context<any, any, {}>
} const onNotFoundAsync = async
(property) Context<any, any, {}>.text: TextRespond <"onNotFound", 404>(text: "onNotFound", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"onNotFound", 404, "text"> (+1 overload)
(c:
const onNotFoundAsync: (c: Context) => Promise<Response & TypedResponse<"onNotFoundAsync", 404, "text">>
Context) => {
(parameter) c: Context<any, any, {}>
return c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('onNotFoundAsync', 404)
(parameter) c: Context<any, any, {}>
} const mHandler = async
(property) Context<any, any, {}>.text: TextRespond <"onNotFoundAsync", 404>(text: "onNotFoundAsync", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"onNotFoundAsync", 404, "text"> (+1 overload)
(_c:
const mHandler: (_c: Context, next: Function) => Promise<void>
Context,
(parameter) _c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.} middleware
(parameter) next: Function
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
it('Should return 404 Response', async () => { const c:
const mHandler: (_c: Context, next: Function) => Promise<void>
Context = new
const c: Context<any, any, {}>
Context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const composed =
const req: Request
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware, undefined,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
onNotFound)
const middleware: MiddlewareTuple[]
const context = await
const onNotFound: (c: Context) => Response & TypedResponse<"onNotFound", 404, "text">
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.res).not.toBeNull()
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(context_res
— The Response object to set..res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.status).toBe(404)_res
— The Response object to set.expect(await context
(property) Response.status: number
MDN Reference.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).toBe('onNotFound')_res
— The Response object to set.expect(context
(method) Body.text(): Promise<string>
MDN Reference.finalized).toBe(true)
const context: Context<any, any, {}>
}) it('Should return 404 Response - async handler', async () => { const c:
(property) Context<any, any, {}>.finalized: boolean
Context = new
const c: Context<any, any, {}>
Context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const composed =
const req: Request
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware, undefined,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
onNotFoundAsync)
const middleware: MiddlewareTuple[]
const context = await
const onNotFoundAsync: (c: Context) => Promise<Response & TypedResponse<"onNotFoundAsync", 404, "text">>
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.res).not.toBeNull()
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(context_res
— The Response object to set..res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.status).toBe(404)_res
— The Response object to set.expect(await context
(property) Response.status: number
MDN Reference.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).toBe('onNotFoundAsync')_res
— The Response object to set.expect(context
(method) Body.text(): Promise<string>
MDN Reference.finalized).toBe(true)
const context: Context<any, any, {}>
}) }) describe('compose with Context - 401 not authorized', () => { const middleware:
(property) Context<any, any, {}>.finalized: boolean
MiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const req = new
type MiddlewareTuple = [[Function, unknown], Params]
Request('http://localhost/')
const req: Request
const c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context = new
const c: Context<any, any, {}>
Context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const handler =
const req: Request
(c:
const handler: (c: Context) => Response & TypedResponse<"Hello", StatusCode, "text">
Context) => {
(parameter) c: Context<any, any, {}>
return c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('Hello')
(parameter) c: Context<any, any, {}>
} const mHandler = async
(property) Context<any, any, {}>.text: TextRespond <"Hello", StatusCode>(text: "Hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
(c:
const mHandler: (c: Context, next: Function) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.c
(parameter) next: Function
.res = new
(parameter) c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response('Not authorized', {_res
— The Response object to set.status: 401 })
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.} middleware
(property) ResponseInit.status?: number | undefined
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const mHandler: (c: Context, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(handler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
it('Should return 401 Response', async () => { const composed =
const handler: (c: Context) => Response & TypedResponse<"Hello", StatusCode, "text">
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware)
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
const context = await
const middleware: MiddlewareTuple[]
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.res).not.toBeNull()
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(context_res
— The Response object to set..res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.status).toBe(401)_res
— The Response object to set.expect(await context
(property) Response.status: number
MDN Reference.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).toBe('Not authorized')_res
— The Response object to set.expect(context
(method) Body.text(): Promise<string>
MDN Reference.finalized).toBe(true)
const context: Context<any, any, {}>
}) }) describe('compose with Context - next() below', () => { const middleware:
(property) Context<any, any, {}>.finalized: boolean
MiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const req = new
type MiddlewareTuple = [[Function, unknown], Params]
Request('http://localhost/')
const req: Request
const c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context = new
const c: Context<any, any, {}>
Context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const handler =
const req: Request
(c:
const handler: (c: Context) => Response & TypedResponse<string, StatusCode, "text">
Context) => {
(parameter) c: Context<any, any, {}>
const message =
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
c
const message: string
.req
(parameter) c: Context<any, any, {}>
.header('x-custom') || 'blank'
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
return c
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
.text
(parameter) c: Context<any, any, {}>
(message)
(property) Context<any, any, {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
} const mHandler = async
const message: string
(c:
const mHandler: (c: Context, next: Function) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
c
interface Function
Creates a new function..req
(parameter) c: Context<any, any, {}>
.raw
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.headers
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.append('x-custom', 'foo')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.await next()
(method) Headers.append(name: string, value: string): void
MDN Reference} middleware
(parameter) next: Function
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const mHandler: (c: Context, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(handler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
it('Should return 200 Response', async () => { const composed =
const handler: (c: Context) => Response & TypedResponse<string, StatusCode, "text">
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware)
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
const context = await
const middleware: MiddlewareTuple[]
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.res).not.toBeNull()
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(context_res
— The Response object to set..res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.status).toBe(200)_res
— The Response object to set.expect(await context
(property) Response.status: number
MDN Reference.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).toBe('foo')_res
— The Response object to set.expect(context
(method) Body.text(): Promise<string>
MDN Reference.finalized).toBe(true)
const context: Context<any, any, {}>
}) }) describe('compose with Context - 500 error', () => { const middleware:
(property) Context<any, any, {}>.finalized: boolean
MiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const req = new
type MiddlewareTuple = [[Function, unknown], Params]
Request('http://localhost/')
const req: Request
const c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context = new
const c: Context<any, any, {}>
Context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.it('Error on handler', async () => { const handler = () => {
const req: Request
throw new Error()
const handler: () => never
} const mHandler = async
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
(_c:
const mHandler: (_c: Context, next: Function) => Promise<void>
Context,
(parameter) _c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.} middleware
(parameter) next: Function
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const mHandler: (_c: Context, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(handler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
const onNotFound =
const handler: () => never
(c:
const onNotFound: (c: Context) => Response & TypedResponse<"NotFound", 404, "text">
Context) =>
(parameter) c: Context<any, any, {}>
c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('NotFound', 404)
(parameter) c: Context<any, any, {}>
const onError =
(property) Context<any, any, {}>.text: TextRespond <"NotFound", 404>(text: "NotFound", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"NotFound", 404, "text"> (+1 overload)
(_error:
const onError: (_error: Error, c: Context) => Response & TypedResponse<"onError", 500, "text">
Error,
(parameter) _error: Error
c:
interface Error
Context) =>
(parameter) c: Context<any, any, {}>
c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('onError', 500)
(parameter) c: Context<any, any, {}>
const composed =
(property) Context<any, any, {}>.text: TextRespond <"onError", 500>(text: "onError", status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"onError", 500, "text"> (+1 overload)
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
onError,
const middleware: MiddlewareTuple[]
onNotFound)
const onError: (_error: Error, c: Context) => Response & TypedResponse<"onError", 500, "text">
const context = await
const onNotFound: (c: Context) => Response & TypedResponse<"NotFound", 404, "text">
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.res).not.toBeNull()
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(context_res
— The Response object to set..res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.status).toBe(500)_res
— The Response object to set.expect(await context
(property) Response.status: number
MDN Reference.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).toBe('onError')_res
— The Response object to set.expect(context
(method) Body.text(): Promise<string>
MDN Reference.finalized).toBe(true)
const context: Context<any, any, {}>
}) it('Error on handler - async', async () => { const handler = () => {
(property) Context<any, any, {}>.finalized: boolean
throw new Error()
const handler: () => never
} middleware
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(handler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
const onError = async
const handler: () => never
(_error:
const onError: (_error: Error, c: Context) => Promise<Response & TypedResponse<"onError", 500, "text">>
Error,
(parameter) _error: Error
c:
interface Error
Context) =>
(parameter) c: Context<any, any, {}>
c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('onError', 500)
(parameter) c: Context<any, any, {}>
const composed =
(property) Context<any, any, {}>.text: TextRespond <"onError", 500>(text: "onError", status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"onError", 500, "text"> (+1 overload)
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
onError)
const middleware: MiddlewareTuple[]
const context = await
const onError: (_error: Error, c: Context) => Promise<Response & TypedResponse<"onError", 500, "text">>
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.res).not.toBeNull()
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(context_res
— The Response object to set..res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.status).toBe(500)_res
— The Response object to set.expect(await context
(property) Response.status: number
MDN Reference.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).toBe('onError')_res
— The Response object to set.expect(context
(method) Body.text(): Promise<string>
MDN Reference.finalized).toBe(true)
const context: Context<any, any, {}>
}) it('Run all the middlewares', async () => { const ctx:
(property) Context<any, any, {}>.finalized: boolean
C = {
const ctx: C
req: {},
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
res: {},
(property) req: Record<string, string>
finalized: false }
(property) res: Record<string, string>
const stack: number[] = []
(property) finalized: boolean
const middlewares = [
const stack: number[]
async (_ctx:
const middlewares: MiddlewareTuple[]
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
stack
interface Function
Creates a new function..push(0)
const stack: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.}, async (_ctx:
(parameter) next: Function
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
stack
interface Function
Creates a new function..push(1)
const stack: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.}, async (_ctx:
(parameter) next: Function
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
stack
interface Function
Creates a new function..push(2)
const stack: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.}, ].map(
(parameter) next: Function
(method) Array<(_ctx: C, next: Function) => Promise<void>>.map<MiddlewareTuple>(callbackfn: (value: (_ctx: C, next: Function) => Promise<void>, index: number, array: ((_ctx: C, next: Function) => Promise<void>)[]) => MiddlewareTuple, thisArg?: any): MiddlewareTuple[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(h) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.buildMiddlewareTuple
(parameter) h: (_ctx: C, next: Function) => Promise<void>
(h))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
const composed =
(parameter) h: (_ctx: C, next: Function) => Promise<void>
compose
const composed: (context: ComposeContext, next?: Function) => Promise<ComposeContext>
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(middlewares)await composed
const middlewares: MiddlewareTuple[]
(ctx)
const composed: (context: ComposeContext, next?: Function) => Promise<ComposeContext>
expect(stack).toEqual([0, 1, 2])
const ctx: C
}) }) describe('compose with Context - not finalized', () => { const req = new
const stack: number[]
Request('http://localhost/')
const req: Request
const c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context = new
const c: Context<any, any, {}>
Context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.const onNotFound =
const req: Request
(c:
const onNotFound: (c: Context) => Response & TypedResponse<"onNotFound", 404, "text">
Context) => {
(parameter) c: Context<any, any, {}>
return c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('onNotFound', 404)
(parameter) c: Context<any, any, {}>
} it('Should not be finalized - lack `next()`', async () => { const middleware:
(property) Context<any, any, {}>.text: TextRespond <"onNotFound", 404>(text: "onNotFound", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"onNotFound", 404, "text"> (+1 overload)
MiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const mHandler = async
type MiddlewareTuple = [[Function, unknown], Params]
(_c:
const mHandler: (_c: Context, next: Function) => Promise<void>
Context,
(parameter) _c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.} const mHandler2 = async () => {}
(parameter) next: Function
middleware
const mHandler2: () => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware
const mHandler: (_c: Context, next: Function) => Promise<void>
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandler2))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
const composed =
const mHandler2: () => Promise<void>
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware, undefined,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
onNotFound)
const middleware: MiddlewareTuple[]
const context = await
const onNotFound: (c: Context) => Response & TypedResponse<"onNotFound", 404, "text">
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.finalized).toBe(false)
const context: Context<any, any, {}>
}) it('Should not be finalized - lack `return Response`', async () => { const middleware2:
(property) Context<any, any, {}>.finalized: boolean
MiddlewareTuple[] = []
const middleware2: MiddlewareTuple[]
const mHandler3 = async
type MiddlewareTuple = [[Function, unknown], Params]
(_c:
const mHandler3: (_c: Context, next: Function) => Promise<void>
Context,
(parameter) _c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.} const handler = async () => {}
(parameter) next: Function
middleware2
const handler: () => Promise<void>
.push
const middleware2: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(mHandler3))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
middleware2
const mHandler3: (_c: Context, next: Function) => Promise<void>
.push
const middleware2: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(handler))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
const composed =
const handler: () => Promise<void>
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(middleware2, undefined,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
onNotFound)
const middleware2: MiddlewareTuple[]
const context = await
const onNotFound: (c: Context) => Response & TypedResponse<"onNotFound", 404, "text">
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
expect(context
const c: Context<any, any, {}>
.finalized).toBe(false)
const context: Context<any, any, {}>
}) }) describe('Compose', function () { it('should get executed order one by one', async () => { const arr: number[] = []
(property) Context<any, any, {}>.finalized: boolean
const stack = []
const arr: number[]
const called: boolean[] = []
const stack: any[]
stack
const called: boolean[]
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(_context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _context: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
called
interface Function
Creates a new function..push(true)
const called: boolean[]
(method) Array<boolean>.push(...items: boolean[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
arritems
— New elements to add to the array..push(1)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.arr
(parameter) next: Function
.push(6)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) stackitems
— New elements to add to the array..push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(_context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _context: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
called
interface Function
Creates a new function..push(true)
const called: boolean[]
(method) Array<boolean>.push(...items: boolean[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
arritems
— New elements to add to the array..push(2)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.arr
(parameter) next: Function
.push(5)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) stackitems
— New elements to add to the array..push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(_context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _context: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
called
interface Function
Creates a new function..push(true)
const called: boolean[]
(method) Array<boolean>.push(...items: boolean[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
arritems
— New elements to add to the array..push(3)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.arr
(parameter) next: Function
.push(4)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) await composeitems
— New elements to add to the array.
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)({res: null,
const stack: MiddlewareTuple[]
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.expect(called).toEqual([true, true, true])
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.expect(arr).toEqual([1, 2, 3, 4, 5, 6])
const called: boolean[]
}) it('should not get executed if previous next() not triggered', async () => { const arr: number[] = []
const arr: number[]
const stack = []
const arr: number[]
const called: boolean[] = []
const stack: any[]
stack
const called: boolean[]
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(_context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _context: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
called
interface Function
Creates a new function..push(true)
const called: boolean[]
(method) Array<boolean>.push(...items: boolean[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
arritems
— New elements to add to the array..push(1)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.arr
(parameter) next: Function
.push(6)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) stackitems
— New elements to add to the array..push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(async () => {items
— New elements to add to the array.called
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
.push(true)
const called: boolean[]
(method) Array<boolean>.push(...items: boolean[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
arritems
— New elements to add to the array..push(2)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) stackitems
— New elements to add to the array..push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(_context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _context: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
called
interface Function
Creates a new function..push(true)
const called: boolean[]
(method) Array<boolean>.push(...items: boolean[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
arritems
— New elements to add to the array..push(3)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.arr
(parameter) next: Function
.push(4)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) await composeitems
— New elements to add to the array.
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)({res: null,
const stack: MiddlewareTuple[]
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.expect(called).toEqual([true, true])
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.expect(arr).toEqual([1, 2, 6])
const called: boolean[]
}) it('should be able to be called twice', async () => { type C = {
const arr: number[]
arr: number[]
type C = { arr: number[]; }
} const stack = []
(property) arr: number[]
stack
const stack: any[]
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) context: C
next:
type C = { arr: number[]; }
Function) => {
(parameter) next: Function
context
interface Function
Creates a new function..arr
(parameter) context: C
.push(1)
(property) arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.context
(parameter) next: Function
.arr
(parameter) context: C
.push(6)
(property) arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) stackitems
— New elements to add to the array..push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) context: C
next:
type C = { arr: number[]; }
Function) => {
(parameter) next: Function
context
interface Function
Creates a new function..arr
(parameter) context: C
.push(2)
(property) arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.context
(parameter) next: Function
.arr
(parameter) context: C
.push(5)
(property) arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) stackitems
— New elements to add to the array..push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) context: C
next:
type C = { arr: number[]; }
Function) => {
(parameter) next: Function
context
interface Function
Creates a new function..arr
(parameter) context: C
.push(3)
(property) arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.context
(parameter) next: Function
.arr
(parameter) context: C
.push(4)
(property) arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) const fn =items
— New elements to add to the array.compose
const fn: (context: ComposeContext, next?: Function) => Promise<ComposeContext>
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)const ctx1 = {
const stack: MiddlewareTuple[]
arr: [] as number[],
const ctx1: { arr: number[]; res: null; finalized: boolean; }
res: null,
(property) arr: number[]
finalized: false }
(property) res: null
const ctx2 = {
(property) finalized: boolean
arr: [] as number[],
const ctx2: { arr: number[]; res: null; finalized: boolean; }
res: null,
(property) arr: number[]
finalized: false }
(property) res: null
const out = [1, 2, 3, 4, 5, 6]
(property) finalized: boolean
await fn
const out: number[]
(ctx1)
const fn: (context: ComposeContext, next?: Function) => Promise<ComposeContext>
expect(out).toEqual
const ctx1: { arr: number[]; res: null; finalized: boolean; }
(ctx1
const out: number[]
.arr)
const ctx1: { arr: number[]; res: null; finalized: boolean; }
await fn
(property) arr: number[]
(ctx2)
const fn: (context: ComposeContext, next?: Function) => Promise<ComposeContext>
expect(out).toEqual
const ctx2: { arr: number[]; res: null; finalized: boolean; }
(ctx2
const out: number[]
.arr)
const ctx2: { arr: number[]; res: null; finalized: boolean; }
}) it('should create next functions that return a Promise', async () => { const stack = []
(property) arr: number[]
const arr: unknown[] = []
const stack: any[]
for (let i = 0;
const arr: unknown[]
i < 5;
let i: number
i++) {
let i: number
stack
let i: number
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(items
— New elements to add to the array.(_context:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _context: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
arr
interface Function
Creates a new function..push
const arr: unknown[]
(method) Array<unknown>.push(...items: unknown[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(next())items
— New elements to add to the array.}) ) } await compose
(parameter) next: Function
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)({res: null,
const stack: MiddlewareTuple[]
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.for (const next of
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.arr) {
const next: unknown
const isPromise = !!
const arr: unknown[]
(next as {
const isPromise: boolean
then?:
const next: unknown
Function })?
(property) then?: Function | undefined
.then
interface Function
Creates a new function.expect(isPromise).toBe(true)
(property) then?: Function | undefined
} }) it('should work with 0 middleware', async () => { await compose([])({
const isPromise: boolean
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
res: null,finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.}) it('should work when yielding at the end of the stack', async () => { const stack = []
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.let called = false
const stack: any[]
stack
let called: boolean
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.called = true
(parameter) next: Function
}) ) await compose
let called: boolean
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)({res: null,
const stack: MiddlewareTuple[]
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.expect(called).toBe(true)
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.}) it('should reject on errors in middleware', async () => { const stack = []
let called: false
stack
const stack: any[]
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(() => {items
— New elements to add to the array.throw new ExpectedError()
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
}) ) try { await compose
constructor ExpectedError(message?: string, options?: ErrorOptions): ExpectedError (+1 overload)
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)({res: null,
const stack: MiddlewareTuple[]
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.throw new Error('promise was not rejected')
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.} catch (e) {
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
expect(e).toBeInstanceOf
(local var) e: unknown
(ExpectedError)
(local var) e: unknown
} }) it('should keep the context', async () => { const ctx = {
class ExpectedError
res: null,
const ctx: { res: null; finalized: boolean; }
finalized: false }
(property) res: null
const stack = []
(property) finalized: boolean
stack
const stack: any[]
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(ctx2:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) ctx2: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.expect(ctx2).toEqual
(parameter) next: Function
(ctx)
(parameter) ctx2: C
}) ) stack
const ctx: { res: null; finalized: boolean; }
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(ctx2:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) ctx2: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.expect(ctx2).toEqual
(parameter) next: Function
(ctx)
(parameter) ctx2: C
}) ) stack
const ctx: { res: null; finalized: boolean; }
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(ctx2:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) ctx2: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.expect(ctx2).toEqual
(parameter) next: Function
(ctx)
(parameter) ctx2: C
}) ) await compose
const ctx: { res: null; finalized: boolean; }
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)(ctx)
const stack: MiddlewareTuple[]
}) it('should catch downstream errors', async () => { const arr: number[] = []
const ctx: { res: null; finalized: boolean; }
const stack = []
const arr: number[]
stack
const stack: any[]
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
arr
interface Function
Creates a new function..push(1)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
try { arritems
— New elements to add to the array..push(6)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
await next()items
— New elements to add to the array.arr
(parameter) next: Function
.push(7)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
} catch { arritems
— New elements to add to the array..push(2)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
} arritems
— New elements to add to the array..push(3)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
}) ) stackitems
— New elements to add to the array..push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(async () => {items
— New elements to add to the array.arr
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
.push(4)
const arr: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
throw new Error()items
— New elements to add to the array.}) ) await compose
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)({res: null,
const stack: MiddlewareTuple[]
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.expect(arr).toEqual([1, 6, 4, 2, 3])
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.}) it('should compose w/ next', async () => { let called = false
const arr: number[]
await compose([])({
let called: boolean
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
res: null,finalized: false }, async () => {
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.called = true
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.}) expect(called).toBe(true)
let called: boolean
}) it('should handle errors in wrapped non-async functions', async () => { const stack = []
let called: false
stack
const stack: any[]
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(function () {items
— New elements to add to the array.throw new ExpectedError()
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
}) ) try { await compose
constructor ExpectedError(message?: string, options?: ErrorOptions): ExpectedError (+1 overload)
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(stack)({res: null,
const stack: MiddlewareTuple[]
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.throw new Error('promise was not rejected')
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.} catch (e) {
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
expect(e).toBeInstanceOf
(local var) e: unknown
(ExpectedError)
(local var) e: unknown
} }) // https://github.com/koajs/compose/pull/27#issuecomment-143109739 it('should compose w/ other compositions', async () => { const called: number[] = []
class ExpectedError
await compose([
const called: number[]
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
buildMiddlewareTuple(compose([
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
buildMiddlewareTuple((_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
called
interface Function
Creates a new function..push(1)
const called: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
return next()items
— New elements to add to the array.}), buildMiddlewareTuple(
(parameter) next: Function
(_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
called
interface Function
Creates a new function..push(2)
const called: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
return next()items
— New elements to add to the array.}), ]) ), buildMiddlewareTuple(
(parameter) next: Function
(_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
called
interface Function
Creates a new function..push(3)
const called: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
return next()items
— New elements to add to the array.}), ])({ res: null,
(parameter) next: Function
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.expect(called).toEqual([1, 2, 3])
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.}) it('should throw if next() is called multiple times', async () => { try { await compose([
const called: number[]
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
buildMiddlewareTuple(async(_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.await next()
(parameter) next: Function
}), ])({ res: null,
(parameter) next: Function
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.throw new Error('boom')
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.} catch (err) {
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
expect(err instanceof
(local var) err: unknown
Error && /multiple times/
(local var) err: unknown
.test
var Error: ErrorConstructor
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
(errstring
— String on which to perform the search..message)).toBe(true)
(local var) err: Error
} }) it('should return a valid middleware', async () => { let val = 0
(property) Error.message: string
await compose([
let val: number
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
buildMiddlewareTuple(compose([
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
buildMiddlewareTuple((_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
val++
interface Function
Creates a new function.return next()
let val: number
}), buildMiddlewareTuple(
(parameter) next: Function
(_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
val++
interface Function
Creates a new function.return next()
let val: number
}), ]) ), buildMiddlewareTuple(
(parameter) next: Function
(_ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
val++
interface Function
Creates a new function.return next()
let val: number
}), ])({ res: null,
(parameter) next: Function
finalized: false })
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.expect(val).toEqual(3)
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.}) it('should return last return value', async () => { type C = {
let val: number
val: number
type C = { val: number; finalized: boolean; res: unknown; }
finalized: boolean
(property) val: number
res: unknown
(property) finalized: boolean
} const stack = []
(property) res: unknown
stack
const stack: any[]
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) ctx: C
next:
type C = { val: number; finalized: boolean; res: unknown; }
Function) => {
(parameter) next: Function
await next()
interface Function
Creates a new function.expect(ctx
(parameter) next: Function
.val).toEqual(2)
(parameter) ctx: C
ctx
(property) val: number
.val = 1
(parameter) ctx: C
}) ) stack
(property) val: number
.push(
const stack: any[]
(method) Array<any>.push(...items: any[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
buildMiddlewareTuple(asyncitems
— New elements to add to the array.(ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) ctx: C
next:
type C = { val: number; finalized: boolean; res: unknown; }
Function) => {
(parameter) next: Function
ctx
interface Function
Creates a new function..val = 2
(parameter) ctx: C
await next()
(property) val: number
expect(ctx
(parameter) next: Function
.val).toEqual(2)
(parameter) ctx: C
}) ) const res = await
(property) val: number
compose
const res: C
(alias) compose<C, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: C, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<C>(stack)({
type C = { val: number; finalized: boolean; res: unknown; }
val: 0,
const stack: MiddlewareTuple[]
res: null,
(property) val: number
finalized: false })
(property) res: unknown
expect(res
(property) finalized: boolean
.val).toEqual(1)
const res: C
}) it('should not affect the original middleware array', () => { const middleware:
(property) val: number
MiddlewareTuple[] = []
const middleware: MiddlewareTuple[]
const fn1 =
type MiddlewareTuple = [[Function, unknown], Params]
(_ctx:
const fn1: (_ctx: C, next: Function) => any
C,
(parameter) _ctx: C
next:
type C = { req: Record<string, string>; res: Record<string, string>; finalized: boolean; }
Function) => {
(parameter) next: Function
return next()
interface Function
Creates a new function.} middleware
(parameter) next: Function
.push
const middleware: MiddlewareTuple[]
(method) Array<MiddlewareTuple>.push(...items: MiddlewareTuple[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(buildMiddlewareTupleitems
— New elements to add to the array.(fn1))
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
for (const [[fn]] of
const fn1: (_ctx: C, next: Function) => any
middleware) {
const fn: Function
expect(fn).toEqual
const middleware: MiddlewareTuple[]
(fn1)
const fn: Function
} compose
const fn1: (_ctx: C, next: Function) => any
(alias) compose<ComposeContext, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: ComposeContext, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
(middleware)for (const [[fn]] of
const middleware: MiddlewareTuple[]
middleware) {
const fn: Function
expect(fn).toEqual
const middleware: MiddlewareTuple[]
(fn1)
const fn: Function
} }) it('should not get stuck on the passed in next', async () => { type C = {
const fn1: (_ctx: C, next: Function) => any
middleware: number
type C = { middleware: number; next: number; finalized: boolean; res: unknown; }
next: number
(property) middleware: number
finalized: boolean
(property) next: number
res: unknown
(property) finalized: boolean
} const middleware = [
(property) res: unknown
buildMiddlewareTuple(
const middleware: MiddlewareTuple[]
(ctx:
function buildMiddlewareTuple(fn: Function, params?: Params): MiddlewareTuple
C,
(parameter) ctx: C
next:
type C = { middleware: number; next: number; finalized: boolean; res: unknown; }
Function) => {
(parameter) next: Function
ctx
interface Function
Creates a new function..middleware++
(parameter) ctx: C
return next()
(property) middleware: number
}), ] const ctx = {
(parameter) next: Function
middleware: 0,
const ctx: { middleware: number; next: number; finalized: boolean; res: null; }
next: 0,
(property) middleware: number
finalized: false,
(property) next: number
res: null,
(property) finalized: boolean
} await compose
(property) res: null
(alias) compose<C, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: C, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<C>(middleware)
type C = { middleware: number; next: number; finalized: boolean; res: unknown; }
(ctx,
const middleware: MiddlewareTuple[]
(ctx:
const ctx: { middleware: number; next: number; finalized: boolean; res: null; }
C,
(parameter) ctx: C
next:
type C = { middleware: number; next: number; finalized: boolean; res: unknown; }
Function) => {
(parameter) next: Function
ctx
interface Function
Creates a new function..next++
(parameter) ctx: C
return next()
(property) next: number
}) expect(ctx
(parameter) next: Function
.middleware).toEqual(1)
const ctx: { middleware: number; next: number; finalized: boolean; res: null; }
expect(ctx
(property) middleware: number
.next).toEqual(1)
const ctx: { middleware: number; next: number; finalized: boolean; res: null; }
}) })
(property) next: number
import { Context } from './context' import type { ParamIndexMap, Params } from './router' import type { Env, ErrorHandler, NotFoundHandler } from './types' /** * Interface representing the context for a composition operation. */ interface ComposeContext {/** * Indicates whether the composition process has been finalized. */ finalized: boolean
interface ComposeContext
Interface representing the context for a composition operation./** * The result of the composition process. The type is unknown and should be * specified based on the context where this interface is used. */ res: unknown
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.} /** * Compose middleware functions into a single function based on `koa-compose` package. * * @template C - The context type. * @template E - The environment type. * * @param {[[Function, unknown], ParamIndexMap | Params][]} middleware - An array of middleware functions and their corresponding parameters. * @param {ErrorHandler
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.} [onError] - An optional error handler function. * @param {NotFoundHandler} [onNotFound] - An optional not-found handler function. * * @returns {(context: C, next?: Function) => Promise} - A composed middleware function. */ export const compose =
const compose: <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>) => ((context: C, next?: Function) => Promise<C>)
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<C extends
(type parameter) C in <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>): ((context: C, next?: Function) => Promise<C>)
- The context type.@template
ComposeContext,C
— The context type.E extends
interface ComposeContext
Interface representing the context for a composition operation.
(type parameter) E in <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>): ((context: C, next?: Function) => Promise<C>)
- The environment type.@template
Env =E
— The environment type.Env>(
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
middleware: [
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
(parameter) middleware: [[Function, unknown], ParamIndexMap | Params][]
- An array of middleware functions and their corresponding parameters.@param
[Function, unknown],middleware
— An array of middleware functions and their corresponding parameters.ParamIndexMap |
interface Function
Creates a new function.Params][],
(alias) type ParamIndexMap = { [x: string]: number; } import ParamIndexMap
Type representing a map of parameter indices.onError?:
(alias) type Params = { [x: string]: string; } import Params
Type representing a map of parameters.
(parameter) onError: ErrorHandler<E> | undefined
- An optional error handler function.@param
ErrorHandleronError
— An optional error handler function.<E>,
(alias) type ErrorHandler<E extends Env = any> = (err: Error | HTTPResponseError, c: Context<E>) => Response | Promise<Response> import ErrorHandler
(type parameter) E in <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>): ((context: C, next?: Function) => Promise<C>)
- The environment type.@template
onNotFound?:E
— The environment type.
(parameter) onNotFound: NotFoundHandler<E> | undefined
- An optional not-found handler function.@param
NotFoundHandleronNotFound
— An optional not-found handler function.<E>
(alias) type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response> import NotFoundHandler
(type parameter) E in <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>): ((context: C, next?: Function) => Promise<C>)
- The environment type.@template
): ((context:E
— The environment type.C,
(parameter) context: C extends ComposeContext
(type parameter) C in <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>): ((context: C, next?: Function) => Promise<C>)
- The context type.@template
next?:C
— The context type.Function) =>
(parameter) next: Function | undefined
Promise
interface Function
Creates a new function.<C>) => {
interface Promise<T>
Represents the completion of an asynchronous operation
(type parameter) C in <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>): ((context: C, next?: Function) => Promise<C>)
- The context type.@template
return (context,C
— The context type.next) => {
(parameter) context: C extends ComposeContext
let index = -1
(parameter) next: Function | undefined
return dispatch(0)
let index: number
(local function) dispatch(i: number): Promise<C>
Dispatch the middleware functions.@param
i
— The current index in the middleware array.@returns — - A promise that resolves to the context.
/** * Dispatch the middleware functions. * * @param {number} i - The current index in the middleware array. * * @returns {Promise} - A promise that resolves to the context. */ async function dispatch
(local function) dispatch(i: number): Promise<C>
Dispatch the middleware functions.@param
i
— The current index in the middleware array.@returns — - A promise that resolves to the context.
(i: number):
(parameter) i: number
- The current index in the middleware array.@param
Promisei
— The current index in the middleware array.<C> {
interface Promise<T>
Represents the completion of an asynchronous operation
(type parameter) C in <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>): ((context: C, next?: Function) => Promise<C>)
- The context type.@template
if (i <=C
— The context type.
(parameter) i: number
- The current index in the middleware array.@param
index) {i
— The current index in the middleware array.throw new Error('next() called multiple times')
let index: number
} index =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
i
let index: number
(parameter) i: number
- The current index in the middleware array.@param
let resi
— The current index in the middleware array.let isError = false
let res: any
let handler
let isError: boolean
if (middleware
let handler: any
(parameter) middleware: [[Function, unknown], ParamIndexMap | Params][]
- An array of middleware functions and their corresponding parameters.@param
[i]) {middleware
— An array of middleware functions and their corresponding parameters.
(parameter) i: number
- The current index in the middleware array.@param
handler =i
— The current index in the middleware array.middleware
let handler: any
(parameter) middleware: [[Function, unknown], ParamIndexMap | Params][]
- An array of middleware functions and their corresponding parameters.@param
[i][0][0]middleware
— An array of middleware functions and their corresponding parameters.
(parameter) i: number
- The current index in the middleware array.@param
if (context instanceofi
— The current index in the middleware array.Context) {
(parameter) context: C extends ComposeContext
context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.req
(parameter) context: C & Context<any, any, any>
.routeIndex =
(property) Context<any, any, any>.req: HonoRequest<any, any>
.req
is the instance of HonoRequest.i
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.routeIndex: number
(parameter) i: number
- The current index in the middleware array.@param
} } else { handler =i
— The current index in the middleware array.(i ===
let handler: any
(parameter) i: number
- The current index in the middleware array.@param
middlewarei
— The current index in the middleware array.
(parameter) middleware: [[Function, unknown], ParamIndexMap | Params][]
- An array of middleware functions and their corresponding parameters.@param
.length &&middleware
— An array of middleware functions and their corresponding parameters.next) || undefined
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.} if (!handler) {
(parameter) next: Function | undefined
if (context instanceof
let handler: Function | undefined
Context &&
(parameter) context: C extends ComposeContext
context
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.finalized === false &&
(parameter) context: C & Context<any, any, any>
onNotFound) {
(property) finalized: boolean
Indicates whether the composition process has been finalized.
(parameter) onNotFound: NotFoundHandler<E> | undefined
- An optional not-found handler function.@param
res = awaitonNotFound
— An optional not-found handler function.onNotFound
let res: any
(parameter) onNotFound: (c: Context<E, any, {}>) => Response | Promise<Response>
- An optional not-found handler function.@param
(context)onNotFound
— An optional not-found handler function.} } else { try { res = await
(parameter) context: C & Context<any, any, any>
handler
let res: any
(context, () => {
let handler: Function
return dispatch
(parameter) context: C extends ComposeContext
(local function) dispatch(i: number): Promise<C>
Dispatch the middleware functions.@param
i
— The current index in the middleware array.@returns — - A promise that resolves to the context.
(i + 1)
(parameter) i: number
- The current index in the middleware array.@param
}) } catch (err) {i
— The current index in the middleware array.if (err instanceof
(local var) err: unknown
Error &&
(local var) err: unknown
context instanceof
var Error: ErrorConstructor
Context &&
(parameter) context: C extends ComposeContext
onError) {
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(parameter) onError: ErrorHandler<E> | undefined
- An optional error handler function.@param
contextonError
— An optional error handler function..error =
(parameter) context: C & Context<any, any, any>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
err
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
res = await
(local var) err: Error
onError
let res: any
(parameter) onError: (err: Error | HTTPResponseError, c: Context<E, any, {}>) => Response | Promise<Response>
- An optional error handler function.@param
(err,onError
— An optional error handler function.context)
(local var) err: Error
isError = true
(parameter) context: C & Context<any, any, any>
} else { throw err
let isError: boolean
} } } if (res &&
(local var) err: unknown
(context
let res: any
.finalized === false ||
(parameter) context: C extends ComposeContext
isError)) {
(property) ComposeContext.finalized: boolean
Indicates whether the composition process has been finalized.context
let isError: boolean
.res =
(parameter) context: C extends ComposeContext
res
(property) ComposeContext.res: unknown
The result of the composition process. The type is unknown and should be specified based on the context where this interface is used.} return context
let res: any
} } }
(parameter) context: C extends ComposeContext
import { Context } from './context' import { setCookie } from './helper/cookie' const makeResponseHeaderImmutable =(res:
const makeResponseHeaderImmutable: (res: Response) => Response
Response) => {
(parameter) res: Response
Object
interface Response
This Fetch API interface represents the response to a request..defineProperty
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.defineProperty<Response>(o: Response, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): Response
Adds a property to an object, or modifies attributes of an existing property.@param
o
— Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object.@param
p
— The property name.@param
(res, 'headers', {attributes
— Descriptor for the property. It can be for a data property or an accessor property.value: new
(parameter) res: Response
Proxy
(property) PropertyDescriptor.value?: any
var Proxy: ProxyConstructor new <Headers>(target: Headers, handler: ProxyHandler<Headers>) => Headers
Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the original object, but which may redefine fundamental Object operations like getting, setting, and defining properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.@param
target
— A target object to wrap with Proxy.@param
(reshandler
— An object whose properties define the behavior of Proxy when an operation is attempted on it..headers, {
(parameter) res: Response
set
(property) Response.headers: Headers
MDN Reference
(method) ProxyHandler<Headers>.set?(target: Headers, p: string | symbol, newValue: any, receiver: any): boolean
A trap for setting a property value.@param
target
— The original object which is being proxied.@param
p
— The name orSymbol
of the property to set.@param
receiver
— The object to which the assignment was originally directed.@returns — A
(target,Boolean
indicating whether or not the property was set.prop,
(parameter) target: Headers
value) {
(parameter) prop: string | symbol
if (prop === 'set') {
(parameter) value: any
throw new TypeError('Cannot modify headers: Headers are immutable')
(parameter) prop: string | symbol
} return Reflect
var TypeError: TypeErrorConstructor new (message?: string, options?: ErrorOptions) => TypeError (+3 overloads)
.set
namespace Reflect
function Reflect.set<Headers, string | symbol>(target: Headers, propertyKey: string | symbol, value: any, receiver?: any): boolean (+1 overload)
Sets the property of target, equivalent totarget[propertyKey] = value
whenreceiver === target
.@param
target
— Object that contains the property on itself or in its prototype chain.@param
propertyKey
— Name of the property.@param
(target,receiver
The reference to use as thethis
value in the setter function, iftarget[propertyKey]
is an accessor property.prop,
(parameter) target: Headers
value)
(parameter) prop: string | symbol
}, get
(parameter) value: any
(method) ProxyHandler<Headers>.get?(target: Headers, p: string | symbol, receiver: any): any
A trap for getting a property value.@param
target
— The original object which is being proxied.@param
p
— The name orSymbol
of the property to get.@param
(target,receiver
— The proxy or an object that inherits from the proxy.prop) {
(parameter) target: Headers
if (prop === 'set') {
(parameter) prop: string | symbol
return function () { throw new TypeError('Cannot modify headers: Headers are immutable')
(parameter) prop: string | symbol
} } return Reflect
var TypeError: TypeErrorConstructor new (message?: string, options?: ErrorOptions) => TypeError (+3 overloads)
.get
namespace Reflect
function Reflect.get<Headers, string | symbol>(target: Headers, propertyKey: string | symbol, receiver?: unknown): any
Gets the property of target, equivalent totarget[propertyKey]
whenreceiver === target
.@param
target
— Object that contains the property on itself or in its prototype chain.@param
propertyKey
— The property name.@param
(target,receiver
The reference to use as thethis
value in the getter function, iftarget[propertyKey]
is an accessor property.prop)
(parameter) target: Headers
}, }), writable: false,
(parameter) prop: string | symbol
}) return res
(property) PropertyDescriptor.writable?: boolean | undefined
} describe('Context', () => { const req = new
(parameter) res: Response
Request('http://localhost/')
const req: Request
let c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context
let c: Context<any, any, {}>
beforeEach(() => { c = new
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Context
let c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.}) it('c.text()', async () => { const res =
const req: Request
c
const res: Response & TypedResponse<"text in c", 201, "text">
.text('text in c', 201, { 'X-Custom': 'Message' })
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.text: TextRespond <"text in c", 201>(text: "text in c", status?: 201 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"text in c", 201, "text"> (+1 overload)
.status).toBe(201)
const res: Response & TypedResponse<"text in c", 201, "text">
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response & TypedResponse<"text in c", 201, "text">
.get('Content-Type')).toMatch(/^text\/plain/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('text in c')
const res: Response & TypedResponse<"text in c", 201, "text">
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response & TypedResponse<"text in c", 201, "text">
.get('X-Custom')).toBe('Message')
(property) Response.headers: Headers
MDN Reference}) it('c.text() with c.status()', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.status(404)
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.status: (status: StatusCode) => void
c
const res: Response & TypedResponse<"not found", StatusCode, "text">
.text('not found')
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.text: TextRespond <"not found", StatusCode>(text: "not found", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.status).toBe(404)
const res: Response & TypedResponse<"not found", StatusCode, "text">
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response & TypedResponse<"not found", StatusCode, "text">
.get('Content-Type')).toMatch(/^text\/plain/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('not found')
const res: Response & TypedResponse<"not found", StatusCode, "text">
}) it('c.json()', async () => { const res =
(method) Body.text(): Promise<string>
MDN Referencec
const res: JSONRespondReturn<{ message: string; }, 201>
.json({
let c: Context<any, any, {}>
message: 'Hello' }, 201, { 'X-Custom': 'Message' })
(property) Context<any, any, {}>.json: JSONRespond <{ message: string; }, 201>(object: { message: string; }, status?: 201 | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ message: string; }, 201> (+1 overload)
expect(res
(property) message: string
.status).toBe(201)
const res: JSONRespondReturn<{ message: string; }, 201>
expect(res
(property) Response.status: number
MDN Reference.headers
const res: JSONRespondReturn<{ message: string; }, 201>
.get('Content-Type')).toMatch('application/json; charset=UTF-8')
(property) Response.headers: Headers
MDN Referenceconst text = await
(method) Headers.get(name: string): string | null
MDN Referenceres
const text: string
.text()
const res: JSONRespondReturn<{ message: string; }, 201>
expect(text).toBe('{"message":"Hello"}')
(method) Body.text(): Promise<string>
MDN Referenceexpect(res
const text: string
.headers
const res: JSONRespondReturn<{ message: string; }, 201>
.get('X-Custom')).toBe('Message')
(property) Response.headers: Headers
MDN Reference}) it('c.html()', async () => { const res:
(method) Headers.get(name: string): string | null
MDN ReferenceResponse =
const res: Response
c
interface Response
This Fetch API interface represents the response to a request..html('
let c: Context<any, any, {}>
Hello! Hono!
', 201, { 'X-Custom': 'Message' })expect(res
(property) Context<any, any, {}>.html: HTMLRespond <"<h1>Hello! Hono!</h1>">(html: "<h1>Hello! Hono!</h1>", status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.status).toBe(201)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('Content-Type')).toMatch('text/html')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('
const res: Response
Hello! Hono!
')expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('X-Custom')).toBe('Message')
(property) Response.headers: Headers
MDN Reference}) it('c.html() with async', async () => { const resPromise:
(method) Headers.get(name: string): string | null
MDN ReferencePromise
const resPromise: Promise<Response>
<Response> =
interface Promise<T>
Represents the completion of an asynchronous operationc
interface Response
This Fetch API interface represents the response to a request..html(
let c: Context<any, any, {}>
new Promise
(property) Context<any, any, {}>.html: HTMLRespond <Promise<string>>(html: Promise<string>, status?: StatusCode, headers?: HeaderRecord) => Promise<Response> (+1 overload)
( (resolve) =>
var Promise: PromiseConstructor new <string>(executor: (resolve: (value: string | PromiseLike<string>) => void, reject: (reason?: any) => void) => void) => Promise<string>
Creates a new Promise.@param
executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.setTimeout(() =>
(parameter) resolve: (value: string | PromiseLike<string>) => void
resolve('
function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
MDN ReferenceHello! Hono!
'), 0)),201, { 'X-Custom': 'Message', } ) const res = await
(parameter) resolve: (value: string | PromiseLike<string>) => void
resPromise
const res: Response
expect(res
const resPromise: Promise<Response>
.status).toBe(201)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('Content-Type')).toMatch('text/html')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('
const res: Response
Hello! Hono!
')expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('X-Custom')).toBe('Message')
(property) Response.headers: Headers
MDN Reference}) it('c.redirect()', async () => { let res =
(method) Headers.get(name: string): string | null
MDN Referencec
let res: Response & TypedResponse<undefined, 302, "redirect">
.redirect('/destination')
let c: Context<any, any, {}>
(property) Context<any, any, {}>.redirect: <302>(location: string, status?: 302 | undefined) => Response & TypedResponse<undefined, 302, "redirect">
.redirect()
can Redirect, default status code is 302.@see — https://hono.dev/docs/api/context#redirect
@example
expect(res
ts app.get('/redirect', (c) => { return c.redirect('/') }) app.get('/redirect-permanently', (c) => { return c.redirect('/', 301) })
.status).toBe(302)
let res: Response & TypedResponse<undefined, 302, "redirect">
expect(res
(property) Response.status: number
MDN Reference.headers
let res: Response & TypedResponse<undefined, 302, "redirect">
.get('Location')).toBe('/destination')
(property) Response.headers: Headers
MDN Referenceres =
(method) Headers.get(name: string): string | null
MDN Referencec
let res: Response & TypedResponse<undefined, 302, "redirect">
.redirect('https://example.com/destination')
let c: Context<any, any, {}>
(property) Context<any, any, {}>.redirect: <302>(location: string, status?: 302 | undefined) => Response & TypedResponse<undefined, 302, "redirect">
.redirect()
can Redirect, default status code is 302.@see — https://hono.dev/docs/api/context#redirect
@example
expect(res
ts app.get('/redirect', (c) => { return c.redirect('/') }) app.get('/redirect-permanently', (c) => { return c.redirect('/', 301) })
.status).toBe(302)
let res: Response & TypedResponse<undefined, 302, "redirect">
expect(res
(property) Response.status: number
MDN Reference.headers
let res: Response & TypedResponse<undefined, 302, "redirect">
.get('Location')).toBe('https://example.com/destination')
(property) Response.headers: Headers
MDN Reference}) it('c.header()', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.header('X-Foo', 'Bar')
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
const res: Response
.body('Hi')
let c: Context<any, any, {}>
const foo =
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
res
const foo: string | null
.headers
const res: Response
.get('X-Foo')
(property) Response.headers: Headers
MDN Referenceexpect(foo).toBe('Bar')
(method) Headers.get(name: string): string | null
MDN Reference}) it('c.header() - append', async () => { c
const foo: string | null
.header('X-Foo', 'Bar')
let c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('X-Foo', 'Buzz', {
let c: Context<any, any, {}>
append: true })
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
const res =
(property) SetHeadersOptions.append?: boolean | undefined
c
const res: Response
.body('Hi')
let c: Context<any, any, {}>
const foo =
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
res
const foo: string | null
.headers
const res: Response
.get('X-Foo')
(property) Response.headers: Headers
MDN Referenceexpect(foo).toBe('Bar, Buzz')
(method) Headers.get(name: string): string | null
MDN Reference}) it('c.set() and c.get()', async () => { expect(c
const foo: string | null
.get('foo')).toBe(undefined)
let c: Context<any, any, {}>
c
(property) Context<any, any, {}>.get: Get <"foo">(key: "foo") => any (+1 overload)
.set('foo', 'bar')
let c: Context<any, any, {}>
expect(c
(property) Context<any, any, {}>.set: Set <"foo">(key: "foo", value: any) => void (+1 overload)
.get('foo')).toBe('bar')
let c: Context<any, any, {}>
expect(c
(property) Context<any, any, {}>.get: Get <"foo">(key: "foo") => any (+1 overload)
.get('foo2')).toBe(undefined)
let c: Context<any, any, {}>
}) it('c.var', async () => { expect(c
(property) Context<any, any, {}>.get: Get <"foo2">(key: "foo2") => any (+1 overload)
.var.foo).toBe(undefined)
let c: Context<any, any, {}>
(property) Context<any, any, {}>.var: Readonly<ContextVariableMap & Record<string, any>>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
c
ts const result = c.var.client.oneMethod()
.set('foo', 'bar')
let c: Context<any, any, {}>
expect(c
(property) Context<any, any, {}>.set: Set <"foo">(key: "foo", value: any) => void (+1 overload)
.var.foo).toBe('bar')
let c: Context<any, any, {}>
(property) Context<any, any, {}>.var: Readonly<ContextVariableMap & Record<string, any>>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
expect(c
ts const result = c.var.client.oneMethod()
.var.foo2).toBe(undefined)
let c: Context<any, any, {}>
(property) Context<any, any, {}>.var: Readonly<ContextVariableMap & Record<string, any>>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
}) it('c.notFound()', async () => { const res =
ts const result = c.var.client.oneMethod()
c
const res: Response | Promise<Response>
.notFound()
let c: Context<any, any, {}>
(property) Context<any, any, {}>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
expect(res).instanceOf
ts app.get('/notfound', (c) => { return c.notFound() })
(Response)
const res: Response | Promise<Response>
}) it('Should set headers if already this.#headers is created by `c.header()`', async () => { c
var Response: { new (body?: BodyInit | null, init?: ResponseInit): Response; prototype: Response; error(): Response; json(data: any, init?: ResponseInit): Response; redirect(url: string | URL, status?: number): Response; }
This Fetch API interface represents the response to a request..header('X-Foo', 'Bar')
let c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('X-Foo', 'Buzz', {
let c: Context<any, any, {}>
append: true })
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
const res =
(property) SetHeadersOptions.append?: boolean | undefined
c
const res: Response
.body('Hi', {
let c: Context<any, any, {}>
headers: {
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, init?: ResponseInit) => Response (+1 overload)
'X-Message': 'Hi', }, }) expect(res
(property) ResponseInit.headers?: ResponseHeadersInit | undefined
.headers
const res: Response
.get('X-Foo')).toBe('Bar, Buzz')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('X-Message')).toBe('Hi')
(property) Response.headers: Headers
MDN Reference}) it('c.header() - append, c.html()', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.header('X-Foo', 'Bar', {
let c: Context<any, any, {}>
append: true })
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
const res = await
(property) SetHeadersOptions.append?: boolean | undefined
c
const res: Response
.html('
let c: Context<any, any, {}>
This rendered fine
')expect(res
(property) Context<any, any, {}>.html: HTMLRespond <"<h1>This rendered fine</h1>">(html: "<h1>This rendered fine</h1>", status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.headers
const res: Response
.get('content-type')).toMatch(/^text\/html/)
(property) Response.headers: Headers
MDN Reference}) it('c.header() - clear the header', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.header('X-Foo', 'Bar')
let c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('X-Foo', undefined)
let c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('X-Foo2', 'Bar')
let c: Context<any, any, {}>
let res =
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
let res: Response
.body('Hi')
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.headers
let res: Response
.get('X-Foo')).toBe(null)
(property) Response.headers: Headers
MDN Referencec
(method) Headers.get(name: string): string | null
MDN Reference.header('X-Foo2', undefined)
let c: Context<any, any, {}>
res =
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
let res: Response
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
expect(res_res
— The Response object to set..headers
let res: Response
.get('X-Foo2')).toBe(null)
(property) Response.headers: Headers
MDN Reference}) it('c.header() - clear the header when append is true', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.header('X-Foo', 'Bar', {
let c: Context<any, any, {}>
append: true })
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
(property) SetHeadersOptions.append?: boolean | undefined
.header('X-Foo', undefined)
let c: Context<any, any, {}>
expect(c
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..get('X-Foo')).toBe(null)
(property) Response.headers: Headers
MDN Reference}) it('c.body() - multiple header', async () => { const res =
(method) Headers.get(name: string): string | null
MDN Referencec
const res: Response
.body('Hi', 200, {
let c: Context<any, any, {}>
'X-Foo': ['Bar', 'Buzz'], }) const foo =
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
res
const foo: string | null
.headers
const res: Response
.get('X-Foo')
(property) Response.headers: Headers
MDN Referenceexpect(foo).toBe('Bar, Buzz')
(method) Headers.get(name: string): string | null
MDN Reference}) it('c.status()', async () => { c
const foo: string | null
.status(201)
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.status: (status: StatusCode) => void
c
const res: Response
.body('Hi')
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.status).toBe(201)
const res: Response
}) it('Complex pattern', async () => { c
(property) Response.status: number
MDN Reference.status(404)
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.status: (status: StatusCode) => void
c
const res: JSONRespondReturn<{ hono: string; }, StatusCode>
.json({
let c: Context<any, any, {}>
hono: 'great app' })
(property) Context<any, any, {}>.json: JSONRespond <{ hono: string; }, StatusCode>(object: { hono: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ hono: string; }, StatusCode> (+1 overload)
expect(res
(property) hono: string
.status).toBe(404)
const res: JSONRespondReturn<{ hono: string; }, StatusCode>
expect(res
(property) Response.status: number
MDN Reference.headers
const res: JSONRespondReturn<{ hono: string; }, StatusCode>
.get('Content-Type')).toMatch('application/json; charset=UTF-8')
(property) Response.headers: Headers
MDN Referenceconst obj: {
(method) Headers.get(name: string): string | null
MDN Reference[key: string]: string } = await
const obj: { [key: string]: string; }
res
(parameter) key: string
.json()
const res: JSONRespondReturn<{ hono: string; }, StatusCode>
expect(obj['hono']).toBe('great app')
(method) Body.json(): Promise<any>
MDN Reference}) it('Has headers and status', async () => { c
const obj: { [key: string]: string; }
.header('x-custom1', 'Message1')
let c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('x-custom2', 'Message2')
let c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.status(200)
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.status: (status: StatusCode) => void
c
const res: Response
.newResponse('this is body', 201, {
let c: Context<any, any, {}>
'x-custom3': 'Message3', 'x-custom2': 'Message2-Override', }) expect(res
(property) Context<any, any, {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.headers
const res: Response
.get('x-Custom1')).toBe('Message1')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-Custom2')).toBe('Message2-Override')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-Custom3')).toBe('Message3')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.status).toBe(201)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('this is body')
const res: Response
// res is already set. c
(method) Body.text(): Promise<string>
MDN Reference.res =
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
res_res
— The Response object to set.c
const res: Response
.header('X-Custom4', 'Message4')
let c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.status(202)
let c: Context<any, any, {}>
expect(c
(property) Context<any, any, {}>.status: (status: StatusCode) => void
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..get('X-Custom4')).toBe('Message4')
(property) Response.headers: Headers
MDN Referenceexpect(c
(method) Headers.get(name: string): string | null
MDN Reference.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.status).toBe(201)_res
— The Response object to set.}) it('Inherit current status if not specified', async () => { c
(property) Response.status: number
MDN Reference.status(201)
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.status: (status: StatusCode) => void
c
const res: Response
.newResponse('this is body', {
let c: Context<any, any, {}>
headers: {
(property) Context<any, any, {}>.newResponse: NewResponse (data: Data | null, init?: ResponseInit) => Response (+1 overload)
'x-custom3': 'Message3', 'x-custom2': 'Message2-Override', }, }) expect(res
(property) ResponseInit.headers?: ResponseHeadersInit | undefined
.headers
const res: Response
.get('x-Custom2')).toBe('Message2-Override')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-Custom3')).toBe('Message3')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.status).toBe(201)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('this is body')
const res: Response
}) it('Should append the previous headers to new Response', () => { c
(method) Body.text(): Promise<string>
MDN Reference.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..set('x-Custom1', 'Message1')
(property) Response.headers: Headers
MDN Referenceconst res2 = new
(method) Headers.set(name: string, value: string): void
MDN ReferenceResponse('foo2', {
const res2: Response
headers: {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.'Content-Type': 'application/json', }, }) res2
(property) ResponseInit.headers?: HeadersInit | undefined
.headers
const res2: Response
.set('x-Custom2', 'Message2')
(property) Response.headers: Headers
MDN Referencec
(method) Headers.set(name: string, value: string): void
MDN Reference.res =
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
res2_res
— The Response object to set.expect(c
const res2: Response
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..get('x-Custom1')).toBe('Message1')
(property) Response.headers: Headers
MDN Referenceexpect(c
(method) Headers.get(name: string): string | null
MDN Reference.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..get('Content-Type')).toBe('application/json')
(property) Response.headers: Headers
MDN Reference}) it('Should return 200 response', async () => { const res =
(method) Headers.get(name: string): string | null
MDN Referencec
const res: Response & TypedResponse<"Text", StatusCode, "text">
.text('Text')
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.text: TextRespond <"Text", StatusCode>(text: "Text", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Text", StatusCode, "text"> (+1 overload)
.status).toBe(200)
const res: Response & TypedResponse<"Text", StatusCode, "text">
}) it('Should return 204 response', async () => { c
(property) Response.status: number
MDN Reference.status(204)
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.status: (status: StatusCode) => void
c
const res: Response
.body(null)
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.status).toBe(204)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('')
const res: Response
}) it('Should be able read env', async () => { const req = new
(method) Body.text(): Promise<string>
MDN ReferenceRequest('http://localhost/')
const req: Request
const key = 'a-secret-key'
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.const ctx = new
const key: "a-secret-key"
Context
const ctx: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req, {options
— Optional configuration options for the context.env: {
const req: Request
API_KEY:
(property) env: any
Bindings for the environment.key,
(property) API_KEY: string
}, }) expect(ctx
const key: "a-secret-key"
.env.API_KEY).toBe
const ctx: Context<any, any, {}>
(property) Context<any, any, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
(key)
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
}) it('set and set', async () => { const ctx = new
const key: "a-secret-key"
Context
const ctx: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.expect(ctx
const req: Request
.get('k-foo')).toEqual(undefined)
const ctx: Context<any, any, {}>
ctx
(property) Context<any, any, {}>.get: Get <"k-foo">(key: "k-foo") => any (+1 overload)
.set('k-foo', 'v-foo')
const ctx: Context<any, any, {}>
expect(ctx
(property) Context<any, any, {}>.set: Set <"k-foo">(key: "k-foo", value: any) => void (+1 overload)
.get('k-foo')).toEqual('v-foo')
const ctx: Context<any, any, {}>
expect(ctx
(property) Context<any, any, {}>.get: Get <"k-foo">(key: "k-foo") => any (+1 overload)
.get('k-bar')).toEqual(undefined)
const ctx: Context<any, any, {}>
ctx
(property) Context<any, any, {}>.get: Get <"k-bar">(key: "k-bar") => any (+1 overload)
.set('k-bar', {
const ctx: Context<any, any, {}>
k: 'v' })
(property) Context<any, any, {}>.set: Set <"k-bar">(key: "k-bar", value: any) => void (+1 overload)
expect(ctx
(property) k: string
.get('k-bar')).toEqual({
const ctx: Context<any, any, {}>
k: 'v' })
(property) Context<any, any, {}>.get: Get <"k-bar">(key: "k-bar") => any (+1 overload)
}) it('has res object by default', async () => { c = new
(property) k: string
Context
let c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.c
const req: Request
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('foo', 'bar')
(property) Response.headers: Headers
MDN Referenceconst res =
(method) Headers.append(name: string, value: string): void
MDN Referencec
const res: Response & TypedResponse<"foo", StatusCode, "text">
.text('foo')
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.text: TextRespond <"foo", StatusCode>(text: "foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
.headers
const res: Response & TypedResponse<"foo", StatusCode, "text">
.get('foo')).not.toBeNull()
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response & TypedResponse<"foo", StatusCode, "text">
.get('foo')).toBe('bar')
(property) Response.headers: Headers
MDN Reference}) }) describe('event and executionCtx', () => { const req = new
(method) Headers.get(name: string): string | null
MDN ReferenceRequest('http://localhost/')
const req: Request
it('Should return the event if accessing c.event', () => { const respondWith = vi.fn()
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.const c = new
const respondWith: any
Context
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req, {options
— Optional configuration options for the context.// @ts-expect-error the type is not correct executionCtx: {
const req: Request
respondWith:
(property) executionCtx?: FetchEventLike | ExecutionContext | undefined
Execution context for the request.respondWith,
(method) FetchEventLike.respondWith(promise: Response | Promise<Response>): void
}, }) expect(() => c
const respondWith: any
.event).not.toThrowError()
const c: Context<any, any, {}>
(property) Context<any, any, {}>.event: FetchEventLike
@see — https://hono.dev/docs/api/context#eventThe FetchEvent associated with the current request.
@throws — Will throw an error if the context does not have a FetchEvent.
c.event
const c: Context<any, any, {}>
(property) Context<any, any, {}>.event: FetchEventLike
@see — https://hono.dev/docs/api/context#eventThe FetchEvent associated with the current request.
@throws — Will throw an error if the context does not have a FetchEvent.
.respondWith(newResponse())
(method) FetchEventLike.respondWith(promise: Response | Promise<Response>): void
expect(respondWith).toHaveBeenCalled()
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.}) it('Should throw an error if accessing c.event', () => { const c = new
const respondWith: any
Context
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.expect(() => c
const req: Request
.event).toThrowError()
const c: Context<any, any, {}>
(property) Context<any, any, {}>.event: FetchEventLike
@see — https://hono.dev/docs/api/context#eventThe FetchEvent associated with the current request.
@throws — Will throw an error if the context does not have a FetchEvent.
}) it('Should return the executionCtx if accessing c.executionCtx', () => { const pathThroughOnException = vi.fn()const waitUntil = vi.fn()
const pathThroughOnException: any
const c = new
const waitUntil: any
Context
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req, {options
— Optional configuration options for the context.executionCtx: {
const req: Request
passThroughOnException:
(property) executionCtx?: FetchEventLike | ExecutionContext | undefined
Execution context for the request.pathThroughOnException,
(property) passThroughOnException: any
waitUntil:
const pathThroughOnException: any
waitUntil,
(property) waitUntil: any
}, env: {},
const waitUntil: any
}) expect(() => c
(property) env: any
Bindings for the environment..executionCtx).not.toThrowError()
const c: Context<any, any, {}>
(property) Context<any, any, {}>.executionCtx: ExecutionContext
@see — https://hono.dev/docs/api/context#executionctxThe ExecutionContext associated with the current request.
@throws — Will throw an error if the context does not have an ExecutionContext.
c.executionCtx
const c: Context<any, any, {}>
(property) Context<any, any, {}>.executionCtx: ExecutionContext
@see — https://hono.dev/docs/api/context#executionctxThe ExecutionContext associated with the current request.
@throws — Will throw an error if the context does not have an ExecutionContext.
.passThroughOnException()expect(pathThroughOnException).toHaveBeenCalled()
(method) ExecutionContext.passThroughOnException(): void
Allows the event to be passed through to subsequent event listeners.const asyncFunc = async () => {}
const pathThroughOnException: any
c
const asyncFunc: () => Promise<void>
.executionCtx
const c: Context<any, any, {}>
(property) Context<any, any, {}>.executionCtx: ExecutionContext
@see — https://hono.dev/docs/api/context#executionctxThe ExecutionContext associated with the current request.
@throws — Will throw an error if the context does not have an ExecutionContext.
.waitUntil
(method) ExecutionContext.waitUntil(promise: Promise<unknown>): void
Extends the lifetime of the event callback until the promise is settled.@param
(asyncFunc())promise
— A promise to wait for.expect(waitUntil).toHaveBeenCalled()
const asyncFunc: () => Promise<void>
}) it('Should throw an error if accessing c.executionCtx', () => { const c = new
const waitUntil: any
Context
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.expect(() => c
const req: Request
.executionCtx).toThrowError()
const c: Context<any, any, {}>
(property) Context<any, any, {}>.executionCtx: ExecutionContext
@see — https://hono.dev/docs/api/context#executionctxThe ExecutionContext associated with the current request.
@throws — Will throw an error if the context does not have an ExecutionContext.
}) }) describe('Context header', () => { const req = newRequest('http://localhost/')
const req: Request
let c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context
let c: Context<any, any, {}>
beforeEach(() => { c = new
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Context
let c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.}) it('Should return only one content-type value', async () => { c
const req: Request
.header('Content-Type', 'foo')
let c: Context<any, any, {}>
const res = await
(property) Context<any, any, {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
const res: Response
.html('foo')
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.html: HTMLRespond <"foo">(html: "foo", status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.headers
const res: Response
.get('Content-Type')).toBe('text/html; charset=UTF-8')
(property) Response.headers: Headers
MDN Reference}) it('Should rewrite header values correctly', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.res = await
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
c_res
— The Response object to set..html('foo')
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.html: HTMLRespond <"foo">(html: "foo", status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
c
const res: Response & TypedResponse<"foo", StatusCode, "text">
.text('foo')
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.text: TextRespond <"foo", StatusCode>(text: "foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
.headers
const res: Response & TypedResponse<"foo", StatusCode, "text">
.get('Content-Type')).toMatch(/^text\/plain/)
(property) Response.headers: Headers
MDN Reference}) it('Should set header values if the #this.headers is set and the arg is ResponseInit', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.header('foo', 'bar')
let c: Context<any, any, {}>
const res =
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
const res: Response
.body('foo', {
let c: Context<any, any, {}>
headers: {
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, init?: ResponseInit) => Response (+1 overload)
'Content-Type': 'text/plain', }, }) expect(res
(property) ResponseInit.headers?: ResponseHeadersInit | undefined
.headers
const res: Response
.get('foo')).toBe('bar')
(property) Response.headers: Headers
MDN Reference}) it('Should set cookie headers when re-assigning Response to `c.res`', () => { const cookies = ['foo=bar; Path=/', 'foo2=bar2; Path=/']
(method) Headers.get(name: string): string | null
MDN Referenceconst res = new
const cookies: string[]
Response(null)
const res: Response
res
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..headers
const res: Response
.append('set-cookie',
(property) Response.headers: Headers
MDN Referencecookies[0])
(method) Headers.append(name: string, value: string): void
MDN Referenceres
const cookies: string[]
.headers
const res: Response
.append('set-cookie',
(property) Response.headers: Headers
MDN Referencecookies[1])
(method) Headers.append(name: string, value: string): void
MDN Referencec
const cookies: string[]
.res =
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
res_res
— The Response object to set.expect(c
const res: Response
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..getSetCookie()
(property) Response.headers: Headers
MDN Reference.length).toBe(2)
(method) Headers.getSetCookie(): string[]
MDN Reference// Re-assign const newCookies = ['foo3=bar3; Path=/']
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.const newResponse = new
const newCookies: string[]
Response(null)
const newResponse: Response
newResponse
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..headers
const newResponse: Response
.append('set-cookie',
(property) Response.headers: Headers
MDN ReferencenewCookies[0])
(method) Headers.append(name: string, value: string): void
MDN Referencec
const newCookies: string[]
.res =
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
newResponse_res
— The Response object to set.expect(c
const newResponse: Response
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..getSetCookie()
(property) Response.headers: Headers
MDN Reference.length).toBe
(method) Headers.getSetCookie(): string[]
MDN Reference(cookies
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array..length)
const cookies: string[]
expect(c
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array..res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..getSetCookie()).toEqual
(property) Response.headers: Headers
MDN Reference(cookies)
(method) Headers.getSetCookie(): string[]
MDN Reference}) it('Should keep previous cookies in response headers', () => { c
const cookies: string[]
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('set-cookie', 'foo=bar; Path=/')
(property) Response.headers: Headers
MDN ReferencesetCookie
(method) Headers.append(name: string, value: string): void
MDN Reference(c, 'foo2', 'bar2', {
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
path: '/' })
let c: Context<any, any, {}>
const res =
(property) path?: string | undefined
c
const res: JSONRespondReturn<{ message: string; }, StatusCode>
.json({
let c: Context<any, any, {}>
message: 'Hello' })
(property) Context<any, any, {}>.json: JSONRespond <{ message: string; }, StatusCode>(object: { message: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ message: string; }, StatusCode> (+1 overload)
const cookies =
(property) message: string
res
const cookies: string[]
.headers
const res: JSONRespondReturn<{ message: string; }, StatusCode>
.getSetCookie()
(property) Response.headers: Headers
MDN Referenceexpect(cookies
(method) Headers.getSetCookie(): string[]
MDN Reference.includes('foo=bar; Path=/')).toBe(true)
const cookies: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
expect(cookiesfromIndex
— The position in this array at which to begin searching for searchElement..includes('foo2=bar2; Path=/')).toBe(true)
const cookies: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
}) it('Should set set-cookie header values if c.res is already defined', () => { cfromIndex
— The position in this array at which to begin searching for searchElement..res = new
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response(null, {_res
— The Response object to set.headers: [
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.['set-cookie', 'a'], ['set-cookie', 'b'], ['set-cookie', 'c'], ], }) const res =
(property) ResponseInit.headers?: HeadersInit | undefined
c
const res: Response & TypedResponse<"Hi", StatusCode, "text">
.text('Hi')
let c: Context<any, any, {}>
expect(res
(property) Context<any, any, {}>.text: TextRespond <"Hi", StatusCode>(text: "Hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Hi", StatusCode, "text"> (+1 overload)
.headers
const res: Response & TypedResponse<"Hi", StatusCode, "text">
.get('set-cookie')).toBe('a, b, c')
(property) Response.headers: Headers
MDN Reference}) it('Should be able to overwrite a fetch response with a new response.', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.res =
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
makeResponseHeaderImmutable(new_res
— The Response object to set.Response('bar'))
const makeResponseHeaderImmutable: (res: Response) => Response
c
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..res = new
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response('foo', {_res
— The Response object to set.headers: {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.'X-Custom': 'Message', }, }) expect(c
(property) ResponseInit.headers?: HeadersInit | undefined
.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).resolves.toBe('foo')_res
— The Response object to set.expect(c
(method) Body.text(): Promise<string>
MDN Reference.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..get('X-Custom')).toBe('Message')
(property) Response.headers: Headers
MDN Reference}) it('Should be able to overwrite a response with a fetch response.', async () => { c
(method) Headers.get(name: string): string | null
MDN Reference.res = new
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response('foo', {_res
— The Response object to set.headers: {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.'X-Custom': 'Message', }, }) c
(property) ResponseInit.headers?: HeadersInit | undefined
.res =
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
makeResponseHeaderImmutable(new_res
— The Response object to set.Response('bar'))
const makeResponseHeaderImmutable: (res: Response) => Response
expect(c
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()).resolves.toBe('bar')_res
— The Response object to set.expect(c
(method) Body.text(): Promise<string>
MDN Reference.res
let c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..get('X-Custom')).toBe('Message')
(property) Response.headers: Headers
MDN Reference}) }) describe('Pass a ResponseInit to respond methods', () => { const req = new
(method) Headers.get(name: string): string | null
MDN ReferenceRequest('http://localhost/')
const req: Request
let c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context
let c: Context<any, any, {}>
beforeEach(() => { c = new
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Context
let c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.}) it('c.json()', async () => { const originalResponse = new
const req: Request
Response('Unauthorized', {
const originalResponse: Response
headers: {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.'content-type': 'text/plain', 'x-custom': 'custom message', }, status: 401,
(property) ResponseInit.headers?: HeadersInit | undefined
}) const res =
(property) ResponseInit.status?: number | undefined
c
const res: JSONRespondReturn<{ message: string; }, StatusCode>
.json(
let c: Context<any, any, {}>
{ message: 'Unauthorized',
(property) Context<any, any, {}>.json: JSONRespond <{ message: string; }, StatusCode>(object: { message: string; }, init?: ResponseInit) => JSONRespondReturn<{ message: string; }, StatusCode> (+1 overload)
}, originalResponse
(property) message: string
) expect(res
const originalResponse: Response
.status).toBe(401)
const res: JSONRespondReturn<{ message: string; }, StatusCode>
expect(res
(property) Response.status: number
MDN Reference.headers
const res: JSONRespondReturn<{ message: string; }, StatusCode>
.get('content-type')).toMatch(/^application\/json/)
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: JSONRespondReturn<{ message: string; }, StatusCode>
.get('x-custom')).toBe('custom message')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.json()).toEqual({
const res: JSONRespondReturn<{ message: string; }, StatusCode>
message: 'Unauthorized',
(method) Body.json(): Promise<any>
MDN Reference}) }) it('c.body()', async () => { const originalResponse = new
(property) message: string
Response('
const originalResponse: Response
Hello
', {headers: {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.'content-type': 'text/html', }, }) const res =
(property) ResponseInit.headers?: HeadersInit | undefined
c
const res: Response
.body('
let c: Context<any, any, {}>
Hello
',originalResponse)
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, init?: ResponseInit) => Response (+1 overload)
expect(res
const originalResponse: Response
.headers
const res: Response
.get('content-type')).toMatch(/^text\/html/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('
const res: Response
Hello
')}) it('c.body() should retain context cookies from context and original response', async () => { setCookie
(method) Body.text(): Promise<string>
MDN Reference(c, 'context', '1')
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
setCookie
let c: Context<any, any, {}>
(c, 'context', '2')
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
const originalResponse = new
let c: Context<any, any, {}>
Response('', {
const originalResponse: Response
headers: {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.'set-cookie': 'response=1; Path=/', }, }) const res =
(property) ResponseInit.headers?: HeadersInit | undefined
c
const res: Response
.body('',
let c: Context<any, any, {}>
originalResponse)
(property) Context<any, any, {}>.body: BodyRespond (data: Data | null, init?: ResponseInit) => Response (+1 overload)
const cookies =
const originalResponse: Response
res
const cookies: string[]
.headers
const res: Response
.getSetCookie()
(property) Response.headers: Headers
MDN Referenceexpect(cookies
(method) Headers.getSetCookie(): string[]
MDN Reference.includes('context=1; Path=/')).toBe(true)
const cookies: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
expect(cookiesfromIndex
— The position in this array at which to begin searching for searchElement..includes('context=2; Path=/')).toBe(true)
const cookies: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
expect(cookiesfromIndex
— The position in this array at which to begin searching for searchElement..includes('response=1; Path=/')).toBe(true)
const cookies: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
}) it('c.text()', async () => { const originalResponse = newfromIndex
— The position in this array at which to begin searching for searchElement.Response
const originalResponse: Response
(JSON
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..stringify({
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
foo: 'bar' }))space
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.const res =
(property) foo: string
c
const res: Response & TypedResponse<"foo", StatusCode, "text">
.text('foo',
let c: Context<any, any, {}>
originalResponse)
(property) Context<any, any, {}>.text: TextRespond <"foo", StatusCode>(text: "foo", init?: ResponseInit) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
expect(res
const originalResponse: Response
.headers
const res: Response & TypedResponse<"foo", StatusCode, "text">
.get('content-type')).toMatch(/^text\/plain/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('foo')
const res: Response & TypedResponse<"foo", StatusCode, "text">
}) it('c.html()', async () => { const originalResponse = new
(method) Body.text(): Promise<string>
MDN ReferenceResponse('foo')
const originalResponse: Response
const res = await
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.c
const res: Response
.html('
let c: Context<any, any, {}>
foo
',originalResponse)
(property) Context<any, any, {}>.html: HTMLRespond <"<h1>foo</h1>">(html: "<h1>foo</h1>", init?: ResponseInit) => Response (+1 overload)
expect(res
const originalResponse: Response
.headers
const res: Response
.get('content-type')).toMatch(/^text\/html/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('
const res: Response
foo
')}) }) declare module './context' { interface ContextRenderer {
(method) Body.text(): Promise<string>
MDN Reference(content: string |
interface ContextRenderer
Interface for context renderer.Promise
(parameter) content: string | Promise<string>
, head: {
interface Promise<T>
Represents the completion of an asynchronous operationtitle: string }):
(parameter) head: { title: string; }
Response |
(property) title: string
Promise
interface Response
This Fetch API interface represents the response to a request.<Response>
interface Promise<T>
Represents the completion of an asynchronous operation} } describe('c.render', () => { const req = new
interface Response
This Fetch API interface represents the response to a request.Request('http://localhost/')
const req: Request
let c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context
let c: Context<any, any, {}>
beforeEach(() => { c = new
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Context
let c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.}) it('Should return a Response from the default renderer', async () => { c
const req: Request
.header('foo', 'bar')
let c: Context<any, any, {}>
const res = await
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
const res: Response
.render('
let c: Context<any, any, {}>
content
', {title: 'dummy ' })
(property) Context<any, any, {}>.render: ContextRenderer (content: string | Promise<string>, head: { title: string; }) => Response | Promise<Response> (+1 overload)
expect(res
(property) title: string
.headers
const res: Response
.get('foo')).toBe('bar')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('
const res: Response
content
')}) it('Should return a Response from the custom renderer', async () => { c
(method) Body.text(): Promise<string>
MDN Reference.setRenderer(
let c: Context<any, any, {}>
(property) Context<any, any, {}>.setRenderer: (renderer: ContextRenderer) => void
.setRenderer()
can set the layout in the custom middleware.@see — https://hono.dev/docs/api/context#render-setrenderer
@example
(content,
tsx app.use('*', async (c, next) => { c.setRenderer((content) => { return c.html( <html> <body> <p>{content}</p> </body> </html> ) }) await next() })
head) => {
(parameter) content: string | Promise<string>
return c
(parameter) head: { title: string; } | { title: string; }
.html(`$
let c: Context<any, any, {}>
{head
(property) Context<any, any, {}>.html: HTMLRespond <`<html><head>${string}</head><body>${string}</body></html>`>(html: `<html><head>${string}</head><body>${string}</body></html>`, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.title}$
(parameter) head: { title: string; } | { title: string; }
{content}`)
(property) title: string
}) c
(parameter) content: string | Promise<string>
.header('foo', 'bar')
let c: Context<any, any, {}>
const res = await
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
const res: Response
.render('
let c: Context<any, any, {}>
content
', {title: 'title' })
(property) Context<any, any, {}>.render: ContextRenderer (content: string | Promise<string>, head: { title: string; }) => Response | Promise<Response> (+1 overload)
expect(res
(property) title: string
.headers
const res: Response
.get('foo')).toBe('bar')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('title
const res: Response
content
')}) })
(method) Body.text(): Promise<string>
MDN Reference
import { HonoRequest } from './request' import type { Result } from './router' import type { Env, FetchEventLike, H, Input, NotFoundHandler, RouterRoute, TypedResponse, } from './types' import { HtmlEscapedCallbackPhase, resolveCallback } from './utils/html' import type { RedirectStatusCode, StatusCode } from './utils/http-status' import type { BaseMime } from './utils/mime' import type { InvalidJSONValue, IsAny, JSONParsed, JSONValue, SimplifyDeepArray, } from './utils/types' type HeaderRecord =| Record<'Content-Type',
type HeaderRecord = Record<string, string | string[]> | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]>
BaseMime>
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T| Record
(alias) type BaseMime = "application/json" | "audio/aac" | "video/x-msvideo" | "image/avif" | "video/av1" | "application/octet-stream" | "image/bmp" | "text/css" | "text/csv" | "application/vnd.ms-fontobject" | ... 38 more ... | "model/gltf-binary" import BaseMime
Union types for BaseMime<ResponseHeader, string | string[]>
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T| Record
type ResponseHeader = "Content-Type" | "Cookie" | "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | ... 61 more ... | "X-XSS-Protection"
/** * Data type can be a string, ArrayBuffer, or ReadableStream. */ export type Data = string |
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TArrayBuffer |
type Data = string | ArrayBuffer | ReadableStream<any>
Data type can be a string, ArrayBuffer, or ReadableStream.ReadableStream
interface ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed./** * Interface for the execution context in a web worker or similar environment. */ export interface ExecutionContext {
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object./** * Extends the lifetime of the event callback until the promise is settled. * * @param promise - A promise to wait for. */ waitUntil
interface ExecutionContext
Interface for the execution context in a web worker or similar environment.
(method) ExecutionContext.waitUntil(promise: Promise<unknown>): void
Extends the lifetime of the event callback until the promise is settled.@param
(promise:promise
— A promise to wait for.
(parameter) promise: Promise<unknown>
- A promise to wait for.@param
Promisepromise
— A promise to wait for.): void /** * Allows the event to be passed through to subsequent event listeners. */ passThroughOnException(): void
interface Promise<T>
Represents the completion of an asynchronous operation} /** * Interface for context variable mapping. */ export interface ContextVariableMap {}
(method) ExecutionContext.passThroughOnException(): void
Allows the event to be passed through to subsequent event listeners./** * Interface for context renderer. */ export interface ContextRenderer {}
interface ContextVariableMap
Interface for context variable mapping./** * Interface representing a renderer for content. * * @interface DefaultRenderer * @param {string | Promise
interface ContextRenderer
Interface for context renderer.} content - The content to be rendered, which can be either a string or a Promise resolving to a string. * @returns {Response | Promise} - The response after rendering the content, which can be either a Response or a Promise resolving to a Response. */ interface DefaultRenderer {
interface DefaultRenderer
Interface representing a renderer for content.@interface — DefaultRenderer
@param
content
— The content to be rendered, which can be either a string or a Promise resolving to a string.@returns — - The response after rendering the content, which can be either a Response or a Promise resolving to a Response.
(content: string |Promise
(parameter) content: string | Promise<string>
): Response |
interface Promise<T>
Represents the completion of an asynchronous operationPromise
interface Response
This Fetch API interface represents the response to a request.<Response>
interface Promise<T>
Represents the completion of an asynchronous operation} /** * Renderer type which can either be a ContextRenderer or DefaultRenderer. */ export type Renderer =
interface Response
This Fetch API interface represents the response to a request.ContextRenderer extends
type Renderer = ContextRenderer
Renderer type which can either be a ContextRenderer or DefaultRenderer.Function ?
interface ContextRenderer
Interface for context renderer.ContextRenderer :
interface Function
Creates a new function.DefaultRenderer
interface ContextRenderer
Interface for context renderer.
interface DefaultRenderer
Interface representing a renderer for content.@interface — DefaultRenderer
@param
content
— The content to be rendered, which can be either a string or a Promise resolving to a string.@returns — - The response after rendering the content, which can be either a Response or a Promise resolving to a Response.
/** * Extracts the props for the renderer. */ export type PropsForRenderer = [...Required
type PropsForRenderer = { title: string; }
Extracts the props for the renderer.<Parameters
type Required<T> = { [P in keyof T]-?: T[P]; }
Make all properties in T required<Renderer>>] extends [unknown, infer
type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never
Obtain the parameters of a function type in a tupleProps]
type Renderer = ContextRenderer
Renderer type which can either be a ContextRenderer or DefaultRenderer.? Props
(type parameter) Props
: unknown // eslint-disable-next-line @typescript-eslint/no-explicit-any export type Layout
(type parameter) Props
<T =
type Layout<T = Record<string, any>> = (props: T) => any
Record
(type parameter) T in type Layout<T = Record<string, any>>
> = (props:
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TT) => any
(parameter) props: T = Record<string, any>
/** * Interface for getting context variables. * * @template E - Environment type. */ interface Get
(type parameter) T in type Layout<T = Record<string, any>>
interface Get<E extends Env>
Interface for getting context variables.@template
<E extendsE
— Environment type.
(type parameter) E in Get<E extends Env>
- Environment type.@template
Env> {E
— Environment type.<Key extends keyof
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
E['Variables']>
(type parameter) Key in <Key extends keyof E["Variables"]>(key: Key): E["Variables"][Key]
(type parameter) E in Get<E extends Env>
- Environment type.@template
(key:E
— Environment type.Key):
(parameter) key: Key extends keyof E["Variables"]
E['Variables']
(type parameter) Key in <Key extends keyof E["Variables"]>(key: Key): E["Variables"][Key]
(type parameter) E in Get<E extends Env>
- Environment type.@template
[Key]E
— Environment type.<Key extends keyof
(type parameter) Key in <Key extends keyof E["Variables"]>(key: Key): E["Variables"][Key]
ContextVariableMap>
(type parameter) Key in <Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key]
(key:
interface ContextVariableMap
Interface for context variable mapping.Key):
(parameter) key: Key extends keyof ContextVariableMap
ContextVariableMap
(type parameter) Key in <Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key]
[Key]
interface ContextVariableMap
Interface for context variable mapping.} /** * Interface for setting context variables. * * @template E - Environment type. */ interface Set
(type parameter) Key in <Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key]
interface Set<E extends Env>
Interface for setting context variables.@template
<E extendsE
— Environment type.
(type parameter) E in Set<E extends Env>
- Environment type.@template
Env> {E
— Environment type.<Key extends keyof
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
E['Variables']>
(type parameter) Key in <Key extends keyof E["Variables"]>(key: Key, value: E["Variables"][Key]): void
(type parameter) E in Set<E extends Env>
- Environment type.@template
(key:E
— Environment type.Key,
(parameter) key: Key extends keyof E["Variables"]
value:
(type parameter) Key in <Key extends keyof E["Variables"]>(key: Key, value: E["Variables"][Key]): void
E['Variables']
(parameter) value: E["Variables"][Key]
(type parameter) E in Set<E extends Env>
- Environment type.@template
[Key]): voidE
— Environment type.<Key extends keyof
(type parameter) Key in <Key extends keyof E["Variables"]>(key: Key, value: E["Variables"][Key]): void
ContextVariableMap>
(type parameter) Key in <Key extends keyof ContextVariableMap>(key: Key, value: ContextVariableMap[Key]): void
(key:
interface ContextVariableMap
Interface for context variable mapping.Key,
(parameter) key: Key extends keyof ContextVariableMap
value:
(type parameter) Key in <Key extends keyof ContextVariableMap>(key: Key, value: ContextVariableMap[Key]): void
ContextVariableMap
(parameter) value: ContextVariableMap[Key]
[Key]): void
interface ContextVariableMap
Interface for context variable mapping.} /** * Interface for creating a new response. */ interface NewResponse {
(type parameter) Key in <Key extends keyof ContextVariableMap>(key: Key, value: ContextVariableMap[Key]): void
(data:
interface NewResponse
Interface for creating a new response.Data | null,
(parameter) data: Data | null
status?:
type Data = string | ArrayBuffer | ReadableStream<any>
Data type can be a string, ArrayBuffer, or ReadableStream.StatusCode,
(parameter) status: StatusCode | undefined
headers?:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.HeaderRecord):
(parameter) headers: HeaderRecord | undefined
Response
type HeaderRecord = Record<string, string | string[]> | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]>
(data:
interface Response
This Fetch API interface represents the response to a request.Data | null,
(parameter) data: Data | null
init?:
type Data = string | ArrayBuffer | ReadableStream<any>
Data type can be a string, ArrayBuffer, or ReadableStream.ResponseInit):
(parameter) init: ResponseInit | undefined
Response
interface ResponseInit
} /** * Interface for responding with a body. */ interface BodyRespond extends
interface Response
This Fetch API interface represents the response to a request.NewResponse {}
interface BodyRespond
Interface for responding with a body./** * Interface for responding with text. * * @interface TextRespond * @template T - The type of the text content. * @template U - The type of the status code. * * @param {T} text - The text content to be included in the response. * @param {U} [status] - An optional status code for the response. * @param {HeaderRecord} [headers] - An optional record of headers to include in the response. * * @returns {Response & TypedResponse
interface NewResponse
Interface for creating a new response.} - The response after rendering the text content, typed with the provided text and status code types. */ interface TextRespond {
interface TextRespond
Interface for responding with text.@interface — TextRespond
@template
T
— The type of the text content.@template
U
— The type of the status code.@param
text
— The text content to be included in the response.@param
status
— An optional status code for the response.@param
headers
— An optional record of headers to include in the response.@returns — - The response after rendering the text content, typed with the provided text and status code types.
<T extends string,U extends
(type parameter) T in <T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, "text">
StatusCode =
(type parameter) U in <T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, "text">
StatusCode>(
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.text:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.T,
(parameter) text: T extends string
status?:
(type parameter) T in <T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, "text">
U,
(parameter) status: U | undefined
headers?:
(type parameter) U in <T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, "text">
HeaderRecord
(parameter) headers: HeaderRecord | undefined
): Response &
type HeaderRecord = Record<string, string | string[]> | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]>
TypedResponse
interface Response
This Fetch API interface represents the response to a request.<T,
(alias) type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : string> = { _data: T; _status: U; _format: F; } import TypedResponse
U, 'text'>
(type parameter) T in <T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, "text">
<T extends string,
(type parameter) U in <T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, "text">
U extends
(type parameter) T in <T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, "text">
StatusCode =
(type parameter) U in <T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, "text">
StatusCode>
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.(text:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.T,
(parameter) text: T extends string
init?:
(type parameter) T in <T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, "text">
ResponseInit):
(parameter) init: ResponseInit | undefined
Response &
interface ResponseInit
TypedResponse
interface Response
This Fetch API interface represents the response to a request.<T,
(alias) type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : string> = { _data: T; _status: U; _format: F; } import TypedResponse
U, 'text'>
(type parameter) T in <T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, "text">
} /** * Interface for responding with JSON. * * @interface JSONRespond * @template T - The type of the JSON value or simplified unknown type. * @template U - The type of the status code. * * @param {T} object - The JSON object to be included in the response. * @param {U} [status] - An optional status code for the response. * @param {HeaderRecord} [headers] - An optional record of headers to include in the response. * * @returns {JSONRespondReturn
(type parameter) U in <T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, "text">
} - The response after rendering the JSON object, typed with the provided object and status code types. */ interface JSONRespond {
interface JSONRespond
Interface for responding with JSON.@interface — JSONRespond
@template
T
— The type of the JSON value or simplified unknown type.@template
U
— The type of the status code.@param
object
— The JSON object to be included in the response.@param
status
— An optional status code for the response.@param
headers
— An optional record of headers to include in the response.@returns — - The response after rendering the JSON object, typed with the provided object and status code types.
< T extendsJSONValue |
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, status?: U, headers?: HeaderRecord): JSONRespondReturn<T, U>
SimplifyDeepArray
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
| InvalidJSONValue,
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.U extends
(alias) type InvalidJSONValue = symbol | ((...args: unknown[]) => unknown) | undefined import InvalidJSONValue
StatusCode =
(type parameter) U in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, status?: U, headers?: HeaderRecord): JSONRespondReturn<T, U>
StatusCode
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.>( object:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.T,
(parameter) object: T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue
status?:
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, status?: U, headers?: HeaderRecord): JSONRespondReturn<T, U>
U,
(parameter) status: U | undefined
headers?:
(type parameter) U in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, status?: U, headers?: HeaderRecord): JSONRespondReturn<T, U>
HeaderRecord
(parameter) headers: HeaderRecord | undefined
): JSONRespondReturn
type HeaderRecord = Record<string, string | string[]> | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]>
type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode> = Response & TypedResponse<SimplifyDeepArray<T> extends JSONValue ? JSONValue extends SimplifyDeepArray<T> ? never : JSONParsed<...> : never, U, "json">
@template
T
— The type of the JSON value or simplified unknown type.@template
U
— The type of the status code.@returns — - The response after rendering the JSON object, typed with the provided object and status code types.
<T,U>
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, status?: U, headers?: HeaderRecord): JSONRespondReturn<T, U>
< T extends
(type parameter) U in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, status?: U, headers?: HeaderRecord): JSONRespondReturn<T, U>
JSONValue |
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, init?: ResponseInit): JSONRespondReturn<T, U>
SimplifyDeepArray
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
| InvalidJSONValue,
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.U extends
(alias) type InvalidJSONValue = symbol | ((...args: unknown[]) => unknown) | undefined import InvalidJSONValue
StatusCode =
(type parameter) U in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, init?: ResponseInit): JSONRespondReturn<T, U>
StatusCode
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.>( object:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.T,
(parameter) object: T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue
init?:
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, init?: ResponseInit): JSONRespondReturn<T, U>
ResponseInit
(parameter) init: ResponseInit | undefined
): JSONRespondReturn
interface ResponseInit
type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode> = Response & TypedResponse<SimplifyDeepArray<T> extends JSONValue ? JSONValue extends SimplifyDeepArray<T> ? never : JSONParsed<...> : never, U, "json">
@template
T
— The type of the JSON value or simplified unknown type.@template
U
— The type of the status code.@returns — - The response after rendering the JSON object, typed with the provided object and status code types.
<T,U>
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, init?: ResponseInit): JSONRespondReturn<T, U>
} /** * @template T - The type of the JSON value or simplified unknown type. * @template U - The type of the status code. * * @returns {Response & TypedResponse
(type parameter) U in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, init?: ResponseInit): JSONRespondReturn<T, U>
extends JSONValue ? (JSONValue extends SimplifyDeepArray */ type JSONRespondReturn<? never : JSONParsed ) : never, U, 'json'>} - The response after rendering the JSON object, typed with the provided object and status code types.
type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode> = Response & TypedResponse<SimplifyDeepArray<T> extends JSONValue ? JSONValue extends SimplifyDeepArray<T> ? never : JSONParsed<...> : never, U, "json">
@template
T
— The type of the JSON value or simplified unknown type.@template
U
— The type of the status code.@returns — - The response after rendering the JSON object, typed with the provided object and status code types.
T extends
(type parameter) T in type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode>
- The type of the JSON value or simplified unknown type.@template
JSONValue |T
— The type of the JSON value or simplified unknown type.SimplifyDeepArray
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
| InvalidJSONValue,
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.U extends
(alias) type InvalidJSONValue = symbol | ((...args: unknown[]) => unknown) | undefined import InvalidJSONValue
(type parameter) U in type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode>
- The type of the status code.@template
StatusCodeU
— The type of the status code.> = Response &
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.TypedResponse<
interface Response
This Fetch API interface represents the response to a request.SimplifyDeepArray
(alias) type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : string> = { _data: T; _status: U; _format: F; } import TypedResponse
<T> extends
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.
(type parameter) T in type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode>
- The type of the JSON value or simplified unknown type.@template
JSONValueT
— The type of the JSON value or simplified unknown type.? JSONValue extends
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
SimplifyDeepArray
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
<T>
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.
(type parameter) T in type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode>
- The type of the JSON value or simplified unknown type.@template
? never : JSONParsedT
— The type of the JSON value or simplified unknown type.<T>
(alias) type JSONParsed<T> = T extends { toJSON(): infer J; } ? (() => J) extends () => JSONPrimitive ? J : (() => J) extends () => { toJSON(): unknown; } ? {} : JSONParsed<J> : T extends JSONPrimitive ? T : T extends InvalidJSONValue ? never : T extends readonly unknown[] ? { [K in keyof T]: JSONParsed<...>; } : T extends Map<...> | globalThis.Set<...> ? {} : T extends object ? { [K in keyof OmitSymbolKeys<...> as IsInvalid<...> extends true ? never : K]: boolean extends IsInvalid<...> ? JSONParsed<...> | undefined : JSONParsed<...>; } : never import JSONParsed
(type parameter) T in type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode>
- The type of the JSON value or simplified unknown type.@template
: never, U,T
— The type of the JSON value or simplified unknown type.
(type parameter) U in type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode>
- The type of the status code.@template
'json' > /** * Interface representing a function that responds with HTML content. * * @param html - The HTML content to respond with, which can be a string or a Promise that resolves to a string. * @param status - (Optional) The HTTP status code for the response. * @param headers - (Optional) A record of headers to include in the response. * @param init - (Optional) The response initialization object. * * @returns A Response object or a Promise that resolves to a Response object. */ interface HTMLRespond {U
— The type of the status code.
interface HTMLRespond
Interface representing a function that responds with HTML content.@param
html
— The HTML content to respond with, which can be a string or a Promise that resolves to a string.@param
status
— (Optional) The HTTP status code for the response.@param
headers
— (Optional) A record of headers to include in the response.@param
init
— (Optional) The response initialization object.@returns — A Response object or a Promise that resolves to a Response object.
<T extends string |Promise
(type parameter) T in <T extends string | Promise<string>>(html: T, status?: StatusCode, headers?: HeaderRecord): T extends string ? Response : Promise<Response>
>( html:
interface Promise<T>
Represents the completion of an asynchronous operationT,
(parameter) html: T extends string | Promise<string>
status?:
(type parameter) T in <T extends string | Promise<string>>(html: T, status?: StatusCode, headers?: HeaderRecord): T extends string ? Response : Promise<Response>
StatusCode,
(parameter) status: StatusCode | undefined
headers?:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.HeaderRecord
(parameter) headers: HeaderRecord | undefined
): T extends string ?
type HeaderRecord = Record<string, string | string[]> | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]>
Response :
(type parameter) T in <T extends string | Promise<string>>(html: T, status?: StatusCode, headers?: HeaderRecord): T extends string ? Response : Promise<Response>
Promise
interface Response
This Fetch API interface represents the response to a request.<Response>
interface Promise<T>
Represents the completion of an asynchronous operation<T extends string |
interface Response
This Fetch API interface represents the response to a request.Promise
(type parameter) T in <T extends string | Promise<string>>(html: T, init?: ResponseInit): T extends string ? Response : Promise<Response>
> (html:
interface Promise<T>
Represents the completion of an asynchronous operationT,
(parameter) html: T extends string | Promise<string>
init?:
(type parameter) T in <T extends string | Promise<string>>(html: T, init?: ResponseInit): T extends string ? Response : Promise<Response>
ResponseInit):
(parameter) init: ResponseInit | undefined
T extends string
interface ResponseInit
? Response
(type parameter) T in <T extends string | Promise<string>>(html: T, init?: ResponseInit): T extends string ? Response : Promise<Response>
: Promise
interface Response
This Fetch API interface represents the response to a request.<Response>
interface Promise<T>
Represents the completion of an asynchronous operation} /** * Options for configuring the context. * * @template E - Environment type. */ type ContextOptions
interface Response
This Fetch API interface represents the response to a request.
type ContextOptions<E extends Env> = { env: E["Bindings"]; executionCtx?: FetchEventLike | ExecutionContext | undefined; notFoundHandler?: NotFoundHandler<E>; matchResult?: Result<[H, RouterRoute]>; path?: string; }
Options for configuring the context.@template
<E extendsE
— Environment type.
(type parameter) E in type ContextOptions<E extends Env>
- Environment type.@template
Env> = {E
— Environment type./** * Bindings for the environment. */ env:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
E['Bindings']
(property) env: E["Bindings"]
Bindings for the environment.
(type parameter) E in type ContextOptions<E extends Env>
- Environment type.@template
/** * Execution context for the request. */ executionCtx?:E
— Environment type.FetchEventLike |
(property) executionCtx?: FetchEventLike | ExecutionContext | undefined
Execution context for the request.ExecutionContext | undefined
(alias) class FetchEventLike import FetchEventLike
/** * Handler for not found responses. */ notFoundHandler?:
interface ExecutionContext
Interface for the execution context in a web worker or similar environment.NotFoundHandler
(property) notFoundHandler?: NotFoundHandler<E> | undefined
Handler for not found responses.<E>
(alias) type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response> import NotFoundHandler
(type parameter) E in type ContextOptions<E extends Env>
- Environment type.@template
matchResult?:E
— Environment type.Result<
(property) matchResult?: Result<[H, RouterRoute]> | undefined
(alias) type Result<T> = [[T, ParamIndexMap][], ParamStash] | [[T, Params][]] import 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]
[ [ [middlewareA, {}], // '*' [funcA, {'id': 0}], // '/user/:id/*' [funcB, {'id': 0, 'action': 1}], // '/user/:id/:action' ], ['123', 'abc'] ]
[[handler, params][]]
[H,[ [ [middlewareA, {}], // '*' [funcA, {'id': '123'}], // '/user/:id/*' [funcB, {'id': '123', 'action': 'abc'}], // '/user/:id/:action' ] ]
RouterRoute]>
(alias) 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> import H
path?: string
(alias) interface RouterRoute import RouterRoute
} interface SetHeadersOptions {
(property) path?: string | undefined
append?: boolean
interface SetHeadersOptions
} type ResponseHeader =
(property) SetHeadersOptions.append?: boolean | undefined
| 'Access-Control-Allow-Credentials' | 'Access-Control-Allow-Headers' | 'Access-Control-Allow-Methods' | 'Access-Control-Allow-Origin' | 'Access-Control-Expose-Headers' | 'Access-Control-Max-Age' | 'Age' | 'Allow' | 'Cache-Control' | 'Clear-Site-Data' | 'Content-Disposition' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-Range' | 'Content-Security-Policy' | 'Content-Security-Policy-Report-Only' | 'Content-Type' | 'Cookie' | 'Cross-Origin-Embedder-Policy' | 'Cross-Origin-Opener-Policy' | 'Cross-Origin-Resource-Policy' | 'Date' | 'ETag' | 'Expires' | 'Last-Modified' | 'Location' | 'Permissions-Policy' | 'Pragma' | 'Retry-After' | 'Save-Data' | 'Sec-CH-Prefers-Color-Scheme' | 'Sec-CH-Prefers-Reduced-Motion' | 'Sec-CH-UA' | 'Sec-CH-UA-Arch' | 'Sec-CH-UA-Bitness' | 'Sec-CH-UA-Form-Factor' | 'Sec-CH-UA-Full-Version' | 'Sec-CH-UA-Full-Version-List' | 'Sec-CH-UA-Mobile' | 'Sec-CH-UA-Model' | 'Sec-CH-UA-Platform' | 'Sec-CH-UA-Platform-Version' | 'Sec-CH-UA-WoW64' | 'Sec-Fetch-Dest' | 'Sec-Fetch-Mode' | 'Sec-Fetch-Site' | 'Sec-Fetch-User' | 'Sec-GPC' | 'Server' | 'Server-Timing' | 'Service-Worker-Navigation-Preload' | 'Set-Cookie' | 'Strict-Transport-Security' | 'Timing-Allow-Origin' | 'Trailer' | 'Transfer-Encoding' | 'Upgrade' | 'Vary' | 'WWW-Authenticate' | 'Warning' | 'X-Content-Type-Options' | 'X-DNS-Prefetch-Control' | 'X-Frame-Options' | 'X-Permitted-Cross-Domain-Policies' | 'X-Powered-By' | 'X-Robots-Tag' | 'X-XSS-Protection' interface SetHeaders {
type ResponseHeader = "Content-Type" | "Cookie" | "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | ... 61 more ... | "X-XSS-Protection"
(name: 'Content-Type',
interface SetHeaders
value?:
(parameter) name: "Content-Type"
BaseMime,
(parameter) value: BaseMime | undefined
options?:
(alias) type BaseMime = "application/json" | "audio/aac" | "video/x-msvideo" | "image/avif" | "video/av1" | "application/octet-stream" | "image/bmp" | "text/css" | "text/csv" | "application/vnd.ms-fontobject" | ... 38 more ... | "model/gltf-binary" import BaseMime
Union types for BaseMimeSetHeadersOptions): void
(parameter) options: SetHeadersOptions | undefined
(name:
interface SetHeadersOptions
ResponseHeader,
(parameter) name: ResponseHeader
value?: string,
type ResponseHeader = "Content-Type" | "Cookie" | "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | ... 61 more ... | "X-XSS-Protection"
options?:
(parameter) value: string | undefined
SetHeadersOptions): void
(parameter) options: SetHeadersOptions | undefined
(name: string,
interface SetHeadersOptions
value?: string,
(parameter) name: string
options?:
(parameter) value: string | undefined
SetHeadersOptions): void
(parameter) options: SetHeadersOptions | undefined
} type ResponseHeadersInit =
interface SetHeadersOptions
| [string, string][] | Record<'Content-Type',
type ResponseHeadersInit = Record<string, string> | Headers | [string, string][] | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string>
BaseMime>
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T| Record
(alias) type BaseMime = "application/json" | "audio/aac" | "video/x-msvideo" | "image/avif" | "video/av1" | "application/octet-stream" | "image/bmp" | "text/css" | "text/csv" | "application/vnd.ms-fontobject" | ... 38 more ... | "model/gltf-binary" import BaseMime
Union types for BaseMime<ResponseHeader, string>
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T| Record
type ResponseHeader = "Content-Type" | "Cookie" | "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | ... 61 more ... | "X-XSS-Protection"
| Headers
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tinterface ResponseInit {
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.headers?:
interface ResponseInit
ResponseHeadersInit
(property) ResponseInit.headers?: ResponseHeadersInit | undefined
status?: number
type ResponseHeadersInit = Record<string, string> | Headers | [string, string][] | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string>
statusText?: string
(property) ResponseInit.status?: number | undefined
} export const TEXT_PLAIN = 'text/plain; charset=UTF-8'
(property) ResponseInit.statusText?: string | undefined
/** * Sets the headers of a response. * * @param headers - The Headers object to set the headers on. * @param map - A record of header key-value pairs to set. * @returns The updated Headers object. */ const setHeaders =
const TEXT_PLAIN: "text/plain; charset=UTF-8"
const setHeaders: (headers: Headers, map?: Record<string, string>) => Headers
Sets the headers of a response.@param
headers
— The Headers object to set the headers on.@param
map
— A record of header key-value pairs to set.@returns — The updated Headers object.
(headers:
(parameter) headers: Headers
- The Headers object to set the headers on.@param
Headers,headers
— The Headers object to set the headers on.map:
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.
(parameter) map: Record<string, string>
- A record of header key-value pairs to set.@param
Recordmap
— A record of header key-value pairs to set.= {}) => { Object
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string>(o: { [s: string]: string; } | ArrayLike<string>): [string, string][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(map)o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
(parameter) map: Record<string, string>
- A record of header key-value pairs to set.@param
.forEach((map
— A record of header key-value pairs to set.
(method) Array<[string, string]>.forEach(callbackfn: (value: [string, string], index: number, array: [string, string][]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
[key,thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.value]) =>
(parameter) key: string
headers
(parameter) value: string
(parameter) headers: Headers
- The Headers object to set the headers on.@param
.setheaders
— The Headers object to set the headers on.(key,
(method) Headers.set(name: string, value: string): void
MDN Referencevalue))
(parameter) key: string
return headers
(parameter) value: string
(parameter) headers: Headers
- The Headers object to set the headers on.@param
} export class Context<headers
— The Headers object to set the headers on.// eslint-disable-next-line @typescript-eslint/no-explicit-any E extends
class Context<E extends Env = any, P extends string = any, I extends Input = {}>
Env = any,
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
// eslint-disable-next-line @typescript-eslint/no-explicit-any P extends string = any,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
I extends
(type parameter) P in Context<E extends Env = any, P extends string = any, I extends Input = {}>
Input = {}
(type parameter) I in Context<E extends Env = any, P extends string = any, I extends Input = {}>
> { #rawRequest: Request
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
#req: HonoRequest
interface Request
This Fetch API interface represents a resource request.<P,
(alias) class HonoRequest<P extends string = "/", I extends Input["out"] = {}> import HonoRequest
I['out']> | undefined
(type parameter) P in Context<E extends Env = any, P extends string = any, I extends Input = {}>
/** * `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers. * * @see {@link https://hono.dev/docs/api/context#env} * * @example * ```ts * // Environment object for Cloudflare Workers * app.get('*', async c => { * const counter = c.env.COUNTER * }) * ``` */ env:
(type parameter) I in Context<E extends Env = any, P extends string = any, I extends Input = {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.env: E["Bindings"]
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
E['Bindings'] = {}
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
#var: Map
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
| undefined finalized: boolean = false
interface Map<K, V>
/** * `.error` can get the error object from the middleware if the Handler throws an error. * * @see {@link https://hono.dev/docs/api/context#error} * * @example * ```ts * app.use('*', async (c, next) => { * await next() * if (c.error) { * // do something... * } * }) * ``` */ error:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.finalized: boolean
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
Error | undefined
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
#status: StatusCode = 200
interface Error
#executionCtx: FetchEventLike |
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.ExecutionContext | undefined
(alias) class FetchEventLike import FetchEventLike
#headers: Headers | undefined
interface ExecutionContext
Interface for the execution context in a web worker or similar environment.#preparedHeaders: Record
interface Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.| undefined #res: Response | undefined
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T#isFresh = true #layout: Layout
interface Response
This Fetch API interface represents the response to a request.<PropsForRenderer & {
type Layout<T = Record<string, any>> = (props: T) => any
Layout:
type PropsForRenderer = { title: string; }
Extracts the props for the renderer.Layout }> | undefined
(property) Layout: Layout<Record<string, any>>
#renderer: Renderer | undefined
type Layout<T = Record<string, any>> = (props: T) => any
#notFoundHandler: NotFoundHandler
type Renderer = ContextRenderer
Renderer type which can either be a ContextRenderer or DefaultRenderer.<E> | undefined
(alias) type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response> import NotFoundHandler
#matchResult: Result<
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
(alias) type Result<T> = [[T, ParamIndexMap][], ParamStash] | [[T, Params][]] import 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]
[ [ [middlewareA, {}], // '*' [funcA, {'id': 0}], // '/user/:id/*' [funcB, {'id': 0, 'action': 1}], // '/user/:id/:action' ], ['123', 'abc'] ]
[[handler, params][]]
[H,[ [ [middlewareA, {}], // '*' [funcA, {'id': '123'}], // '/user/:id/*' [funcB, {'id': '123', 'action': 'abc'}], // '/user/:id/:action' ] ]
RouterRoute]> | undefined
(alias) 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> import H
#path: string | undefined /** * Creates an instance of the Context class. * * @param req - The Request object. * @param options - Optional configuration options for the context. */ constructor(req:
(alias) interface RouterRoute import RouterRoute
(parameter) req: Request
- The Request object.@param
Request,req
— The Request object.options?:
interface Request
This Fetch API interface represents a resource request.
(parameter) options: ContextOptions<E> | undefined
- Optional configuration options for the context.@param
ContextOptionsoptions
— Optional configuration options for the context.
type ContextOptions<E extends Env> = { env: E["Bindings"]; executionCtx?: FetchEventLike | ExecutionContext | undefined; notFoundHandler?: NotFoundHandler<E>; matchResult?: Result<[H, RouterRoute]>; path?: string; }
Options for configuring the context.@template
<E>) {E
— Environment type.this.#rawRequest = req
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
(parameter) req: Request
- The Request object.@param
if (options) {req
— The Request object.
(parameter) options: ContextOptions<E> | undefined
- Optional configuration options for the context.@param
this.#executionCtx = optionsoptions
— Optional configuration options for the context.
(parameter) options: ContextOptions<E>
- Optional configuration options for the context.@param
.executionCtxoptions
— Optional configuration options for the context.this.env =
(property) executionCtx?: FetchEventLike | ExecutionContext | undefined
Execution context for the request.
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.env: E["Bindings"]
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
options
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
(parameter) options: ContextOptions<E>
- Optional configuration options for the context.@param
.envoptions
— Optional configuration options for the context.this.#notFoundHandler = options
(property) env: E["Bindings"]
Bindings for the environment.
(parameter) options: ContextOptions<E>
- Optional configuration options for the context.@param
.notFoundHandleroptions
— Optional configuration options for the context.this.#path = options
(property) notFoundHandler?: NotFoundHandler<E> | undefined
Handler for not found responses.
(parameter) options: ContextOptions<E>
- Optional configuration options for the context.@param
.pathoptions
— Optional configuration options for the context.this.#matchResult = options
(property) path?: string | undefined
(parameter) options: ContextOptions<E>
- Optional configuration options for the context.@param
.matchResultoptions
— Optional configuration options for the context.} } /** * `.req` is the instance of {@link HonoRequest}. */ get req():
(property) matchResult?: Result<[H, RouterRoute]> | undefined
HonoRequest
(getter) Context<E extends Env = any, P extends string = any, I extends Input = {}>.req: HonoRequest<P, I["out"]>
.req
is the instance of HonoRequest.<P,
(alias) class HonoRequest<P extends string = "/", I extends Input["out"] = {}> import HonoRequest
I['out']> {
(type parameter) P in Context<E extends Env = any, P extends string = any, I extends Input = {}>
this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult)
(type parameter) I in Context<E extends Env = any, P extends string = any, I extends Input = {}>
return this.#req } /** * @see {@link https://hono.dev/docs/api/context#event} * The FetchEvent associated with the current request. * * @throws Will throw an error if the context does not have a FetchEvent. */ get event():
(alias) new HonoRequest<P, I["out"]>(request: Request, path?: string, matchResult?: Result<[unknown, RouterRoute]>): HonoRequest<P, I["out"]> import HonoRequest
(getter) Context<E extends Env = any, P extends string = any, I extends Input = {}>.event: FetchEventLike
@see — https://hono.dev/docs/api/context#eventThe FetchEvent associated with the current request.
@throws — Will throw an error if the context does not have a FetchEvent.
FetchEventLike {if (this.#executionCtx && 'respondWith' in this.#executionCtx) { return this.#executionCtx } else { throw Error('This context has no FetchEvent')
(alias) class FetchEventLike import FetchEventLike
} } /** * @see {@link https://hono.dev/docs/api/context#executionctx} * The ExecutionContext associated with the current request. * * @throws Will throw an error if the context does not have an ExecutionContext. */ get executionCtx():
var Error: ErrorConstructor (message?: string, options?: ErrorOptions) => Error (+1 overload)
(getter) Context<E extends Env = any, P extends string = any, I extends Input = {}>.executionCtx: ExecutionContext
@see — https://hono.dev/docs/api/context#executionctxThe ExecutionContext associated with the current request.
@throws — Will throw an error if the context does not have an ExecutionContext.
ExecutionContext {if (this.#executionCtx) { return this.#executionCtx as ExecutionContext
interface ExecutionContext
Interface for the execution context in a web worker or similar environment.} else { throw Error('This context has no ExecutionContext')
interface ExecutionContext
Interface for the execution context in a web worker or similar environment.} } /** * @see {@link https://hono.dev/docs/api/context#res} * The Response object for the current request. */ get res():
var Error: ErrorConstructor (message?: string, options?: ErrorOptions) => Error (+1 overload)
(getter) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
Response {this.#isFresh = false return (this.#res ||= new Response('404 Not Found', {
interface Response
This Fetch API interface represents the response to a request.status: 404 }))
var Response: new (body?: BodyInit | null, init?: globalThis.ResponseInit) => Response
This Fetch API interface represents the response to a request.} /** * Sets the Response object for the current request. * * @param _res - The Response object to set. */ set res
(property) ResponseInit.status?: number | undefined
(setter) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@param
(_res:_res
— The Response object to set.
(parameter) _res: Response | undefined
- The Response object to set.@param
Response | undefined) {_res
— The Response object to set.this.#isFresh = false if (this.#res && _res) {
interface Response
This Fetch API interface represents the response to a request.
(parameter) _res: Response | undefined
- The Response object to set.@param
try { for (const [k,_res
— The Response object to set.v] of this.#res
const k: string
.headers
const v: string
.entries()) {
(property) Response.headers: Headers
MDN Referenceif (k === 'content-type') {
(method) Headers.entries(): HeadersIterator<[string, string]>
Returns an iterator allowing to go through all key/value pairs contained in this object.continue } if (k === 'set-cookie') {
const k: string
const cookies = this.#res
const k: string
.headers
const cookies: string[]
.getSetCookie()
(property) Response.headers: Headers
MDN Reference_res
(method) Headers.getSetCookie(): string[]
MDN Reference
(parameter) _res: Response
- The Response object to set.@param
.headers_res
— The Response object to set..delete('set-cookie')
(property) Response.headers: Headers
MDN Referencefor (const cookie of
(method) Headers.delete(name: string): void
MDN Referencecookies) {
const cookie: string
_res
const cookies: string[]
(parameter) _res: Response
- The Response object to set.@param
.headers_res
— The Response object to set..append('set-cookie',
(property) Response.headers: Headers
MDN Referencecookie)
(method) Headers.append(name: string, value: string): void
MDN Reference} } else { _res
const cookie: string
(parameter) _res: Response
- The Response object to set.@param
.headers_res
— The Response object to set..set
(property) Response.headers: Headers
MDN Reference(k,
(method) Headers.set(name: string, value: string): void
MDN Referencev)
const k: string
} } } catch (e) {
const v: string
if (e instanceof
(local var) e: unknown
TypeError &&
(local var) e: unknown
e
var TypeError: TypeErrorConstructor
.message
(local var) e: TypeError
.includes('immutable')) {
(property) Error.message: string
(method) String.includes(searchString: string, position?: number): boolean
Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.@param
searchString
— search string@param
// `_res` is immutable (probably a response from a fetch API), so retry with a new response. this.res = newposition
— If position is undefined, 0 is assumed, so as to search all of the String.
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@param
Response_res
— The Response object to set.(_res
var Response: new (body?: BodyInit | null, init?: globalThis.ResponseInit) => Response
This Fetch API interface represents the response to a request.
(parameter) _res: Response
- The Response object to set.@param
.body, {_res
— The Response object to set.headers:
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference_res
(property) ResponseInit.headers?: HeadersInit | undefined
(parameter) _res: Response
- The Response object to set.@param
.headers,_res
— The Response object to set.status:
(property) Response.headers: Headers
MDN Reference_res
(property) ResponseInit.status?: number | undefined
(parameter) _res: Response
- The Response object to set.@param
.status,_res
— The Response object to set.}) return } else { throw e
(property) Response.status: number
MDN Reference} } } this.#res = _res
(local var) e: unknown
(parameter) _res: Response | undefined
- The Response object to set.@param
this.finalized = true_res
— The Response object to set.} /** * `.render()` can create a response within a layout. * * @see {@link https://hono.dev/docs/api/context#render-setrenderer} * * @example * ```ts * app.get('/', (c) => { * return c.render('Hello!') * }) * ``` */ render:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.finalized: boolean
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.render: ContextRenderer
.render()
can create a response within a layout.@see — https://hono.dev/docs/api/context#render-setrenderer
@example
Renderer = (..
ts app.get('/', (c) => { return c.render('Hello!') })
.args) => {
type Renderer = ContextRenderer
Renderer type which can either be a ContextRenderer or DefaultRenderer.this.#renderer ??= (content: string |
(parameter) args: [content: string | Promise<string>, head: { title: string; }]
Promise
(parameter) content: string | Promise<string>
) => this .html
interface Promise<T>
Represents the completion of an asynchronous operation(content)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.html: HTMLRespond <string | Promise<string>>(html: string | Promise<string>, status?: StatusCode, headers?: HeaderRecord) => Response | Promise<Response> (+1 overload)
return this.#renderer(...args)
(parameter) content: string | Promise<string>
} /** * Sets the layout for the response. * * @param layout - The layout to set. * @returns The layout function. */ setLayout = (
(parameter) args: [content: string | Promise<string>, head: { title: string; }]
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.setLayout: (layout: Layout<PropsForRenderer & { Layout: Layout; }>) => Layout<PropsForRenderer & { Layout: Layout; }>
Sets the layout for the response.@param
layout
— The layout to set.@returns — The layout function.
layout:
(parameter) layout: Layout<{ title: string; } & { Layout: Layout; }>
- The layout to set.@param
Layoutlayout
— The layout to set.<PropsForRenderer & {
type Layout<T = Record<string, any>> = (props: T) => any
Layout:
type PropsForRenderer = { title: string; }
Extracts the props for the renderer.Layout }>
(property) Layout: Layout<Record<string, any>>
): Layout<
type Layout<T = Record<string, any>> = (props: T) => any
PropsForRenderer & {
type Layout<T = Record<string, any>> = (props: T) => any
Layout:
type PropsForRenderer = { title: string; }
Extracts the props for the renderer.Layout
(property) Layout: Layout<Record<string, any>>
} > => (this.#layout = layout)
type Layout<T = Record<string, any>> = (props: T) => any
(parameter) layout: Layout<{ title: string; } & { Layout: Layout; }>
- The layout to set.@param
/** * Gets the current layout for the response. * * @returns The current layout function. */ getLayout = ():layout
— The layout to set.
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.getLayout: () => Layout<PropsForRenderer & { Layout: Layout; }> | undefined
Gets the current layout for the response.@returns — The current layout function.
Layout<PropsForRenderer & {
type Layout<T = Record<string, any>> = (props: T) => any
Layout:
type PropsForRenderer = { title: string; }
Extracts the props for the renderer.Layout }> | undefined => this.#layout
(property) Layout: Layout<Record<string, any>>
/** * `.setRenderer()` can set the layout in the custom middleware. * * @see {@link https://hono.dev/docs/api/context#render-setrenderer} * * @example * ```tsx * app.use('*', async (c, next) => { * c.setRenderer((content) => { * return c.html( * * *
type Layout<T = Record<string, any>> = (props: T) => any
{content}
* * * ) * }) * await next() * }) * ``` */ setRenderer =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.setRenderer: (renderer: Renderer) => void
.setRenderer()
can set the layout in the custom middleware.@see — https://hono.dev/docs/api/context#render-setrenderer
@example
(renderer:
tsx app.use('*', async (c, next) => { c.setRenderer((content) => { return c.html( <html> <body> <p>{content}</p> </body> </html> ) }) await next() })
Renderer): void => {
(parameter) renderer: ContextRenderer
this.#renderer = renderer
type Renderer = ContextRenderer
Renderer type which can either be a ContextRenderer or DefaultRenderer.} /** * `.header()` can set headers. * * @see {@link https://hono.dev/docs/api/context#body} * * @example * ```ts * app.get('/welcome', (c) => { * // Set headers * c.header('X-Message', 'Hello!') * c.header('Content-Type', 'text/plain') * * return c.body('Thank you for coming') * }) * ``` */ header:
(parameter) renderer: ContextRenderer
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders
.header()
can set headers.@see — https://hono.dev/docs/api/context#body
@example
```ts app.get('/welcome', (c) => { // Set headers c.header('X-Message', 'Hello!') c.header('Content-Type', 'text/plain')return c.body('Thank you for coming') }) ```
SetHeaders =(name,
interface SetHeaders
value,
(parameter) name: string
options): void => {
(parameter) value: string | undefined
// Clear the header if (value === undefined) {
(parameter) options: SetHeadersOptions | undefined
if (this.#headers) { this.#headers.delete
(parameter) value: string | undefined
(name)
(method) Headers.delete(name: string): void
MDN Reference} else if (this.#preparedHeaders) { delete this.#preparedHeaders[name
(parameter) name: string
.toLocaleLowerCase()]
(parameter) name: string
} if (this.finalized) {
(method) String.toLocaleLowerCase(locales?: Intl.LocalesArgument): string (+1 overload)
Converts all alphabetic characters to lowercase, taking into account the host environment's current locale.this.res
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.finalized: boolean
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..delete
(property) Response.headers: Headers
MDN Reference(name)
(method) Headers.delete(name: string): void
MDN Reference} return } if (options?
(parameter) name: string
.append) {
(parameter) options: SetHeadersOptions | undefined
if (!this.#headers) { this.#isFresh = false this.#headers = new Headers(this.#preparedHeaders)
(property) SetHeadersOptions.append?: boolean | undefined
this.#preparedHeaders = {} } this.#headers.append
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.(name,
(method) Headers.append(name: string, value: string): void
MDN Referencevalue)
(parameter) name: string
} else { if (this.#headers) { this.#headers.set
(parameter) value: string
(name,
(method) Headers.set(name: string, value: string): void
MDN Referencevalue)
(parameter) name: string
} else { this.#preparedHeaders ??= {} this.#preparedHeaders[name
(parameter) value: string
.toLowerCase()] =
(parameter) name: string
value
(method) String.toLowerCase(): string
Converts all the alphabetic characters in a string to lowercase.} } if (this.finalized) {
(parameter) value: string
if (options?
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.finalized: boolean
.append) {
(parameter) options: SetHeadersOptions | undefined
this.res
(property) SetHeadersOptions.append?: boolean | undefined
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append
(property) Response.headers: Headers
MDN Reference(name,
(method) Headers.append(name: string, value: string): void
MDN Referencevalue)
(parameter) name: string
} else { this.res
(parameter) value: string
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..set
(property) Response.headers: Headers
MDN Reference(name,
(method) Headers.set(name: string, value: string): void
MDN Referencevalue)
(parameter) name: string
} } } status =
(parameter) value: string
(status:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.status: (status: StatusCode) => void
StatusCode): void => {
(parameter) status: StatusCode
this.#isFresh = false this.#status = status
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.} /** * `.set()` can set the value specified by the key. * * @see {@link https://hono.dev/docs/api/context#set-get} * * @example * ```ts * app.use('*', async (c, next) => { * c.set('message', 'Hono is cool!!') * await next() * }) * ``` */ set:
(parameter) status: StatusCode
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.set: Set<IsAny<E> extends true ? { Variables: ContextVariableMap & Record<string, any>; } : E>
.set()
can set the value specified by the key.@see — https://hono.dev/docs/api/context#set-get
@example
Set<
ts app.use('*', async (c, next) => { c.set('message', 'Hono is cool!!') await next() })
interface Set<E extends Env>
Interface for setting context variables.@template
IsAnyE
— Environment type.<E> extends true
(alias) type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false import IsAny
? { // eslint-disable-next-line @typescript-eslint/no-explicit-any Variables:
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
ContextVariableMap &
(property) Variables: ContextVariableMap & Record<string, any>
Record
interface ContextVariableMap
Interface for context variable mapping.} : E
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T> = (key: string,
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
value: unknown) => {
(parameter) key: string
this.#var ??= new Map()
(parameter) value: unknown
this.#var.set
var Map: MapConstructor new () => Map<any, any> (+3 overloads)
(key,
(method) Map<unknown, unknown>.set(key: unknown, value: unknown): Map<unknown, unknown>
Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.value)
(parameter) key: string
} /** * `.get()` can use the value specified by the key. * * @see {@link https://hono.dev/docs/api/context#set-get} * * @example * ```ts * app.get('/', (c) => { * const message = c.get('message') * return c.text(`The message is "${message}"`) * }) * ``` */ get:
(parameter) value: unknown
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.get: Get<IsAny<E> extends true ? { Variables: ContextVariableMap & Record<string, any>; } : E>
.get()
can use the value specified by the key.@see — https://hono.dev/docs/api/context#set-get
@example
Get<
ts app.get('/', (c) => { const message = c.get('message') return c.text(`The message is "${message}"`) })
interface Get<E extends Env>
Interface for getting context variables.@template
IsAnyE
— Environment type.<E> extends true
(alias) type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false import IsAny
? { // eslint-disable-next-line @typescript-eslint/no-explicit-any Variables:
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
ContextVariableMap &
(property) Variables: ContextVariableMap & Record<string, any>
Record
interface ContextVariableMap
Interface for context variable mapping.} : E
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T> = (key: string) => {
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
return this.#var ? this.#var.get
(parameter) key: string
(method) Map<unknown, unknown>.get(key: unknown): unknown
Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.@returns — Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
(key) : undefined} /** * `.var` can access the value of a variable. * * @see {@link https://hono.dev/docs/api/context#var} * * @example * ```ts * const result = c.var.client.oneMethod() * ``` */ // c.var.propName is a read-only get var():
(parameter) key: string
(getter) Context<E extends Env = any, P extends string = any, I extends Input = {}>.var: Readonly<ContextVariableMap & (IsAny<E["Variables"]> extends true ? Record<string, any> : E["Variables"])>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
Readonly<
ts const result = c.var.client.oneMethod()
// eslint-disable-next-line @typescript-eslint/no-explicit-any ContextVariableMap &
type Readonly<T> = { readonly [P in keyof T]: T[P]; }
Make all properties in T readonly(IsAny
interface ContextVariableMap
Interface for context variable mapping.<E['Variables']> extends true ?
(alias) type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false import IsAny
Record
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
: E['Variables'])
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T> { if (!this.#var) { // eslint-disable-next-line @typescript-eslint/no-explicit-any return {} as any } return Object
(type parameter) E in Context<E extends Env = any, P extends string = any, I extends Input = {}>
.fromEntries(this.#var)
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.fromEntries(entries: Iterable<readonly any[]>): any (+1 overload)
Returns an object created by key-value entries for properties and methods@param
} newResponse:entries
— An iterable object that contains key-value entries for properties and methods.NewResponse = (
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse
data:
interface NewResponse
Interface for creating a new response.Data | null,
(parameter) data: Data | null
arg?:
type Data = string | ArrayBuffer | ReadableStream<any>
Data type can be a string, ArrayBuffer, or ReadableStream.StatusCode |
(parameter) arg: StatusCode | ResponseInit | undefined
ResponseInit,
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.headers?:
interface ResponseInit
HeaderRecord
(parameter) headers: HeaderRecord | undefined
): Response => {
type HeaderRecord = Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]> | Record<string, string | string[]>
// Optimized if (this.#isFresh && !headers &&
interface Response
This Fetch API interface represents the response to a request.!arg && this.#status === 200) {
(parameter) headers: HeaderRecord | undefined
return new Response
(parameter) arg: StatusCode | ResponseInit | undefined
(data, {
var Response: new (body?: BodyInit | null, init?: globalThis.ResponseInit) => Response
This Fetch API interface represents the response to a request.headers: this.#preparedHeaders,
(parameter) data: Data | null
}) } if (arg && typeof
(property) ResponseInit.headers?: HeadersInit | undefined
arg !== 'number') {
(parameter) arg: StatusCode | ResponseInit | undefined
const header = new
(parameter) arg: StatusCode | ResponseInit
Headers
const header: Headers
(arg
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence..headers)
(parameter) arg: ResponseInit
if (this.#headers) { // If the header is set by c.header() and arg.headers, c.header() will be prioritized. this.#headers.forEach(
(property) ResponseInit.headers?: ResponseHeadersInit | undefined
(v,
(method) Headers.forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void
k) => {
(parameter) v: string
if (k === 'set-cookie') {
(parameter) k: string
header
(parameter) k: string
.append
const header: Headers
(k,
(method) Headers.append(name: string, value: string): void
MDN Referencev)
(parameter) k: "set-cookie"
} else { header
(parameter) v: string
.set
const header: Headers
(k,
(method) Headers.set(name: string, value: string): void
MDN Referencev)
(parameter) k: string
} }) } const headers =
(parameter) v: string
setHeaders
const headers: Headers
const setHeaders: (headers: Headers, map?: Record<string, string>) => Headers
Sets the headers of a response.@param
headers
— The Headers object to set the headers on.@param
map
— A record of header key-value pairs to set.@returns — The updated Headers object.
(header, this.#preparedHeaders)return new Response
const header: Headers
(data, {
var Response: new (body?: BodyInit | null, init?: globalThis.ResponseInit) => Response
This Fetch API interface represents the response to a request.headers,
(parameter) data: Data | null
status:
(property) ResponseInit.headers?: HeadersInit | undefined
arg
(property) ResponseInit.status?: number | undefined
.status ?? this.#status,
(parameter) arg: ResponseInit
}) } const status = typeof
(property) ResponseInit.status?: number | undefined
arg === 'number' ?
const status: StatusCode
arg : this.#status
(parameter) arg: StatusCode | undefined
this.#preparedHeaders ??= {} this.#headers ??= new Headers()
(parameter) arg: StatusCode
setHeaders(this.#headers, this.#preparedHeaders)
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.
const setHeaders: (headers: Headers, map?: Record<string, string>) => Headers
Sets the headers of a response.@param
headers
— The Headers object to set the headers on.@param
map
— A record of header key-value pairs to set.@returns — The updated Headers object.
if (this.#res) { this.#res.headers.forEach(
(property) Response.headers: Headers
MDN Reference(v,
(method) Headers.forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void
k) => {
(parameter) v: string
if (k === 'set-cookie') {
(parameter) k: string
this.#headers?.append
(parameter) k: string
(k,
(method) Headers.append(name: string, value: string): void
MDN Referencev)
(parameter) k: "set-cookie"
} else { this.#headers?.set
(parameter) v: string
(k,
(method) Headers.set(name: string, value: string): void
MDN Referencev)
(parameter) k: string
} }) setHeaders(this.#headers, this.#preparedHeaders)
(parameter) v: string
const setHeaders: (headers: Headers, map?: Record<string, string>) => Headers
Sets the headers of a response.@param
headers
— The Headers object to set the headers on.@param
map
— A record of header key-value pairs to set.@returns — The updated Headers object.
} headers ??= {}for (const [k,
(parameter) headers: HeaderRecord | undefined
v] of
const k: string
Object
const v: string | string[]
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string | string[]>(o: { [s: string]: string | string[]; } | ArrayLike<string | string[]>): [string, string | string[]][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(headers)) {o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.if (typeof v === 'string') {
(parameter) headers: HeaderRecord
this.#headers.set
const v: string | string[]
(k,
(method) Headers.set(name: string, value: string): void
MDN Referencev)
const k: string
} else { this.#headers.delete
const v: string
(k)
(method) Headers.delete(name: string): void
MDN Referencefor (const v2 of
const k: string
v) {
const v2: string
this.#headers.append
const v: string[]
(k,
(method) Headers.append(name: string, value: string): void
MDN Referencev2)
const k: string
} } } return new Response
const v2: string
(data, {
var Response: new (body?: BodyInit | null, init?: globalThis.ResponseInit) => Response
This Fetch API interface represents the response to a request.status,
(parameter) data: Data | null
headers: this.#headers,
(property) ResponseInit.status?: number | undefined
}) } /** * `.body()` can return the HTTP response. * You can set headers with `.header()` and set HTTP status code with `.status`. * This can also be set in `.text()`, `.json()` and so on. * * @see {@link https://hono.dev/docs/api/context#body} * * @example * ```ts * app.get('/welcome', (c) => { * // Set headers * c.header('X-Message', 'Hello!') * c.header('Content-Type', 'text/plain') * // Set HTTP status code * c.status(201) * * // Return the response body * return c.body('Thank you for coming') * }) * ``` */ body:
(property) ResponseInit.headers?: HeadersInit | undefined
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.body: BodyRespond
.body()
can return the HTTP response. You can set headers with.header()
and set HTTP status code with.status
. This can also be set in.text()
,.json()
and so on.@see — https://hono.dev/docs/api/context#body
@example
```ts app.get('/welcome', (c) => { // Set headers c.header('X-Message', 'Hello!') c.header('Content-Type', 'text/plain') // Set HTTP status code c.status(201)// Return the response body return c.body('Thank you for coming') }) ```
BodyRespond = (data:
interface BodyRespond
Interface for responding with a body.Data | null,
(parameter) data: Data | null
arg?:
type Data = string | ArrayBuffer | ReadableStream<any>
Data type can be a string, ArrayBuffer, or ReadableStream.StatusCode |
(parameter) arg: StatusCode | ResponseInit | undefined
ResponseInit,
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.headers?:
interface ResponseInit
HeaderRecord
(parameter) headers: HeaderRecord | undefined
): Response => {
type HeaderRecord = Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]> | Record<string, string | string[]>
return typeof arg === 'number'
interface Response
This Fetch API interface represents the response to a request.? this.newResponse
(parameter) arg: StatusCode | ResponseInit | undefined
(data,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
arg,
(parameter) data: Data | null
headers)
(parameter) arg: StatusCode
: this.newResponse
(parameter) headers: HeaderRecord | undefined
(data,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, init?: ResponseInit) => Response (+1 overload)
arg)
(parameter) data: Data | null
} /** * `.text()` can render text as `Content-Type:text/plain`. * * @see {@link https://hono.dev/docs/api/context#text} * * @example * ```ts * app.get('/say', (c) => { * return c.text('Hello!') * }) * ``` */ text:
(parameter) arg: ResponseInit | undefined
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond
.text()
can render text asContent-Type:text/plain
.@see — https://hono.dev/docs/api/context#text
@example
TextRespond = (
ts app.get('/say', (c) => { return c.text('Hello!') })
interface TextRespond
Interface for responding with text.@interface — TextRespond
@template
T
— The type of the text content.@template
U
— The type of the status code.@param
text
— The text content to be included in the response.@param
status
— An optional status code for the response.@param
headers
— An optional record of headers to include in the response.@returns — - The response after rendering the text content, typed with the provided text and status code types.
text: string,arg?:
(parameter) text: string
StatusCode |
(parameter) arg: StatusCode | ResponseInit | undefined
ResponseInit,
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.headers?:
interface ResponseInit
HeaderRecord
(parameter) headers: HeaderRecord | undefined
): ReturnType
type HeaderRecord = Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]> | Record<string, string | string[]>
<TextRespond> => {
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any
Obtain the return type of a function type
interface TextRespond
Interface for responding with text.@interface — TextRespond
@template
T
— The type of the text content.@template
U
— The type of the status code.@param
text
— The text content to be included in the response.@param
status
— An optional status code for the response.@param
headers
— An optional record of headers to include in the response.@returns — - The response after rendering the text content, typed with the provided text and status code types.
// If the header is empty, return Response immediately. // Content-Type will be added automatically as `text/plain`. if (!this.#preparedHeaders) { if (this.#isFresh && !headers &&!arg) {
(parameter) headers: HeaderRecord | undefined
// @ts-expect-error `Response` due to missing some types-only keys return new Response
(parameter) arg: StatusCode | ResponseInit | undefined
(text)
var Response: new (body?: BodyInit | null, init?: globalThis.ResponseInit) => Response
This Fetch API interface represents the response to a request.} this.#preparedHeaders = {} } this.#preparedHeaders['content-type'] = TEXT_PLAIN
(parameter) text: string
// @ts-expect-error `Response` due to missing some types-only keys return typeof arg === 'number'
const TEXT_PLAIN: "text/plain; charset=UTF-8"
? this.newResponse
(parameter) arg: StatusCode | ResponseInit | undefined
(text,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
arg,
(parameter) text: string
headers)
(parameter) arg: StatusCode
: this.newResponse
(parameter) headers: HeaderRecord | undefined
(text,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, init?: ResponseInit) => Response (+1 overload)
arg)
(parameter) text: string
} /** * `.json()` can render JSON as `Content-Type:application/json`. * * @see {@link https://hono.dev/docs/api/context#json} * * @example * ```ts * app.get('/api', (c) => { * return c.json({ message: 'Hello!' }) * }) * ``` */ json:
(parameter) arg: ResponseInit | undefined
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond
.json()
can render JSON asContent-Type:application/json
.@see — https://hono.dev/docs/api/context#json
@example
JSONRespond = <
ts app.get('/api', (c) => { return c.json({ message: 'Hello!' }) })
interface JSONRespond
Interface for responding with JSON.@interface — JSONRespond
@template
T
— The type of the JSON value or simplified unknown type.@template
U
— The type of the status code.@param
object
— The JSON object to be included in the response.@param
status
— An optional status code for the response.@param
headers
— An optional record of headers to include in the response.@returns — - The response after rendering the JSON object, typed with the provided object and status code types.
T extendsJSONValue |
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, arg?: U | ResponseInit, headers?: HeaderRecord): JSONRespondReturn<T, U>
SimplifyDeepArray
(alias) type JSONValue = JSONObject | JSONArray | JSONPrimitive import JSONValue
| InvalidJSONValue,
(alias) type SimplifyDeepArray<T> = T extends any[] ? { [E in keyof T]: SimplifyDeepArray<T[E]>; } : { [KeyType in keyof T]: T[KeyType]; } import SimplifyDeepArray
A simple extension of Simplify that will deeply traverse array elements.U extends
(alias) type InvalidJSONValue = symbol | ((...args: unknown[]) => unknown) | undefined import InvalidJSONValue
StatusCode =
(type parameter) U in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, arg?: U | ResponseInit, headers?: HeaderRecord): JSONRespondReturn<T, U>
StatusCode
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.>( object:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.T,
(parameter) object: T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue
arg?:
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, arg?: U | ResponseInit, headers?: HeaderRecord): JSONRespondReturn<T, U>
U |
(parameter) arg: ResponseInit | U | undefined
ResponseInit,
(type parameter) U in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, arg?: U | ResponseInit, headers?: HeaderRecord): JSONRespondReturn<T, U>
headers?:
interface ResponseInit
HeaderRecord
(parameter) headers: HeaderRecord | undefined
): JSONRespondReturn
type HeaderRecord = Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]> | Record<string, string | string[]>
type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode> = Response & TypedResponse<SimplifyDeepArray<T> extends JSONValue ? JSONValue extends SimplifyDeepArray<T> ? never : JSONParsed<...> : never, U, "json">
@template
T
— The type of the JSON value or simplified unknown type.@template
U
— The type of the status code.@returns — - The response after rendering the JSON object, typed with the provided object and status code types.
<T,U> => {
(type parameter) T in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, arg?: U | ResponseInit, headers?: HeaderRecord): JSONRespondReturn<T, U>
const body =
(type parameter) U in <T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode = StatusCode>(object: T, arg?: U | ResponseInit, headers?: HeaderRecord): JSONRespondReturn<T, U>
JSON
const body: string
.stringify
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
(object)space
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.this.#preparedHeaders ??= {} this.#preparedHeaders['content-type'] = 'application/json; charset=UTF-8' /* eslint-disable @typescript-eslint/no-explicit-any */ return ( typeof arg === 'number' ? this
(parameter) object: JSONValue | {} | InvalidJSONValue
.newResponse
(parameter) arg: ResponseInit | U | undefined
(body,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
arg,
const body: string
headers) : this
(parameter) arg: StatusCode
.newResponse
(parameter) headers: HeaderRecord | undefined
(body,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, init?: ResponseInit) => Response (+1 overload)
arg)
const body: string
) as any } html:
(parameter) arg: ResponseInit | undefined
HTMLRespond = (
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.html: HTMLRespond
interface HTMLRespond
Interface representing a function that responds with HTML content.@param
html
— The HTML content to respond with, which can be a string or a Promise that resolves to a string.@param
status
— (Optional) The HTTP status code for the response.@param
headers
— (Optional) A record of headers to include in the response.@param
init
— (Optional) The response initialization object.@returns — A Response object or a Promise that resolves to a Response object.
html: string |Promise
(parameter) html: string | Promise<string>
, arg?:
interface Promise<T>
Represents the completion of an asynchronous operationStatusCode |
(parameter) arg: StatusCode | ResponseInit | undefined
ResponseInit,
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.headers?:
interface ResponseInit
HeaderRecord
(parameter) headers: HeaderRecord | undefined
): Response |
type HeaderRecord = Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]> | Record<string, string | string[]>
Promise
interface Response
This Fetch API interface represents the response to a request.<Response> => {
interface Promise<T>
Represents the completion of an asynchronous operationthis.#preparedHeaders ??= {} this.#preparedHeaders['content-type'] = 'text/html; charset=UTF-8' if (typeof html === 'object') {
interface Response
This Fetch API interface represents the response to a request.return resolveCallback
(parameter) html: string | Promise<string>
(html,
(alias) resolveCallback(str: string | HtmlEscapedString | Promise<string>, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [string]): Promise<string> import resolveCallback
HtmlEscapedCallbackPhase
(parameter) html: Promise<string>
(alias) const HtmlEscapedCallbackPhase: { readonly Stringify: 1; readonly BeforeStream: 2; readonly Stream: 3; } import HtmlEscapedCallbackPhase
@module — HTML utility.
.Stringify, false, {}).then(
(property) Stringify: 1
(method) Promise<string>.then<Response, Response>(onfulfilled?: ((value: string) => Response | PromiseLike<Response>) | null | undefined, onrejected?: ((reason: any) => Response | PromiseLike<...>) | null | undefined): Promise<...>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(html) => {return typeof arg === 'number'
(parameter) html: string
? this.newResponse
(parameter) arg: StatusCode | ResponseInit | undefined
(html,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
arg,
(parameter) html: string
headers)
(parameter) arg: StatusCode
: this.newResponse
(parameter) headers: HeaderRecord | undefined
(html,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, init?: ResponseInit) => Response (+1 overload)
arg)
(parameter) html: string
}) } return typeof arg === 'number'
(parameter) arg: ResponseInit | undefined
? this.newResponse
(parameter) arg: StatusCode | ResponseInit | undefined
(html as string,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
arg,
(parameter) html: string
headers)
(parameter) arg: StatusCode
: this.newResponse
(parameter) headers: HeaderRecord | undefined
(html as string,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, init?: ResponseInit) => Response (+1 overload)
arg)
(parameter) html: string
} /** * `.redirect()` can Redirect, default status code is 302. * * @see {@link https://hono.dev/docs/api/context#redirect} * * @example * ```ts * app.get('/redirect', (c) => { * return c.redirect('/') * }) * app.get('/redirect-permanently', (c) => { * return c.redirect('/', 301) * }) * ``` */ redirect =
(parameter) arg: ResponseInit | undefined
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.redirect: <T extends RedirectStatusCode = 302>(location: string, status?: T) => Response & TypedResponse<undefined, T, "redirect">
.redirect()
can Redirect, default status code is 302.@see — https://hono.dev/docs/api/context#redirect
@example
<T extends
ts app.get('/redirect', (c) => { return c.redirect('/') }) app.get('/redirect-permanently', (c) => { return c.redirect('/', 301) })
RedirectStatusCode = 302>(
(type parameter) T in <T extends RedirectStatusCode = 302>(location: string, status?: T): Response & TypedResponse<undefined, T, "redirect">
location: string,
(alias) type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308 import RedirectStatusCode
status?:
(parameter) location: string
T
(parameter) status: T | undefined
): Response &
(type parameter) T in <T extends RedirectStatusCode = 302>(location: string, status?: T): Response & TypedResponse<undefined, T, "redirect">
TypedResponse
interface Response
This Fetch API interface represents the response to a request.T, 'redirect'> => {
(alias) type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : string> = { _data: T; _status: U; _format: F; } import TypedResponse
this.#headers ??= new Headers()
(type parameter) T in <T extends RedirectStatusCode = 302>(location: string, status?: T): Response & TypedResponse<undefined, T, "redirect">
this.#headers.set('Location',
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.location)
(method) Headers.set(name: string, value: string): void
MDN Referencereturn this.newResponse(null,
(parameter) location: string
status ?? 302) as any
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
} /** * `.notFound()` can return the Not Found Response. * * @see {@link https://hono.dev/docs/api/context#notfound} * * @example * ```ts * app.get('/notfound', (c) => { * return c.notFound() * }) * ``` */ notFound = ():
(parameter) status: RedirectStatusCode | undefined
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
Response |
ts app.get('/notfound', (c) => { return c.notFound() })
Promise
interface Response
This Fetch API interface represents the response to a request.<Response> => {
interface Promise<T>
Represents the completion of an asynchronous operationthis.#notFoundHandler ??= () => new Response()
interface Response
This Fetch API interface represents the response to a request.return this.#notFoundHandler(this) } }
var Response: new (body?: BodyInit | null, init?: globalThis.ResponseInit) => Response
This Fetch API interface represents the response to a request.
import { Hono } from '../..' import type { Accept, acceptsConfig, acceptsOptions } from './accepts' import { accepts, defaultMatch, parseAccept } from './accepts' describe('parseAccept', () => { test('should parse accept header', () => { const acceptHeader ='text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8;level=1;foo=bar' const accepts =
const acceptHeader: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8;level=1;foo=bar"
parseAccept
const accepts: Accept[]
(acceptHeader)
(alias) parseAccept(acceptHeader: string): Accept[] import parseAccept
expect(accepts).toEqual([
const acceptHeader: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8;level=1;foo=bar"
{ type: 'text/html',
const accepts: Accept[]
params: {},
(property) type: string
q: 1 },
(property) params: {}
{ type: 'application/xhtml+xml',
(property) q: number
params: {},
(property) type: string
q: 1 },
(property) params: {}
{ type: 'application/xml',
(property) q: number
params: {
(property) type: string
q: '0.9' },
(property) params: { q: string; }
q: 0.9 },
(property) q: string
{ type: 'image/webp',
(property) q: number
params: {},
(property) type: string
q: 1 },
(property) params: {}
{ type: '*/*',
(property) q: number
params: {
(property) type: string
q: '0.8',
(property) params: { q: string; level: string; foo: string; }
level: '1',
(property) q: string
foo: 'bar' },
(property) level: string
q: 0.8 },
(property) foo: string
]) }) }) describe('defaultMatch', () => { test('should return default support', () => { const accepts:
(property) q: number
Accept[] = [
const accepts: Accept[]
{ type: 'text/html',
(alias) interface Accept import Accept
params: {},
(property) Accept.type: string
q: 1 },
(property) Accept.params: Record<string, string>
{ type: 'application/xhtml+xml',
(property) Accept.q: number
params: {},
(property) Accept.type: string
q: 1 },
(property) Accept.params: Record<string, string>
{ type: 'application/xml',
(property) Accept.q: number
params: {
(property) Accept.type: string
q: '0.9' },
(property) Accept.params: Record<string, string>
q: 0.9 },
(property) q: string
{ type: 'image/webp',
(property) Accept.q: number
params: {},
(property) Accept.type: string
q: 1 },
(property) Accept.params: Record<string, string>
{ type: '*/*',
(property) Accept.q: number
params: {
(property) Accept.type: string
q: '0.8' },
(property) Accept.params: Record<string, string>
q: 0.8 },
(property) q: string
] const config:
(property) Accept.q: number
acceptsConfig = {
const config: acceptsConfig
header: 'Accept',
(alias) interface acceptsConfig import acceptsConfig
supports: ['text/html'],
(property) acceptsConfig.header: AcceptHeader
default: 'text/html',
(property) acceptsConfig.supports: string[]
} const result =
(property) acceptsConfig.default: string
defaultMatch
const result: string
(accepts,
(alias) defaultMatch(accepts: Accept[], config: acceptsConfig): string import defaultMatch
config)
const accepts: Accept[]
expect(result).toBe('text/html')
const config: acceptsConfig
}) }) describe('accepts', () => { test('should return matched support', () => { const c = {
const result: string
req: {
const c: any
header: () => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
(property) req: { header: () => string; }
}, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any const options:
(property) header: () => string
acceptsConfig = {
const options: acceptsConfig
header: 'Accept',
(alias) interface acceptsConfig import acceptsConfig
supports: ['application/xml', 'text/html'],
(property) acceptsConfig.header: AcceptHeader
default: 'application/json',
(property) acceptsConfig.supports: string[]
} const result =
(property) acceptsConfig.default: string
accepts
const result: string
(alias) accepts(c: Context, options: acceptsOptions): string import accepts
Match the accept header with the given options.@example
(c,
ts app.get('/users', (c) => { const lang = accepts(c, { header: 'Accept-Language', supports: ['en', 'zh'], default: 'en', }) })
options)
const c: any
expect(result).toBe('text/html')
const options: acceptsConfig
}) test('should return default support if no matched support', () => { const c = {
const result: string
req: {
const c: any
header: () => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
(property) req: { header: () => string; }
}, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any const options:
(property) header: () => string
acceptsConfig = {
const options: acceptsConfig
header: 'Accept',
(alias) interface acceptsConfig import acceptsConfig
supports: ['application/json'],
(property) acceptsConfig.header: AcceptHeader
default: 'text/html',
(property) acceptsConfig.supports: string[]
} const result =
(property) acceptsConfig.default: string
accepts
const result: string
(alias) accepts(c: Context, options: acceptsOptions): string import accepts
Match the accept header with the given options.@example
(c,
ts app.get('/users', (c) => { const lang = accepts(c, { header: 'Accept-Language', supports: ['en', 'zh'], default: 'en', }) })
options)
const c: any
expect(result).toBe('text/html')
const options: acceptsConfig
}) test('should return default support if no accept header', () => { const c = {
const result: string
req: {
const c: any
header: () => undefined,
(property) req: { header: () => undefined; }
}, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any const options:
(property) header: () => undefined
acceptsConfig = {
const options: acceptsConfig
header: 'Accept',
(alias) interface acceptsConfig import acceptsConfig
supports: ['application/json'],
(property) acceptsConfig.header: AcceptHeader
default: 'text/html',
(property) acceptsConfig.supports: string[]
} const result =
(property) acceptsConfig.default: string
accepts
const result: string
(alias) accepts(c: Context, options: acceptsOptions): string import accepts
Match the accept header with the given options.@example
(c,
ts app.get('/users', (c) => { const lang = accepts(c, { header: 'Accept-Language', supports: ['en', 'zh'], default: 'en', }) })
options)
const c: any
expect(result).toBe('text/html')
const options: acceptsConfig
}) test('should return matched support with custom match function', () => { const c = {
const result: string
req: {
const c: any
header: () => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
(property) req: { header: () => string; }
}, // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any // this match function will return the least q value const match =
(property) header: () => string
(accepts:
const match: (accepts: Accept[], config: acceptsConfig) => string
Accept[],
(parameter) accepts: Accept[]
config:
(alias) interface Accept import Accept
acceptsConfig) => {
(parameter) config: acceptsConfig
const { supports,
(alias) interface acceptsConfig import acceptsConfig
default:
const supports: string[]
defaultSupport } =
(property) acceptsConfig.default: string
config
const defaultSupport: string
const accept =
(parameter) config: acceptsConfig
accepts
const accept: Accept | undefined
.sort(
(parameter) accepts: Accept[]
(method) Array<Accept>.sort(compareFn?: ((a: Accept, b: Accept) => number) | undefined): Accept[]
Sorts an array in place. This method mutates the array and returns a reference to the same array.@param
(a,compareFn
Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.ts [11,2,22,1].sort((a, b) => a - b)
b) =>
(parameter) a: Accept
a
(parameter) b: Accept
.q -
(parameter) a: Accept
b
(property) Accept.q: number
.q)
(parameter) b: Accept
.find(
(property) Accept.q: number
(method) Array<Accept>.find(predicate: (value: Accept, index: number, obj: Accept[]) => unknown, thisArg?: any): Accept | undefined (+1 overload)
Returns the value of the first element in the array where predicate is true, and undefined otherwise.@param
predicate
find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.@param
(accept) =>thisArg
If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.supports
(parameter) accept: Accept
.includes
const supports: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
(acceptfromIndex
— The position in this array at which to begin searching for searchElement..type))
(parameter) accept: Accept
return accept ?
(property) Accept.type: string
accept
const accept: Accept | undefined
.type :
const accept: Accept
defaultSupport
(property) Accept.type: string
} const options:
const defaultSupport: string
acceptsOptions = {
const options: acceptsOptions
header: 'Accept',
(alias) interface acceptsOptions import acceptsOptions
supports: ['application/xml', 'text/html'],
(property) acceptsConfig.header: AcceptHeader
default: 'application/json',
(property) acceptsConfig.supports: string[]
match,
(property) acceptsConfig.default: string
} const result =
(property) acceptsOptions.match?: ((accepts: Accept[], config: acceptsConfig) => string) | undefined
accepts
const result: string
(alias) accepts(c: Context, options: acceptsOptions): string import accepts
Match the accept header with the given options.@example
(c,
ts app.get('/users', (c) => { const lang = accepts(c, { header: 'Accept-Language', supports: ['en', 'zh'], default: 'en', }) })
options)
const c: any
expect(result).toBe('application/xml')
const options: acceptsOptions
}) }) describe('Usage', () => { test('decide compression by Accept-Encoding header', async () => { const app = new
const result: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/compressed', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/compressed", "/compressed", HandlerResponse<any>, BlankInput, BlankEnv>(path: "/compressed", handler: H<BlankEnv, "/compressed", BlankInput, HandlerResponse<...>>) => Hono<...> (+22 overloads)
const encoding =
(parameter) c: Context<BlankEnv, "/compressed", BlankInput>
accepts
const encoding: string
(alias) accepts(c: Context, options: acceptsOptions): string import accepts
Match the accept header with the given options.@example
(c, {
ts app.get('/users', (c) => { const lang = accepts(c, { header: 'Accept-Language', supports: ['en', 'zh'], default: 'en', }) })
header: 'Accept-Encoding',
(parameter) c: Context<BlankEnv, "/compressed", BlankInput>
supports: ['gzip', 'deflate'],
(property) acceptsConfig.header: AcceptHeader
default: 'identity',
(property) acceptsConfig.supports: string[]
}) const COMPRESS_DATA = 'COMPRESS_DATA'
(property) acceptsConfig.default: string
const readable = new
const COMPRESS_DATA: "COMPRESS_DATA"
ReadableStream({
const readable: ReadableStream<any>
start
var ReadableStream: new <any>(underlyingSource: UnderlyingDefaultSource<any>, strategy?: QueuingStrategy<any> | undefined) => ReadableStream<any> (+2 overloads)
(controller) {
(property) UnderlyingDefaultSource<any>.start?: ((controller: ReadableStreamDefaultController<any>) => any) | undefined
controller
(parameter) controller: ReadableStreamDefaultController<any>
.enqueue(new
(parameter) controller: ReadableStreamDefaultController<any>
TextEncoder()
(method) ReadableStreamDefaultController<any>.enqueue(chunk?: any): void
MDN Reference.encode
var TextEncoder: new () => TextEncoder
TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays.(COMPRESS_DATA))
(method) TextEncoder.encode(input?: string): Uint8Array
Returns the result of running UTF-8's encoder.controller
const COMPRESS_DATA: "COMPRESS_DATA"
.close()
(parameter) controller: ReadableStreamDefaultController<any>
}, }) if (encoding === 'gzip') {
(method) ReadableStreamDefaultController<any>.close(): void
MDN Referencec
const encoding: string
.header('Content-Encoding', 'gzip')
(parameter) c: Context<BlankEnv, "/compressed", BlankInput>
return c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.body
(parameter) c: Context<BlankEnv, "/compressed", BlankInput>
(readable
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.pipeThrough(new
const readable: ReadableStream<any>
CompressionStream('gzip')))
(method) ReadableStream<any>.pipeThrough<any>(transform: ReadableWritablePair<any, any>, options?: StreamPipeOptions): ReadableStream<any>
MDN Reference} if (encoding === 'deflate') {
var CompressionStream: new (format: CompressionFormat) => CompressionStream
MDN Referencec
const encoding: string
.header('Content-Encoding', 'deflate')
(parameter) c: Context<BlankEnv, "/compressed", BlankInput>
return c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.body
(parameter) c: Context<BlankEnv, "/compressed", BlankInput>
(readable
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.pipeThrough(new
const readable: ReadableStream<any>
CompressionStream('deflate')))
(method) ReadableStream<any>.pipeThrough<any>(transform: ReadableWritablePair<any, any>, options?: StreamPipeOptions): ReadableStream<any>
MDN Reference} c
var CompressionStream: new (format: CompressionFormat) => CompressionStream
MDN Reference.body
(parameter) c: Context<BlankEnv, "/compressed", BlankInput>
(COMPRESS_DATA)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
}) const req1 = await
const COMPRESS_DATA: "COMPRESS_DATA"
app
const req1: Response
.request('/compressed', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: { 'Accept-Encoding': 'deflate' } })const req2 = await
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.app
const req2: Response
.request('/compressed', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: { 'Accept-Encoding': 'gzip' } })const req3 = await
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.app
const req3: Response
.request('/compressed', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: { 'Accept-Encoding': 'gzip;q=0.5,deflate' },}) const req4 = await
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.app
const req4: Response
.request('/compressed', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: { 'Accept-Encoding': 'br' } })expect(req1
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers..headers
const req1: Response
.get('Content-Encoding')).toBe('deflate')
(property) Response.headers: Headers
MDN Referenceexpect(req2
(method) Headers.get(name: string): string | null
MDN Reference.headers
const req2: Response
.get('Content-Encoding')).toBe('gzip')
(property) Response.headers: Headers
MDN Referenceexpect(req3
(method) Headers.get(name: string): string | null
MDN Reference.headers
const req3: Response
.get('Content-Encoding')).toBe('deflate')
(property) Response.headers: Headers
MDN Referenceexpect(req4
(method) Headers.get(name: string): string | null
MDN Reference.headers
const req4: Response
.get('Content-Encoding')).toBeNull()
(property) Response.headers: Headers
MDN Reference}) test('decide language by Accept-Language header', async () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const SUPPORTED_LANGS = ['en', 'ja', 'zh']options
— Optional configuration options for the Hono instance.app
const SUPPORTED_LANGS: string[]
.get('/*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/*", "/*", Promise<Response>, BlankInput, BlankEnv>(path: "/*", handler: H<BlankEnv, "/*", BlankInput, Promise<Response>>) => Hono<...> (+22 overloads)
const lang =
(parameter) c: Context<BlankEnv, "/*", BlankInput>
accepts
const lang: string
(alias) accepts(c: Context, options: acceptsOptions): string import accepts
Match the accept header with the given options.@example
(c, {
ts app.get('/users', (c) => { const lang = accepts(c, { header: 'Accept-Language', supports: ['en', 'zh'], default: 'en', }) })
header: 'Accept-Language',
(parameter) c: Context<BlankEnv, "/*", BlankInput>
supports:
(property) acceptsConfig.header: AcceptHeader
SUPPORTED_LANGS,
(property) acceptsConfig.supports: string[]
default: 'en',
const SUPPORTED_LANGS: string[]
}) const isLangedPath =
(property) acceptsConfig.default: string
SUPPORTED_LANGS
const isLangedPath: boolean
.some(
const SUPPORTED_LANGS: string[]
(method) Array<string>.some(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean
Determines whether the specified callback function returns true for any element of an array.@param
predicate
A function that accepts up to three arguments. The some method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value true, or until the end of the array.@param
(l) =>thisArg
An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.c
(parameter) l: string
.req
(parameter) c: Context<BlankEnv, "/*", BlankInput>
.path
(property) Context<BlankEnv, "/*", BlankInput>.req: HonoRequest<"/*", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.path: string
.path
can get the pathname of the request.@see — https://hono.dev/docs/api/request#path
@example
.startsWith(`/$
ts app.get('/about/me', (c) => { const pathname = c.req.path // `/about/me` })
{l}`))
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.if (isLangedPath) {
(parameter) l: string
return c
const isLangedPath: boolean
.body(`lang: $
(parameter) c: Context<BlankEnv, "/*", BlankInput>
{lang}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
} return c
const lang: string
.redirect(`/$
(parameter) c: Context<BlankEnv, "/*", BlankInput>
(property) Context<BlankEnv, "/*", BlankInput>.redirect: <302>(location: string, status?: 302 | undefined) => Response & TypedResponse<undefined, 302, "redirect">
.redirect()
can Redirect, default status code is 302.@see — https://hono.dev/docs/api/context#redirect
@example
{lang}$
ts app.get('/redirect', (c) => { return c.redirect('/') }) app.get('/redirect-permanently', (c) => { return c.redirect('/', 301) })
{c
const lang: string
.req
(parameter) c: Context<BlankEnv, "/*", BlankInput>
.path}`)
(property) Context<BlankEnv, "/*", BlankInput>.req: HonoRequest<"/*", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.path: string
.path
can get the pathname of the request.@see — https://hono.dev/docs/api/request#path
@example
}) const req1 = await
ts app.get('/about/me', (c) => { const pathname = c.req.path // `/about/me` })
app
const req1: Response
.request('/foo', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: { 'Accept-Language': 'en=0.8,ja' } })const req2 = await
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.app
const req2: Response
.request('/en/foo', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: { 'Accept-Language': 'en' } })expect(req1
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers..status).toBe(302)
const req1: Response
expect(req1
(property) Response.status: number
MDN Reference.headers
const req1: Response
.get('Location')).toBe('/ja/foo')
(property) Response.headers: Headers
MDN Referenceexpect(await req2
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('lang: en')
const req2: Response
}) })
(method) Body.text(): Promise<string>
MDN Reference
import type { Context } from '../../context' export type AcceptHeader =| 'Accept' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Accept-Patch' | 'Accept-Post' | 'Accept-Ranges' export interface Accept {
type AcceptHeader = "Accept" | "Accept-Charset" | "Accept-Encoding" | "Accept-Language" | "Accept-Patch" | "Accept-Post" | "Accept-Ranges"
type: string
interface Accept
params:
(property) Accept.type: string
Record
(property) Accept.params: Record<string, string>
q: number
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T} export interface acceptsConfig {
(property) Accept.q: number
header:
interface acceptsConfig
AcceptHeader
(property) acceptsConfig.header: AcceptHeader
supports: string[]
type AcceptHeader = "Accept" | "Accept-Charset" | "Accept-Encoding" | "Accept-Language" | "Accept-Patch" | "Accept-Post" | "Accept-Ranges"
default: string
(property) acceptsConfig.supports: string[]
} export interface acceptsOptions extends
(property) acceptsConfig.default: string
acceptsConfig {
interface acceptsOptions
match?:
interface acceptsConfig
(accepts:
(property) acceptsOptions.match?: ((accepts: Accept[], config: acceptsConfig) => string) | undefined
Accept[],
(parameter) accepts: Accept[]
config:
interface Accept
acceptsConfig) => string
(parameter) config: acceptsConfig
} export const parseAccept =
interface acceptsConfig
(acceptHeader: string):
const parseAccept: (acceptHeader: string) => Accept[]
Accept[] => {
(parameter) acceptHeader: string
// Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 const accepts =
interface Accept
acceptHeader
const accepts: string[]
.split(',') // ['text/html', 'application/xhtml+xml', 'application/xml;q=0.9', 'image/webp', '*/*;q=0.8']
(parameter) acceptHeader: string
(method) String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
separator
— A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.@param
return acceptslimit
— A value used to limit the number of elements returned in the array..map(
const accepts: string[]
(method) Array<string>.map<{ type: string; params: { [key: string]: string; }; q: number; }>(callbackfn: (value: string, index: number, array: string[]) => { type: string; params: { [key: string]: string; }; q: number; }, thisArg?: any): { type: string; params: { [key: string]: string; }; q: number; }[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(accept) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.const parts =
(parameter) accept: string
accept
const parts: string[]
.trim()
(parameter) accept: string
.split(';') // ['text/html', 'q=0.9', 'image/webp']
(method) String.trim(): string
Removes the leading and trailing white space and line terminator characters from a string.
(method) String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
separator
— A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.@param
const type =limit
— A value used to limit the number of elements returned in the array.parts[0] // text/html
const type: string
const params =
const parts: string[]
parts
const params: string[]
.slice(1) // ['q=0.9', 'image/webp']
const parts: string[]
(method) Array<string>.slice(start?: number, end?: number): string[]
Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.@param
start
The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.@param
const q =end
The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array.params
const q: string | undefined
.find(
const params: string[]
(method) Array<string>.find(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): string | undefined (+1 overload)
Returns the value of the first element in the array where predicate is true, and undefined otherwise.@param
predicate
find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.@param
(param) =>thisArg
If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.param
(parameter) param: string
.startsWith('q='))
(parameter) param: string
const paramsObject =
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.params
const paramsObject: { [key: string]: string; }
.reduce(
const params: string[]
(method) Array<string>.reduce<{ [key: string]: string; }>(callbackfn: (previousValue: { [key: string]: string; }, currentValue: string, currentIndex: number, array: string[]) => { [key: string]: string; }, initialValue: { [key: string]: string; }): { [key: string]: string; } (+2 overloads)
Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.@param
callbackfn
— A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.@param
(acc,initialValue
— If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.param) => {
(parameter) acc: { [key: string]: string; }
const keyValue =
(parameter) param: string
param
const keyValue: string[]
.split('=')
(parameter) param: string
(method) String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
separator
— A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.@param
const key =limit
— A value used to limit the number of elements returned in the array.keyValue[0]
const key: string
.trim()
const keyValue: string[]
const value =
(method) String.trim(): string
Removes the leading and trailing white space and line terminator characters from a string.keyValue[1]
const value: string
.trim()
const keyValue: string[]
acc
(method) String.trim(): string
Removes the leading and trailing white space and line terminator characters from a string.[key] =
(parameter) acc: { [key: string]: string; }
value
const key: string
return acc
const value: string
}, {} as { [key: string]: string })
(parameter) acc: { [key: string]: string; }
return { type:
(parameter) key: string
type,
(property) type: string
params:
const type: string
paramsObject,
(property) params: { [key: string]: string; }
q:
const paramsObject: { [key: string]: string; }
q ?
(property) q: number
parseFloat
const q: string | undefined
function parseFloat(string: string): number
Converts a string to a floating-point number.@param
(qstring
— A string that contains a floating-point number..split('=')[1]) : 1,
const q: string
(method) String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
separator
— A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.@param
} }) } export const defaultMatch =limit
— A value used to limit the number of elements returned in the array.(accepts:
const defaultMatch: (accepts: Accept[], config: acceptsConfig) => string
Accept[],
(parameter) accepts: Accept[]
config:
interface Accept
acceptsConfig): string => {
(parameter) config: acceptsConfig
const { supports,
interface acceptsConfig
default:
const supports: string[]
defaultSupport } =
(property) acceptsConfig.default: string
config
const defaultSupport: string
const accept =
(parameter) config: acceptsConfig
accepts
const accept: Accept | undefined
.sort(
(parameter) accepts: Accept[]
(method) Array<Accept>.sort(compareFn?: ((a: Accept, b: Accept) => number) | undefined): Accept[]
Sorts an array in place. This method mutates the array and returns a reference to the same array.@param
(a,compareFn
Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.ts [11,2,22,1].sort((a, b) => a - b)
b) =>
(parameter) a: Accept
b
(parameter) b: Accept
.q -
(parameter) b: Accept
a
(property) Accept.q: number
.q)
(parameter) a: Accept
.find(
(property) Accept.q: number
(method) Array<Accept>.find(predicate: (value: Accept, index: number, obj: Accept[]) => unknown, thisArg?: any): Accept | undefined (+1 overload)
Returns the value of the first element in the array where predicate is true, and undefined otherwise.@param
predicate
find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.@param
(accept) =>thisArg
If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.supports
(parameter) accept: Accept
.includes
const supports: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
(acceptfromIndex
— The position in this array at which to begin searching for searchElement..type))
(parameter) accept: Accept
return accept ?
(property) Accept.type: string
accept
const accept: Accept | undefined
.type :
const accept: Accept
defaultSupport
(property) Accept.type: string
} /** * Match the accept header with the given options. * @example * ```ts * app.get('/users', (c) => { * const lang = accepts(c, { * header: 'Accept-Language', * supports: ['en', 'zh'], * default: 'en', * }) * }) * ``` */ export const accepts =
const defaultSupport: string
const accepts: (c: Context, options: acceptsOptions) => string
Match the accept header with the given options.@example
(c:
ts app.get('/users', (c) => { const lang = accepts(c, { header: 'Accept-Language', supports: ['en', 'zh'], default: 'en', }) })
Context,
(parameter) c: Context<any, any, {}>
options:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
acceptsOptions): string => {
(parameter) options: acceptsOptions
const acceptHeader =
interface acceptsOptions
c
const acceptHeader: string | undefined
.req
(parameter) c: Context<any, any, {}>
.header
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
(options
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
.header)
(parameter) options: acceptsOptions
if (!acceptHeader) {
(property) acceptsConfig.header: AcceptHeader
return options
const acceptHeader: string | undefined
.default
(parameter) options: acceptsOptions
} const accepts =
(property) acceptsConfig.default: string
parseAccept
const accepts: Accept[]
(acceptHeader)
const parseAccept: (acceptHeader: string) => Accept[]
const match =
const acceptHeader: string
options
const match: (accepts: Accept[], config: acceptsConfig) => string
.match ||
(parameter) options: acceptsOptions
defaultMatch
(property) acceptsOptions.match?: ((accepts: Accept[], config: acceptsConfig) => string) | undefined
return match
const defaultMatch: (accepts: Accept[], config: acceptsConfig) => string
(accepts,
const match: (accepts: Accept[], config: acceptsConfig) => string
options)
const accepts: Accept[]
}
(parameter) options: acceptsOptions
/** * @module * Accepts Helper for Hono. */ export { accepts } from './accepts'
(alias) const accepts: (c: Context, options: acceptsOptions) => string export accepts
Match the accept header with the given options.@example
ts app.get('/users', (c) => { const lang = accepts(c, { header: 'Accept-Language', supports: ['en', 'zh'], default: 'en', }) })
import { getRuntimeKey } from '.' describe('getRuntimeKey', () => { it('Should return the current runtime key', () => { // Now, using the `bun run test` command. // But `vitest` depending Node.js will run this test so the RuntimeKey will be `node`. expect(getRuntimeKey()).toBe('node')}) })
(alias) getRuntimeKey(): Runtime import getRuntimeKey
/** * @module * Adapter Helper for Hono. */ import type { Context } from '../../context' export type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'other'export const env =
type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other"
<T extends
const env: <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime) => T & C["env"]
Record
(type parameter) T in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
, C extends
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TContext =
(type parameter) C in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
Context<{}>>(
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
c:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
C,
(parameter) c: C extends Context = Context<{}, any, {}>
runtime?:
(type parameter) C in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
Runtime
(parameter) runtime: Runtime | undefined
): T &
type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other"
C['env'] => {
(type parameter) T in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
// eslint-disable-next-line @typescript-eslint/no-explicit-any const global = globalThis as any
(type parameter) C in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
const globalEnv =
const global: any
global?.process?.env as
const globalEnv: T extends Record<string, unknown>
T
const global: any
runtime ??=
(type parameter) T in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
getRuntimeKey()
(parameter) runtime: Runtime | undefined
const runtimeEnvHandlers:
const getRuntimeKey: () => Runtime
Record
const runtimeEnvHandlers: Record<string, () => T>
T> = {
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tbun: () =>
(type parameter) T in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
globalEnv,
(property) bun: () => T
node: () =>
const globalEnv: T extends Record<string, unknown>
globalEnv,
(property) node: () => T
'edge-light': () => globalEnv,
const globalEnv: T extends Record<string, unknown>
deno: () => {
const globalEnv: T extends Record<string, unknown>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return Deno.env.toObject() as
(property) deno: () => T
T
namespace Deno
}, workerd: () =>
(type parameter) T in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
c
(property) workerd: () => any
.env,
(parameter) c: C extends Context = Context<{}, any, {}>
(property) Context<any, any, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
// On Fastly Compute, you can use the ConfigStore to manage user-defined data. fastly: () => ({} as
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
T),
(property) fastly: () => T
other: () => ({} as
(type parameter) T in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
T),
(property) other: () => T
} return runtimeEnvHandlers
(type parameter) T in <T extends Record<string, unknown>, C extends Context = Context<{}, any, {}>>(c: C, runtime?: Runtime): T & C["env"]
[runtime]()
const runtimeEnvHandlers: Record<string, () => T>
} export const knownUserAgents:
(parameter) runtime: Runtime
Partial
const knownUserAgents: Partial<Record<Runtime, string>>
<Record
type Partial<T> = { [P in keyof T]?: T[P] | undefined; }
Make all properties in T optional<Runtime, string>> = {
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tdeno: 'Deno',
type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other"
bun: 'Bun',
(property) deno?: string | undefined
workerd: 'Cloudflare-Workers',
(property) bun?: string | undefined
node: 'Node.js',
(property) workerd?: string | undefined
} export const getRuntimeKey = ():
(property) node?: string | undefined
Runtime => {
const getRuntimeKey: () => Runtime
// eslint-disable-next-line @typescript-eslint/no-explicit-any const global = globalThis as any
type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other"
// check if the current runtime supports navigator.userAgent const userAgentSupported =
const global: any
typeof navigator !== 'undefined' && typeof
const userAgentSupported: boolean
navigator
var navigator: Navigator
MDN Reference.userAgent === 'string'
var navigator: Navigator
MDN Reference// if supported, check the user agent if (userAgentSupported) {
(property) NavigatorID.userAgent: string
MDN Referencefor (const [runtimeKey,
const userAgentSupported: boolean
userAgent] of
const runtimeKey: string
Object
const userAgent: string
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<string>(o: { [s: string]: string; } | ArrayLike<string>): [string, string][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(knownUserAgents)) {o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.if (checkUserAgentEquals
const knownUserAgents: Partial<Record<Runtime, string>>
(userAgent)) {
const checkUserAgentEquals: (platform: string) => boolean
return runtimeKey as
const userAgent: string
Runtime
const runtimeKey: string
} } } // check if running on Edge Runtime if (typeof global?.EdgeRuntime === 'string') {
type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other"
return 'edge-light' } // check if running on Fastly if (global?.fastly !== undefined) {
const global: any
return 'fastly' } // userAgent isn't supported before Node v21.1.0; so fallback to the old way if (global?.process?.release?.name === 'node') {
const global: any
return 'node' } // couldn't detect the runtime return 'other' } export const checkUserAgentEquals =
const global: any
(platform: string): boolean => {
const checkUserAgentEquals: (platform: string) => boolean
const userAgent =
(parameter) platform: string
navigator
const userAgent: string
.userAgent
var navigator: Navigator
MDN Referencereturn userAgent
(property) NavigatorID.userAgent: string
MDN Reference.startsWith
const userAgent: string
(platform)
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.}
(parameter) platform: string
/** * @module * ConnInfo Helper for Hono. */ export type { AddressType,NetAddrInfo,
(alias) type AddressType = "IPv6" | "IPv4" | undefined export AddressType
ConnInfo,
(alias) type NetAddrInfo = { transport?: "tcp" | "udp"; port?: number; address?: string; addressType?: AddressType; } | ({ transport?: "tcp" | "udp"; port?: number; address?: string; addressType?: AddressType; } & { ...; }) export NetAddrInfo
GetConnInfo } from './types'
(alias) interface ConnInfo export ConnInfo
HTTP Connection information
(alias) type GetConnInfo = (c: Context) => ConnInfo export GetConnInfo
Helper type
import type { Context } from '../../context' export type AddressType = 'IPv6' | 'IPv4' | undefinedexport type NetAddrInfo = {
type AddressType = "IPv6" | "IPv4" | undefined
/** * Transport protocol type */ transport?: 'tcp' | 'udp'
type NetAddrInfo = { transport?: "tcp" | "udp"; port?: number; address?: string; addressType?: AddressType; } | ({ transport?: "tcp" | "udp"; port?: number; address?: string; addressType?: AddressType; } & { ...; })
/** * Transport port number */ port?: number
(property) transport?: "tcp" | "udp" | undefined
Transport protocol typeaddress?: string
(property) port?: number | undefined
Transport port numberaddressType?:
(property) address?: string | undefined
AddressType
(property) addressType?: AddressType
} & ( | { /** * Host name such as IP Addr */ address: string
type AddressType = "IPv6" | "IPv4" | undefined
/** * Host name type */ addressType:
(property) address: string
Host name such as IP AddrAddressType
(property) addressType: AddressType
Host name type} | {} ) /** * HTTP Connection information */ export interface ConnInfo {
type AddressType = "IPv6" | "IPv4" | undefined
/** * Remote information */ remote:
interface ConnInfo
HTTP Connection informationNetAddrInfo
(property) ConnInfo.remote: NetAddrInfo
Remote information} /** * Helper type */ export type GetConnInfo =
type NetAddrInfo = { transport?: "tcp" | "udp"; port?: number; address?: string; addressType?: AddressType; } | ({ transport?: "tcp" | "udp"; port?: number; address?: string; addressType?: AddressType; } & { ...; })
(c:
type GetConnInfo = (c: Context) => ConnInfo
Helper typeContext) =>
(parameter) c: Context<any, any, {}>
ConnInfo
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
interface ConnInfo
HTTP Connection information
import { Hono } from '../../hono' import { deleteCookie, getCookie, getSignedCookie, setCookie, setSignedCookie } from '.' describe('Cookie Middleware', () => { describe('Parse cookie', () => { const apps:Record
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
Hono> = {}
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
apps['get by name'] = (() => {BasePath
— The base path type.const app = new
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/cookie',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/cookie", "/cookie", Response, BlankInput, BlankEnv>(path: "/cookie", handler: H<BlankEnv, "/cookie", BlankInput, Response>) => Hono<...> (+22 overloads)
const yummyCookie =
(parameter) c: Context<BlankEnv, "/cookie", BlankInput>
getCookie
const yummyCookie: string | undefined
(c, 'yummy_cookie')
(alias) getCookie(c: Context, key: string): string | undefined (+2 overloads) import getCookie
const tastyCookie =
(parameter) c: Context<BlankEnv, "/cookie", BlankInput>
getCookie
const tastyCookie: string | undefined
(c, 'tasty_cookie')
(alias) getCookie(c: Context, key: string): string | undefined (+2 overloads) import getCookie
const res = new
(parameter) c: Context<BlankEnv, "/cookie", BlankInput>
Response('Good cookie')
const res: Response
if (yummyCookie &&
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.tastyCookie) {
const yummyCookie: string | undefined
res
const tastyCookie: string | undefined
.headers
const res: Response
.set('Yummy-Cookie',
(property) Response.headers: Headers
MDN ReferenceyummyCookie)
(method) Headers.set(name: string, value: string): void
MDN Referenceres
const yummyCookie: string
.headers
const res: Response
.set('Tasty-Cookie',
(property) Response.headers: Headers
MDN ReferencetastyCookie)
(method) Headers.set(name: string, value: string): void
MDN Reference} return res
const tastyCookie: string
}) return app
const res: Response
})() apps['get all as an object'] = (() => {
const app: Hono<BlankEnv, BlankSchema, "/">
const app = new
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/cookie',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/cookie", "/cookie", Response, BlankInput, BlankEnv>(path: "/cookie", handler: H<BlankEnv, "/cookie", BlankInput, Response>) => Hono<...> (+22 overloads)
const { yummy_cookie: yummyCookie, tasty_cookie:
(parameter) c: Context<BlankEnv, "/cookie", BlankInput>
tastyCookie } =
const yummyCookie: string
getCookie
const tastyCookie: string
(c)
(alias) getCookie(c: Context): Cookie (+2 overloads) import getCookie
const res = new
(parameter) c: Context<BlankEnv, "/cookie", BlankInput>
Response('Good cookie')
const res: Response
res
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..headers
const res: Response
.set('Yummy-Cookie',
(property) Response.headers: Headers
MDN ReferenceyummyCookie)
(method) Headers.set(name: string, value: string): void
MDN Referenceres
const yummyCookie: string
.headers
const res: Response
.set('Tasty-Cookie',
(property) Response.headers: Headers
MDN ReferencetastyCookie)
(method) Headers.set(name: string, value: string): void
MDN Referencereturn res
const tastyCookie: string
}) return app
const res: Response
})() describe.each(Object
const app: Hono<BlankEnv, BlankSchema, "/">
.keys
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.keys(o: {}): string[] (+1 overload)
Returns the names of the enumerable string properties and methods of an object.@param
(apps))('%s',o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.(name) => {
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
const app =
(parameter) name: any
apps
const app: Hono<BlankEnv, BlankSchema, "/">
[name]
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
it('Parse cookie with getCookie()', async () => { const req = new
(parameter) name: any
Request('http://localhost/cookie')
const req: Request
const cookieString = 'yummy_cookie=choco; tasty_cookie = strawberry'
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.req
const cookieString: "yummy_cookie=choco; tasty_cookie = strawberry"
.headers
const req: Request
.set('Cookie',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.cookieString)
(method) Headers.set(name: string, value: string): void
MDN Referenceconst res = await
const cookieString: "yummy_cookie=choco; tasty_cookie = strawberry"
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.headers
const res: Response
.get('Yummy-Cookie')).toBe('choco')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('Tasty-Cookie')).toBe('strawberry')
(property) Response.headers: Headers
MDN Reference}) }) const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/cookie-signed-get-all', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/cookie-signed-get-all", "/cookie-signed-get-all", Promise<Response>, BlankInput, BlankEnv>(path: "/cookie-signed-get-all", handler: H<BlankEnv, "/cookie-signed-get-all", BlankInput, Promise<...>>) => Hono<...> (+22 overloads)
const secret = 'secret lucky charm'
(parameter) c: Context<BlankEnv, "/cookie-signed-get-all", BlankInput>
const { fortune_cookie: fortuneCookie, fruit_cookie:
const secret: "secret lucky charm"
fruitCookie } = await
const fortuneCookie: string | false
getSignedCookie(
const fruitCookie: string | false
c,
(alias) getSignedCookie(c: Context, secret: string): Promise<SignedCookie> (+2 overloads) import getSignedCookie
secret
(parameter) c: Context<BlankEnv, "/cookie-signed-get-all", BlankInput>
) const res = new
const secret: "secret lucky charm"
Response('Signed fortune cookie')
const res: Response
if (typeof fortuneCookie !== 'undefined' && typeof
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.fruitCookie !== 'undefined') {
const fortuneCookie: string | false
// just examples for tests sake res
const fruitCookie: string | false
.headers
const res: Response
.set('Fortune-Cookie',
(property) Response.headers: Headers
MDN ReferencefortuneCookie || 'INVALID')
(method) Headers.set(name: string, value: string): void
MDN Referenceres
const fortuneCookie: string | false
.headers
const res: Response
.set('Fruit-Cookie',
(property) Response.headers: Headers
MDN ReferencefruitCookie || 'INVALID')
(method) Headers.set(name: string, value: string): void
MDN Reference} return res
const fruitCookie: string | false
}) app
const res: Response
.get('/cookie-signed-get-one', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/cookie-signed-get-one", "/cookie-signed-get-one", Promise<Response>, BlankInput, BlankEnv>(path: "/cookie-signed-get-one", handler: H<BlankEnv, "/cookie-signed-get-one", BlankInput, Promise<...>>) => Hono<...> (+22 overloads)
const secret = 'secret lucky charm'
(parameter) c: Context<BlankEnv, "/cookie-signed-get-one", BlankInput>
const fortuneCookie = await
const secret: "secret lucky charm"
getSignedCookie
const fortuneCookie: string | false | undefined
(c,
(alias) getSignedCookie(c: Context, secret: string | BufferSource, key: string): Promise<string | undefined | false> (+2 overloads) import getSignedCookie
secret, 'fortune_cookie')
(parameter) c: Context<BlankEnv, "/cookie-signed-get-one", BlankInput>
const res = new
const secret: "secret lucky charm"
Response('Signed fortune cookie')
const res: Response
if (typeof fortuneCookie !== 'undefined') {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.// just an example for tests sake res
const fortuneCookie: string | false | undefined
.headers
const res: Response
.set('Fortune-Cookie',
(property) Response.headers: Headers
MDN ReferencefortuneCookie || 'INVALID')
(method) Headers.set(name: string, value: string): void
MDN Reference} return res
const fortuneCookie: string | false
}) it('Get signed cookies', async () => { const req = new
const res: Response
Request('http://localhost/cookie-signed-get-all')
const req: Request
const cookieString =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.'fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D' req
const cookieString: "fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D"
.headers
const req: Request
.set('Cookie',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.cookieString)
(method) Headers.set(name: string, value: string): void
MDN Referenceconst res = await
const cookieString: "fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D"
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.headers
const res: Response
.get('Fortune-Cookie')).toBe('lots-of-money')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('Fruit-Cookie')).toBe('mango')
(property) Response.headers: Headers
MDN Reference}) it('Get signed cookies invalid signature', async () => { const req = new
(method) Headers.get(name: string): string | null
MDN ReferenceRequest('http://localhost/cookie-signed-get-all')
const req: Request
// fruit_cookie has invalid signature const cookieString =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.'fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.LAa7RX43t2vCrLNcKmNG65H41OkyV02sraRPuY5RuVg%3D' req
const cookieString: "fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.LAa7RX43t2vCrLNcKmNG65H41OkyV02sraRPuY5RuVg%3D"
.headers
const req: Request
.set('Cookie',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.cookieString)
(method) Headers.set(name: string, value: string): void
MDN Referenceconst res = await
const cookieString: "fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.LAa7RX43t2vCrLNcKmNG65H41OkyV02sraRPuY5RuVg%3D"
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.headers
const res: Response
.get('Fortune-Cookie')).toBe('lots-of-money')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('Fruit-Cookie')).toBe('INVALID')
(property) Response.headers: Headers
MDN Reference}) it('Get signed cookie', async () => { const req = new
(method) Headers.get(name: string): string | null
MDN ReferenceRequest('http://localhost/cookie-signed-get-one')
const req: Request
const cookieString =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.'fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D' req
const cookieString: "fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D"
.headers
const req: Request
.set('Cookie',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.cookieString)
(method) Headers.set(name: string, value: string): void
MDN Referenceconst res = await
const cookieString: "fortune_cookie=lots-of-money.UO6vMygDM6NCDU4LdvBnzdVb2Xcdj+h+ZTnmS8X7iH8%3D; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D"
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.headers
const res: Response
.get('Fortune-Cookie')).toBe('lots-of-money')
(property) Response.headers: Headers
MDN Reference}) it('Get signed cookie witn invalid signature', async () => { const req = new
(method) Headers.get(name: string): string | null
MDN ReferenceRequest('http://localhost/cookie-signed-get-one')
const req: Request
// fortune_cookie has invalid signature const cookieString =
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.'fortune_cookie=lots-of-money.LAa7RX43t2vCrLNcKmNG65H41OkyV02sraRPuY5RuVg=; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D' req
const cookieString: "fortune_cookie=lots-of-money.LAa7RX43t2vCrLNcKmNG65H41OkyV02sraRPuY5RuVg=; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D"
.headers
const req: Request
.set('Cookie',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.cookieString)
(method) Headers.set(name: string, value: string): void
MDN Referenceconst res = await
const cookieString: "fortune_cookie=lots-of-money.LAa7RX43t2vCrLNcKmNG65H41OkyV02sraRPuY5RuVg=; fruit_cookie=mango.lRwgtW9ooM9%2Fd9ZZA%2FInNRG64CbQsfWGXQyFLPM9520%3D"
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.headers
const res: Response
.get('Fortune-Cookie')).toBe('INVALID')
(property) Response.headers: Headers
MDN Reference}) describe('get null if the value is undefined', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/cookie',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/cookie", "/cookie", Response, BlankInput, BlankEnv>(path: "/cookie", handler: H<BlankEnv, "/cookie", BlankInput, Response>) => Hono<...> (+22 overloads)
const yummyCookie =
(parameter) c: Context<BlankEnv, "/cookie", BlankInput>
getCookie
const yummyCookie: string | undefined
(c, 'yummy_cookie')
(alias) getCookie(c: Context, key: string): string | undefined (+2 overloads) import getCookie
const res = new
(parameter) c: Context<BlankEnv, "/cookie", BlankInput>
Response('Good cookie')
const res: Response
if (yummyCookie) {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.res
const yummyCookie: string | undefined
.headers
const res: Response
.set('Yummy-Cookie',
(property) Response.headers: Headers
MDN ReferenceyummyCookie)
(method) Headers.set(name: string, value: string): void
MDN Reference} return res
const yummyCookie: string
}) it('Should be null', async () => { const req = new
const res: Response
Request('http://localhost/cookie')
const req: Request
const cookieString = 'yummy_cookie='
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.req
const cookieString: "yummy_cookie="
.headers
const req: Request
.set('Cookie',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.cookieString)
(method) Headers.set(name: string, value: string): void
MDN Referenceconst res = await
const cookieString: "yummy_cookie="
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.headers
const res: Response
.get('Yummy-Cookie')).toBe(null)
(property) Response.headers: Headers
MDN Reference}) }) }) describe('Set cookie', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/set-cookie',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-cookie", "/set-cookie", Response & TypedResponse<"Give cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/set-cookie", handler: H<...>) => Hono<...> (+22 overloads)
setCookie
(parameter) c: Context<BlankEnv, "/set-cookie", BlankInput>
(c, 'delicious_cookie', 'macha')
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
return c
(parameter) c: Context<BlankEnv, "/set-cookie", BlankInput>
.text('Give cookie')
(parameter) c: Context<BlankEnv, "/set-cookie", BlankInput>
}) it('Set cookie with setCookie()', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give cookie", StatusCode>(text: "Give cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe('delicious_cookie=macha; Path=/')
(method) Headers.get(name: string): string | null
MDN Reference}) app
const header: string | null
.get('/a/set-cookie-path',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/a/set-cookie-path", "/a/set-cookie-path", Response & TypedResponse<"Give cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/a/set-cookie-path", handler: H<...>) => Hono<...> (+22 overloads)
setCookie
(parameter) c: Context<BlankEnv, "/a/set-cookie-path", BlankInput>
(c, 'delicious_cookie', 'macha', {
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
path: '/a' })
(parameter) c: Context<BlankEnv, "/a/set-cookie-path", BlankInput>
return c
(property) path?: string | undefined
.text('Give cookie')
(parameter) c: Context<BlankEnv, "/a/set-cookie-path", BlankInput>
}) it('Set cookie with setCookie() and path option', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give cookie", StatusCode>(text: "Give cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/a/set-cookie-path')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe('delicious_cookie=macha; Path=/a')
(method) Headers.get(name: string): string | null
MDN Reference}) app
const header: string | null
.get('/set-signed-cookie', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-signed-cookie", "/set-signed-cookie", Promise<Response & TypedResponse<"Give signed cookie", StatusCode, "text">>, BlankInput, BlankEnv>(path: "/set-signed-cookie", handler: H<...>) => Hono<...> (+22 overloads)
const secret = 'secret chocolate chips'
(parameter) c: Context<BlankEnv, "/set-signed-cookie", BlankInput>
await setSignedCookie
const secret: "secret chocolate chips"
(c, 'delicious_cookie', 'macha',
(alias) setSignedCookie(c: Context, name: string, value: string, secret: string | BufferSource, opt?: CookieOptions): Promise<void> import setSignedCookie
secret)
(parameter) c: Context<BlankEnv, "/set-signed-cookie", BlankInput>
return c
const secret: "secret chocolate chips"
.text('Give signed cookie')
(parameter) c: Context<BlankEnv, "/set-signed-cookie", BlankInput>
}) it('Set signed cookie with setSignedCookie()', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give signed cookie", StatusCode>(text: "Give signed cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-signed-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe(
(method) Headers.get(name: string): string | null
MDN Reference'delicious_cookie=macha.diubJPY8O7hI1pLa42QSfkPiyDWQ0I4DnlACH%2FN2HaA%3D; Path=/' ) }) app
const header: string | null
.get('/a/set-signed-cookie-path', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/a/set-signed-cookie-path", "/a/set-signed-cookie-path", Promise<Response & TypedResponse<"Give signed cookie", StatusCode, "text">>, BlankInput, BlankEnv>(path: "/a/set-signed-cookie-path", handler: H<...>) => Hono<...> (+22 overloads)
const secret = 'secret chocolate chips'
(parameter) c: Context<BlankEnv, "/a/set-signed-cookie-path", BlankInput>
await setSignedCookie
const secret: "secret chocolate chips"
(c, 'delicious_cookie', 'macha',
(alias) setSignedCookie(c: Context, name: string, value: string, secret: string | BufferSource, opt?: CookieOptions): Promise<void> import setSignedCookie
secret, {
(parameter) c: Context<BlankEnv, "/a/set-signed-cookie-path", BlankInput>
path: '/a' })
const secret: "secret chocolate chips"
return c
(property) path?: string | undefined
.text('Give signed cookie')
(parameter) c: Context<BlankEnv, "/a/set-signed-cookie-path", BlankInput>
}) it('Set signed cookie with setSignedCookie() and path option', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give signed cookie", StatusCode>(text: "Give signed cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/a/set-signed-cookie-path')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe(
(method) Headers.get(name: string): string | null
MDN Reference'delicious_cookie=macha.diubJPY8O7hI1pLa42QSfkPiyDWQ0I4DnlACH%2FN2HaA%3D; Path=/a' ) }) app
const header: string | null
.get('/get-secure-prefix-cookie', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/get-secure-prefix-cookie", "/get-secure-prefix-cookie", Promise<Response>, BlankInput, BlankEnv>(path: "/get-secure-prefix-cookie", handler: H<...>) => Hono<...> (+22 overloads)
const cookie =
(parameter) c: Context<BlankEnv, "/get-secure-prefix-cookie", BlankInput>
getCookie
const cookie: string | undefined
(c, 'delicious_cookie', 'secure')
(alias) getCookie(c: Context, key: string, prefixOptions: CookiePrefixOptions): string | undefined (+2 overloads) import getCookie
if (cookie) {
(parameter) c: Context<BlankEnv, "/get-secure-prefix-cookie", BlankInput>
return c
const cookie: string | undefined
.text
(parameter) c: Context<BlankEnv, "/get-secure-prefix-cookie", BlankInput>
(cookie)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
} else { return c
const cookie: string
.notFound()
(parameter) c: Context<BlankEnv, "/get-secure-prefix-cookie", BlankInput>
(property) Context<BlankEnv, "/get-secure-prefix-cookie", BlankInput>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
} }) app
ts app.get('/notfound', (c) => { return c.notFound() })
.get('/get-host-prefix-cookie', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/get-host-prefix-cookie", "/get-host-prefix-cookie", Promise<Response>, BlankInput, BlankEnv>(path: "/get-host-prefix-cookie", handler: H<...>) => Hono<...> (+22 overloads)
const cookie =
(parameter) c: Context<BlankEnv, "/get-host-prefix-cookie", BlankInput>
getCookie
const cookie: string | undefined
(c, 'delicious_cookie', 'host')
(alias) getCookie(c: Context, key: string, prefixOptions: CookiePrefixOptions): string | undefined (+2 overloads) import getCookie
if (cookie) {
(parameter) c: Context<BlankEnv, "/get-host-prefix-cookie", BlankInput>
return c
const cookie: string | undefined
.text
(parameter) c: Context<BlankEnv, "/get-host-prefix-cookie", BlankInput>
(cookie)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
} else { return c
const cookie: string
.notFound()
(parameter) c: Context<BlankEnv, "/get-host-prefix-cookie", BlankInput>
(property) Context<BlankEnv, "/get-host-prefix-cookie", BlankInput>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
} }) app
ts app.get('/notfound', (c) => { return c.notFound() })
.get('/set-secure-prefix-cookie',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-secure-prefix-cookie", "/set-secure-prefix-cookie", Response & TypedResponse<"Set secure prefix cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/set-secure-prefix-cookie", handler: H<...>) => Hono<...> (+22 overloads)
setCookie
(parameter) c: Context<BlankEnv, "/set-secure-prefix-cookie", BlankInput>
(c, 'delicious_cookie', 'macha', {
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
prefix: 'secure',
(parameter) c: Context<BlankEnv, "/set-secure-prefix-cookie", BlankInput>
secure: false, // this will be ignore
(property) prefix?: CookiePrefixOptions | undefined
}) return c
(property) secure?: boolean | undefined
.text('Set secure prefix cookie')
(parameter) c: Context<BlankEnv, "/set-secure-prefix-cookie", BlankInput>
}) it('Set cookie with secure prefix', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Set secure prefix cookie", StatusCode>(text: "Set secure prefix cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-secure-prefix-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe('__Secure-delicious_cookie=macha; Path=/; Secure')
(method) Headers.get(name: string): string | null
MDN Reference}) it('Get cookie with secure prefix', async () => { const setCookie = await
const header: string | null
app
const setCookie: Response
.request('http://localhost/set-secure-prefix-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
const header =setCookie
const header: string | null
.headers
const setCookie: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceif (!header) {
(method) Headers.get(name: string): string | null
MDN Referenceassert.fail('invalid header') } const res = await
const header: string | null
app
const res: Response
.request('http://localhost/get-secure-prefix-cookie', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {Cookie:
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.header,
(property) Cookie: string | null
}, }) const response = await
const header: string | null
res
const response: string
.text()
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.status).toBe(200)
const res: Response
expect(response).toBe('macha')
(property) Response.status: number
MDN Reference}) app
const response: string
.get('/set-host-prefix-cookie',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-host-prefix-cookie", "/set-host-prefix-cookie", Response & TypedResponse<"Set host prefix cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/set-host-prefix-cookie", handler: H<...>) => Hono<...> (+22 overloads)
setCookie
(parameter) c: Context<BlankEnv, "/set-host-prefix-cookie", BlankInput>
(c, 'delicious_cookie', 'macha', {
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
prefix: 'host',
(parameter) c: Context<BlankEnv, "/set-host-prefix-cookie", BlankInput>
path: '/foo', // this will be ignored
(property) prefix?: CookiePrefixOptions | undefined
domain: 'example.com', // this will be ignored
(property) path?: string | undefined
secure: false, // this will be ignored
(property) domain?: string | undefined
}) return c
(property) secure?: boolean | undefined
.text('Set host prefix cookie')
(parameter) c: Context<BlankEnv, "/set-host-prefix-cookie", BlankInput>
}) it('Set cookie with host prefix', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Set host prefix cookie", StatusCode>(text: "Set host prefix cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-host-prefix-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe('__Host-delicious_cookie=macha; Path=/; Secure')
(method) Headers.get(name: string): string | null
MDN Reference}) it('Get cookie with host prefix', async () => { const setCookie = await
const header: string | null
app
const setCookie: Response
.request('http://localhost/set-host-prefix-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
const header =setCookie
const header: string | null
.headers
const setCookie: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceif (!header) {
(method) Headers.get(name: string): string | null
MDN Referenceassert.fail('invalid header') } const res = await
const header: string | null
app
const res: Response
.request('http://localhost/get-host-prefix-cookie', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {Cookie:
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.header,
(property) Cookie: string | null
}, }) const response = await
const header: string | null
res
const response: string
.text()
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.status).toBe(200)
const res: Response
expect(response).toBe('macha')
(property) Response.status: number
MDN Reference}) app
const response: string
.get('/set-signed-secure-prefix-cookie', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-signed-secure-prefix-cookie", "/set-signed-secure-prefix-cookie", Promise<Response & TypedResponse<"Set secure prefix cookie", StatusCode, "text">>, BlankInput, BlankEnv>(path: "/set-signed-secure-prefix-cookie", handler: H<...>) => Hono<...> (+22 overloads)
await setSignedCookie
(parameter) c: Context<BlankEnv, "/set-signed-secure-prefix-cookie", BlankInput>
(c, 'delicious_cookie', 'macha', 'secret choco chips', {
(alias) setSignedCookie(c: Context, name: string, value: string, secret: string | BufferSource, opt?: CookieOptions): Promise<void> import setSignedCookie
prefix: 'secure',
(parameter) c: Context<BlankEnv, "/set-signed-secure-prefix-cookie", BlankInput>
}) return c
(property) prefix?: CookiePrefixOptions | undefined
.text('Set secure prefix cookie')
(parameter) c: Context<BlankEnv, "/set-signed-secure-prefix-cookie", BlankInput>
}) it('Set signed cookie with secure prefix', async () => { const res = await
(property) Context<BlankEnv, "/set-signed-secure-prefix-cookie", BlankInput>.text: TextRespond <"Set secure prefix cookie", StatusCode>(text: "Set secure prefix cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-signed-secure-prefix-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe(
(method) Headers.get(name: string): string | null
MDN Reference'__Secure-delicious_cookie=macha.i225faTyCrJUY8TvpTuJHI20HBWbQ89B4GV7lT4E%2FB0%3D; Path=/; Secure' ) }) app
const header: string | null
.get('/set-signed-host-prefix-cookie', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-signed-host-prefix-cookie", "/set-signed-host-prefix-cookie", Promise<Response & TypedResponse<"Set host prefix cookie", StatusCode, "text">>, BlankInput, BlankEnv>(path: "/set-signed-host-prefix-cookie", handler: H<...>) => Hono<...> (+22 overloads)
await setSignedCookie
(parameter) c: Context<BlankEnv, "/set-signed-host-prefix-cookie", BlankInput>
(c, 'delicious_cookie', 'macha', 'secret choco chips', {
(alias) setSignedCookie(c: Context, name: string, value: string, secret: string | BufferSource, opt?: CookieOptions): Promise<void> import setSignedCookie
prefix: 'host',
(parameter) c: Context<BlankEnv, "/set-signed-host-prefix-cookie", BlankInput>
domain: 'example.com', // this will be ignored
(property) prefix?: CookiePrefixOptions | undefined
path: 'example.com', // thi will be ignored
(property) domain?: string | undefined
secure: false, // this will be ignored
(property) path?: string | undefined
}) return c
(property) secure?: boolean | undefined
.text('Set host prefix cookie')
(parameter) c: Context<BlankEnv, "/set-signed-host-prefix-cookie", BlankInput>
}) it('Set signed cookie with host prefix', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Set host prefix cookie", StatusCode>(text: "Set host prefix cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-signed-host-prefix-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe(
(method) Headers.get(name: string): string | null
MDN Reference'__Host-delicious_cookie=macha.i225faTyCrJUY8TvpTuJHI20HBWbQ89B4GV7lT4E%2FB0%3D; Path=/; Secure' ) }) app
const header: string | null
.get('/set-cookie-complex',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-cookie-complex", "/set-cookie-complex", Response & TypedResponse<"Give cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/set-cookie-complex", handler: H<...>) => Hono<...> (+22 overloads)
setCookie
(parameter) c: Context<BlankEnv, "/set-cookie-complex", BlankInput>
(c, 'great_cookie', 'banana', {
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
path: '/',
(parameter) c: Context<BlankEnv, "/set-cookie-complex", BlankInput>
secure: true,
(property) path?: string | undefined
domain: 'example.com',
(property) secure: true
httpOnly: true,
(property) domain?: string | undefined
maxAge: 1000,
(property) httpOnly?: boolean | undefined
expires: new
(property) maxAge?: number | undefined
Date
(property) expires?: Date | undefined
(Date
var Date: DateConstructor new (value: number | string | Date) => Date (+4 overloads)
.UTC(2000, 11, 24, 10, 30, 59, 900)),
var Date: DateConstructor
Enables basic storage and retrieval of dates and times.
(method) DateConstructor.UTC(year: number, monthIndex?: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number (+1 overload)
Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.@param
year
— The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.@param
monthIndex
— The month as a number between 0 and 11 (January to December).@param
date
— The date as a number between 1 and 31.@param
hours
— Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.@param
minutes
— Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.@param
seconds
— Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.@param
sameSite: 'Strict',ms
— A number from 0 to 999 that specifies the milliseconds.}) return c
(property) sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none" | undefined
.text('Give cookie')
(parameter) c: Context<BlankEnv, "/set-cookie-complex", BlankInput>
}) it('Complex pattern', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give cookie", StatusCode>(text: "Give cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-cookie-complex')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe(
(method) Headers.get(name: string): string | null
MDN Reference'great_cookie=banana; Max-Age=1000; Domain=example.com; Path=/; Expires=Sun, 24 Dec 2000 10:30:59 GMT; HttpOnly; Secure; SameSite=Strict' ) }) app
const header: string | null
.get('/set-signed-cookie-complex', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-signed-cookie-complex", "/set-signed-cookie-complex", Promise<Response & TypedResponse<"Give signed cookie", StatusCode, "text">>, BlankInput, BlankEnv>(path: "/set-signed-cookie-complex", handler: H<...>) => Hono<...> (+22 overloads)
const secret = 'secret chocolate chips'
(parameter) c: Context<BlankEnv, "/set-signed-cookie-complex", BlankInput>
await setSignedCookie
const secret: "secret chocolate chips"
(c, 'great_cookie', 'banana',
(alias) setSignedCookie(c: Context, name: string, value: string, secret: string | BufferSource, opt?: CookieOptions): Promise<void> import setSignedCookie
secret, {
(parameter) c: Context<BlankEnv, "/set-signed-cookie-complex", BlankInput>
path: '/',
const secret: "secret chocolate chips"
secure: true,
(property) path?: string | undefined
domain: 'example.com',
(property) secure: true
httpOnly: true,
(property) domain?: string | undefined
maxAge: 1000,
(property) httpOnly?: boolean | undefined
expires: new
(property) maxAge?: number | undefined
Date
(property) expires?: Date | undefined
(Date
var Date: DateConstructor new (value: number | string | Date) => Date (+4 overloads)
.UTC(2000, 11, 24, 10, 30, 59, 900)),
var Date: DateConstructor
Enables basic storage and retrieval of dates and times.
(method) DateConstructor.UTC(year: number, monthIndex?: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number (+1 overload)
Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.@param
year
— The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.@param
monthIndex
— The month as a number between 0 and 11 (January to December).@param
date
— The date as a number between 1 and 31.@param
hours
— Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.@param
minutes
— Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.@param
seconds
— Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.@param
sameSite: 'Strict',ms
— A number from 0 to 999 that specifies the milliseconds.}) return c
(property) sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none" | undefined
.text('Give signed cookie')
(parameter) c: Context<BlankEnv, "/set-signed-cookie-complex", BlankInput>
}) it('Complex pattern (signed)', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give signed cookie", StatusCode>(text: "Give signed cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-signed-cookie-complex')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe(
(method) Headers.get(name: string): string | null
MDN Reference'great_cookie=banana.hSo6gB7YT2db0WBiEAakEmh7dtwEL0DSp76G23WvHuQ%3D; Max-Age=1000; Domain=example.com; Path=/; Expires=Sun, 24 Dec 2000 10:30:59 GMT; HttpOnly; Secure; SameSite=Strict' ) }) app
const header: string | null
.get('/set-cookie-multiple',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/set-cookie-multiple", "/set-cookie-multiple", Response & TypedResponse<"Give cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/set-cookie-multiple", handler: H<...>) => Hono<...> (+22 overloads)
setCookie
(parameter) c: Context<BlankEnv, "/set-cookie-multiple", BlankInput>
(c, 'delicious_cookie', 'macha')
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
setCookie
(parameter) c: Context<BlankEnv, "/set-cookie-multiple", BlankInput>
(c, 'delicious_cookie', 'choco')
(alias) setCookie(c: Context, name: string, value: string, opt?: CookieOptions): void import setCookie
return c
(parameter) c: Context<BlankEnv, "/set-cookie-multiple", BlankInput>
.text('Give cookie')
(parameter) c: Context<BlankEnv, "/set-cookie-multiple", BlankInput>
}) it('Multiple values', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give cookie", StatusCode>(text: "Give cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/set-cookie-multiple')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
const header =
(property) Response.status: number
MDN Referenceres
const header: string | null
.headers
const res: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header).toBe('delicious_cookie=macha; Path=/, delicious_cookie=choco; Path=/')
(method) Headers.get(name: string): string | null
MDN Reference}) }) describe('Delete cookie', () => { const app = new
const header: string | null
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/delete-cookie',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/delete-cookie", "/delete-cookie", Response & TypedResponse<"Give cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/delete-cookie", handler: H<...>) => Hono<...> (+22 overloads)
deleteCookie
(parameter) c: Context<BlankEnv, "/delete-cookie", BlankInput>
(c, 'delicious_cookie')
(alias) deleteCookie(c: Context, name: string, opt?: CookieOptions): string | undefined import deleteCookie
return c
(parameter) c: Context<BlankEnv, "/delete-cookie", BlankInput>
.text('Give cookie')
(parameter) c: Context<BlankEnv, "/delete-cookie", BlankInput>
}) it('Delete cookie', async () => { const res2 = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give cookie", StatusCode>(text: "Give cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res2: Response
.request('http://localhost/delete-cookie')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res2.status).toBe(200)
const res2: Response
const header2 =
(property) Response.status: number
MDN Referenceres2
const header2: string | null
.headers
const res2: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header2).toBe('delicious_cookie=; Max-Age=0; Path=/')
(method) Headers.get(name: string): string | null
MDN Reference}) app
const header2: string | null
.get('/delete-cookie-multiple',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/delete-cookie-multiple", "/delete-cookie-multiple", Response & TypedResponse<"Give cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/delete-cookie-multiple", handler: H<...>) => Hono<...> (+22 overloads)
deleteCookie
(parameter) c: Context<BlankEnv, "/delete-cookie-multiple", BlankInput>
(c, 'delicious_cookie')
(alias) deleteCookie(c: Context, name: string, opt?: CookieOptions): string | undefined import deleteCookie
deleteCookie
(parameter) c: Context<BlankEnv, "/delete-cookie-multiple", BlankInput>
(c, 'delicious_cookie2')
(alias) deleteCookie(c: Context, name: string, opt?: CookieOptions): string | undefined import deleteCookie
return c
(parameter) c: Context<BlankEnv, "/delete-cookie-multiple", BlankInput>
.text('Give cookie')
(parameter) c: Context<BlankEnv, "/delete-cookie-multiple", BlankInput>
}) it('Delete multiple cookies', async () => { const res2 = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give cookie", StatusCode>(text: "Give cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res2: Response
.request('http://localhost/delete-cookie-multiple')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res2.status).toBe(200)
const res2: Response
const header2 =
(property) Response.status: number
MDN Referenceres2
const header2: string | null
.headers
const res2: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header2).toBe(
(method) Headers.get(name: string): string | null
MDN Reference'delicious_cookie=; Max-Age=0; Path=/, delicious_cookie2=; Max-Age=0; Path=/' ) }) app
const header2: string | null
.get('/delete-cookie-with-options',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/delete-cookie-with-options", "/delete-cookie-with-options", Response & TypedResponse<"Give cookie", StatusCode, "text">, BlankInput, BlankEnv>(path: "/delete-cookie-with-options", handler: H<...>) => Hono<...> (+22 overloads)
deleteCookie
(parameter) c: Context<BlankEnv, "/delete-cookie-with-options", BlankInput>
(c, 'delicious_cookie', {
(alias) deleteCookie(c: Context, name: string, opt?: CookieOptions): string | undefined import deleteCookie
path: '/',
(parameter) c: Context<BlankEnv, "/delete-cookie-with-options", BlankInput>
secure: true,
(property) path?: string | undefined
domain: 'example.com',
(property) secure: true
}) return c
(property) domain?: string | undefined
.text('Give cookie')
(parameter) c: Context<BlankEnv, "/delete-cookie-with-options", BlankInput>
}) it('Delete cookie with options', async () => { const res2 = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Give cookie", StatusCode>(text: "Give cookie", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res2: Response
.request('http://localhost/delete-cookie-with-options')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res2.status).toBe(200)
const res2: Response
const header2 =
(property) Response.status: number
MDN Referenceres2
const header2: string | null
.headers
const res2: Response
.get('Set-Cookie')
(property) Response.headers: Headers
MDN Referenceexpect(header2).toBe('delicious_cookie=; Max-Age=0; Domain=example.com; Path=/; Secure')
(method) Headers.get(name: string): string | null
MDN Reference}) app
const header2: string | null
.get('/delete-cookie-with-deleted-value',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/delete-cookie-with-deleted-value", "/delete-cookie-with-deleted-value", Response & TypedResponse<string, StatusCode, "text">, BlankInput, BlankEnv>(path: "/delete-cookie-with-deleted-value", handler: H<...>) => Hono<...> (+22 overloads)
const deleted =
(parameter) c: Context<BlankEnv, "/delete-cookie-with-deleted-value", BlankInput>
deleteCookie
const deleted: string | undefined
(c, 'delicious_cookie')
(alias) deleteCookie(c: Context, name: string, opt?: CookieOptions): string | undefined import deleteCookie
return c
(parameter) c: Context<BlankEnv, "/delete-cookie-with-deleted-value", BlankInput>
.text
(parameter) c: Context<BlankEnv, "/delete-cookie-with-deleted-value", BlankInput>
(deleted || '')
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
}) it('Get deleted value', async () => { const cookieString = 'delicious_cookie=choco'
const deleted: string | undefined
const req = new
const cookieString: "delicious_cookie=choco"
Request('http://localhost/delete-cookie-with-deleted-value')
const req: Request
req
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request..headers
const req: Request
.set('Cookie',
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.cookieString)
(method) Headers.set(name: string, value: string): void
MDN Referenceconst res = await
const cookieString: "delicious_cookie=choco"
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('choco')
const res: Response
}) }) })
(method) Body.text(): Promise<string>
MDN Reference
/** * @module * Cookie Helper for Hono. */ import type { Context } from '../../context' import { parse, parseSigned, serialize, serializeSigned } from '../../utils/cookie' import type { Cookie, CookieOptions, CookiePrefixOptions, SignedCookie } from '../../utils/cookie' interface GetCookie {(c:
interface GetCookie
Context,
(parameter) c: Context<any, any, {}>
key: string): string | undefined
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(c:
(parameter) key: string
Context):
(parameter) c: Context<any, any, {}>
Cookie
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(c:
(alias) type Cookie = { [x: string]: string; } import Cookie
Context,
(parameter) c: Context<any, any, {}>
key: string,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
prefixOptions:
(parameter) key: string
CookiePrefixOptions): string | undefined
(parameter) prefixOptions: CookiePrefixOptions
} interface GetSignedCookie {
(alias) type CookiePrefixOptions = "host" | "secure" import CookiePrefixOptions
(c:
interface GetSignedCookie
Context,
(parameter) c: Context<any, any, {}>
secret: string |
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
BufferSource,
(parameter) secret: string | BufferSource
key: string):
type BufferSource = ArrayBufferView | ArrayBuffer
Promise
(parameter) key: string
(c:
interface Promise<T>
Represents the completion of an asynchronous operationContext,
(parameter) c: Context<any, any, {}>
secret: string):
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Promise
(parameter) secret: string
<SignedCookie>
interface Promise<T>
Represents the completion of an asynchronous operation( c:
(alias) type SignedCookie = { [x: string]: string | false; } import SignedCookie
Context,
(parameter) c: Context<any, any, {}>
secret: string |
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
BufferSource,
(parameter) secret: string | BufferSource
key: string,
type BufferSource = ArrayBufferView | ArrayBuffer
prefixOptions:
(parameter) key: string
CookiePrefixOptions
(parameter) prefixOptions: CookiePrefixOptions
): Promise
(alias) type CookiePrefixOptions = "host" | "secure" import CookiePrefixOptions
} export const getCookie:
interface Promise<T>
Represents the completion of an asynchronous operationGetCookie =
const getCookie: GetCookie
(c,
interface GetCookie
key?,
(parameter) c: Context<any, any, {}>
prefix?:
(parameter) key: unknown
CookiePrefixOptions) => {
(parameter) prefix: CookiePrefixOptions | undefined
const cookie =
(alias) type CookiePrefixOptions = "host" | "secure" import CookiePrefixOptions
c
const cookie: string | null
.req
(parameter) c: Context<any, any, {}>
.raw
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.headers
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.get('Cookie')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.if (typeof key === 'string') {
(method) Headers.get(name: string): string | null
MDN Referenceif (!cookie) {
(parameter) key: unknown
return undefined } let finalKey =
const cookie: string | null
key
let finalKey: string
if (prefix === 'secure') {
(parameter) key: string
finalKey = '__Secure-' +
(parameter) prefix: CookiePrefixOptions | undefined
key
let finalKey: string
} else if (prefix === 'host') {
(parameter) key: string
finalKey = '__Host-' +
(parameter) prefix: "host" | undefined
key
let finalKey: string
} const obj =
(parameter) key: string
parse
const obj: Cookie
(cookie,
(alias) parse(cookie: string, name?: string): Cookie import parse
finalKey)
const cookie: string
return obj
let finalKey: string
[finalKey]
const obj: Cookie
} if (!cookie) {
let finalKey: string
return {} } const obj =
const cookie: string | null
parse
const obj: Cookie
(cookie)
(alias) parse(cookie: string, name?: string): Cookie import parse
// eslint-disable-next-line @typescript-eslint/no-explicit-any return obj as any
const cookie: string
} export const getSignedCookie:
const obj: Cookie
GetSignedCookie = async (
const getSignedCookie: GetSignedCookie
c,
interface GetSignedCookie
secret,
(parameter) c: Context<any, any, {}>
key?,
(parameter) secret: string | BufferSource
prefix?:
(parameter) key: unknown
CookiePrefixOptions
(parameter) prefix: CookiePrefixOptions | undefined
) => { const cookie =
(alias) type CookiePrefixOptions = "host" | "secure" import CookiePrefixOptions
c
const cookie: string | null
.req
(parameter) c: Context<any, any, {}>
.raw
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.headers
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.get('Cookie')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.if (typeof key === 'string') {
(method) Headers.get(name: string): string | null
MDN Referenceif (!cookie) {
(parameter) key: unknown
return undefined } let finalKey =
const cookie: string | null
key
let finalKey: string
if (prefix === 'secure') {
(parameter) key: string
finalKey = '__Secure-' +
(parameter) prefix: CookiePrefixOptions | undefined
key
let finalKey: string
} else if (prefix === 'host') {
(parameter) key: string
finalKey = '__Host-' +
(parameter) prefix: "host" | undefined
key
let finalKey: string
} const obj = await
(parameter) key: string
parseSigned
const obj: SignedCookie
(cookie,
(alias) parseSigned(cookie: string, secret: string | BufferSource, name?: string): Promise<SignedCookie> import parseSigned
secret,
const cookie: string
finalKey)
(parameter) secret: string | BufferSource
return obj
let finalKey: string
[finalKey]
const obj: SignedCookie
} if (!cookie) {
let finalKey: string
return {} } const obj = await
const cookie: string | null
parseSigned
const obj: SignedCookie
(cookie,
(alias) parseSigned(cookie: string, secret: string | BufferSource, name?: string): Promise<SignedCookie> import parseSigned
secret)
const cookie: string
// eslint-disable-next-line @typescript-eslint/no-explicit-any return obj as any
(parameter) secret: string | BufferSource
} export const setCookie =
const obj: SignedCookie
(c:
const setCookie: (c: Context, name: string, value: string, opt?: CookieOptions) => void
Context,
(parameter) c: Context<any, any, {}>
name: string,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
value: string,
(parameter) name: string
opt?:
(parameter) value: string
CookieOptions): void => {
(parameter) opt: CookieOptions | undefined
// Cookie names prefixed with __Secure- can be used only if they are set with the secure attribute. // Cookie names prefixed with __Host- can be used only if they are set with the secure attribute, must have a path of / (meaning any path at the host) // and must not have a Domain attribute. // Read more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#cookie_prefixes' let cookie
(alias) type CookieOptions = { domain?: string; expires?: Date; httpOnly?: boolean; maxAge?: number; path?: string; secure?: boolean; signingSecret?: string; sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none"; partitioned?: boolean; prefix?: CookiePrefixOptions; } & PartitionCookieConstraint import CookieOptions
if (opt?
let cookie: any
.prefix === 'secure') {
(parameter) opt: CookieOptions | undefined
cookie =
(property) prefix?: CookiePrefixOptions | undefined
serialize('__Secure-' +
let cookie: any
name,
(alias) serialize<string>(name: string, value: string, opt?: CookieOptions | undefined): string import serialize
value, {
(parameter) name: string
path: '/', ..
(parameter) value: string
.opt,
(property) path?: string | undefined
secure: true })
(parameter) opt: CookieOptions
} else if (opt?
(property) secure: true
.prefix === 'host') {
(parameter) opt: CookieOptions | undefined
cookie =
(property) prefix?: "host" | undefined
serialize('__Host-' +
let cookie: any
name,
(alias) serialize<string>(name: string, value: string, opt?: CookieOptions | undefined): string import serialize
value, {
(parameter) name: string
...opt,
(parameter) value: string
path: '/',
(parameter) opt: CookieOptions
secure: true,
(property) path?: string | undefined
domain: undefined,
(property) secure: true
}) } else { cookie =
(property) domain?: string | undefined
serialize
let cookie: any
(name,
(alias) serialize<string>(name: string, value: string, opt?: CookieOptions | undefined): string import serialize
value, {
(parameter) name: string
path: '/', ..
(parameter) value: string
.opt })
(property) path?: string | undefined
} c
(parameter) opt: CookieOptions | undefined
.header('set-cookie',
(parameter) c: Context<any, any, {}>
cookie, {
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
append: true })
let cookie: string
} export const setSignedCookie = async (
(property) SetHeadersOptions.append?: boolean | undefined
c:
const setSignedCookie: (c: Context, name: string, value: string, secret: string | BufferSource, opt?: CookieOptions) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
name: string,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
value: string,
(parameter) name: string
secret: string |
(parameter) value: string
BufferSource,
(parameter) secret: string | BufferSource
opt?:
type BufferSource = ArrayBufferView | ArrayBuffer
CookieOptions
(parameter) opt: CookieOptions | undefined
): Promise
(alias) type CookieOptions = { domain?: string; expires?: Date; httpOnly?: boolean; maxAge?: number; path?: string; secure?: boolean; signingSecret?: string; sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none"; partitioned?: boolean; prefix?: CookiePrefixOptions; } & PartitionCookieConstraint import CookieOptions
=> { let cookie
interface Promise<T>
Represents the completion of an asynchronous operationif (opt?
let cookie: any
.prefix === 'secure') {
(parameter) opt: CookieOptions | undefined
cookie = await
(property) prefix?: CookiePrefixOptions | undefined
serializeSigned('__Secure-' +
let cookie: any
name,
(alias) serializeSigned(name: string, value: string, secret: string | BufferSource, opt?: CookieOptions): Promise<string> import serializeSigned
value,
(parameter) name: string
secret, {
(parameter) value: string
path: '/',
(parameter) secret: string | BufferSource
...opt,
(property) path?: string | undefined
secure: true,
(parameter) opt: CookieOptions
}) } else if (opt?
(property) secure: true
.prefix === 'host') {
(parameter) opt: CookieOptions | undefined
cookie = await
(property) prefix?: "host" | undefined
serializeSigned('__Host-' +
let cookie: any
name,
(alias) serializeSigned(name: string, value: string, secret: string | BufferSource, opt?: CookieOptions): Promise<string> import serializeSigned
value,
(parameter) name: string
secret, {
(parameter) value: string
...opt,
(parameter) secret: string | BufferSource
path: '/',
(parameter) opt: CookieOptions
secure: true,
(property) path?: string | undefined
domain: undefined,
(property) secure: true
}) } else { cookie = await
(property) domain?: string | undefined
serializeSigned
let cookie: any
(name,
(alias) serializeSigned(name: string, value: string, secret: string | BufferSource, opt?: CookieOptions): Promise<string> import serializeSigned
value,
(parameter) name: string
secret, {
(parameter) value: string
path: '/', ..
(parameter) secret: string | BufferSource
.opt })
(property) path?: string | undefined
} c
(parameter) opt: CookieOptions | undefined
.header('set-cookie',
(parameter) c: Context<any, any, {}>
cookie, {
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
append: true })
let cookie: string
} export const deleteCookie =
(property) SetHeadersOptions.append?: boolean | undefined
(c:
const deleteCookie: (c: Context, name: string, opt?: CookieOptions) => string | undefined
Context,
(parameter) c: Context<any, any, {}>
name: string,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
opt?:
(parameter) name: string
CookieOptions): string | undefined => {
(parameter) opt: CookieOptions | undefined
const deletedCookie =
(alias) type CookieOptions = { domain?: string; expires?: Date; httpOnly?: boolean; maxAge?: number; path?: string; secure?: boolean; signingSecret?: string; sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none"; partitioned?: boolean; prefix?: CookiePrefixOptions; } & PartitionCookieConstraint import CookieOptions
getCookie
const deletedCookie: string | undefined
(c,
const getCookie: GetCookie (c: Context, key: string) => string | undefined (+2 overloads)
name)
(parameter) c: Context<any, any, {}>
setCookie
(parameter) name: string
(c,
const setCookie: (c: Context, name: string, value: string, opt?: CookieOptions) => void
name, '', { ..
(parameter) c: Context<any, any, {}>
.opt,
(parameter) name: string
maxAge: 0 })
(parameter) opt: CookieOptions | undefined
return deletedCookie
(property) maxAge?: number | undefined
}
const deletedCookie: string | undefined
// provide utility functions for css helper both on server and client export const PSEUDO_GLOBAL_SELECTOR = ':-hono-global'export const isPseudoGlobalSelectorRe = new
const PSEUDO_GLOBAL_SELECTOR: ":-hono-global"
RegExp(`^$
const isPseudoGlobalSelectorRe: RegExp
{PSEUDO_GLOBAL_SELECTOR}{(.*)}$`)
var RegExp: RegExpConstructor new (pattern: RegExp | string, flags?: string) => RegExp (+2 overloads)
export const DEFAULT_STYLE_ID = 'hono-css'
const PSEUDO_GLOBAL_SELECTOR: ":-hono-global"
export const SELECTOR: unique symbol =
const DEFAULT_STYLE_ID: "hono-css"
Symbol()
const SELECTOR: typeof SELECTOR
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export const CLASS_NAME: unique symbol =description
— Description of the new Symbol object.Symbol()
const CLASS_NAME: typeof CLASS_NAME
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export const STYLE_STRING: unique symbol =description
— Description of the new Symbol object.Symbol()
const STYLE_STRING: typeof STYLE_STRING
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export const SELECTORS: unique symbol =description
— Description of the new Symbol object.Symbol()
const SELECTORS: typeof SELECTORS
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export const EXTERNAL_CLASS_NAMES: unique symbol =description
— Description of the new Symbol object.Symbol()
const EXTERNAL_CLASS_NAMES: typeof EXTERNAL_CLASS_NAMES
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
const CSS_ESCAPED: unique symbol =description
— Description of the new Symbol object.Symbol()
const CSS_ESCAPED: typeof CSS_ESCAPED
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export interface CssClassName {description
— Description of the new Symbol object.[SELECTOR]: string
interface CssClassName
[CLASS_NAME]: string
const SELECTOR: typeof SELECTOR
[STYLE_STRING]: string
const CLASS_NAME: typeof CLASS_NAME
[SELECTORS]:
const STYLE_STRING: typeof STYLE_STRING
CssClassName[]
const SELECTORS: typeof SELECTORS
[EXTERNAL_CLASS_NAMES]: string[]
interface CssClassName
} export const IS_CSS_ESCAPED =
const EXTERNAL_CLASS_NAMES: typeof EXTERNAL_CLASS_NAMES
Symbol()
const IS_CSS_ESCAPED: typeof IS_CSS_ESCAPED
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
interface CssEscapedString {description
— Description of the new Symbol object.[CSS_ESCAPED]: string
interface CssEscapedString
} /** * @experimental * `rawCssString` is an experimental feature. * The API might be changed. */ export const rawCssString =
const CSS_ESCAPED: typeof CSS_ESCAPED
const rawCssString: (value: string) => CssEscapedString
@experimental
(value: string):
rawCssString
is an experimental feature. The API might be changed.CssEscapedString => {
(parameter) value: string
return { [CSS_ESCAPED]:
interface CssEscapedString
value,
const CSS_ESCAPED: typeof CSS_ESCAPED
} } /** * Used the goober'code as a reference: * https://github.com/cristianbote/goober/blob/master/src/core/to-hash.js * MIT License, Copyright (c) 2019 Cristian Bote */ const toHash =
(parameter) value: string
(str: string): string => {
const toHash: (str: string) => string
Used the goober'code as a reference: https://github.com/cristianbote/goober/blob/master/src/core/to-hash.js MIT License, Copyright (c) 2019 Cristian Botelet i = 0,
(parameter) str: string
out = 11
let i: number
while (i <
let out: number
str
let i: number
.length) {
(parameter) str: string
out = (101 *
(property) String.length: number
Returns the length of a String object.out +
let out: number
str
let out: number
.charCodeAt
(parameter) str: string
(method) String.charCodeAt(index: number): number
Returns the Unicode value of the character at the specified location.@param
(i++)) >>> 0index
— The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.} return 'css-' + out
let i: number
} const cssStringReStr: string = [
let out: number
'"(?:(?:\\\\[\\s\\S]|[^"\\\\])*)"', // double quoted string // eslint-disable-next-line quotes "'(?:(?:\\\\[\\s\\S]|[^'\\\\])*)'", // single quoted string ].join('|')
const cssStringReStr: string
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
const minifyCssRe:separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.RegExp = new
const minifyCssRe: RegExp
RegExp(
interface RegExp
[ '(' + cssStringReStr + ')', // $1: quoted string
var RegExp: RegExpConstructor new (pattern: RegExp | string, flags?: string) => RegExp (+2 overloads)
'(?:' + [ '^\\s+', // head whitespace '\\/\\*.*?\\*\\/\\s*', // multi-line comment '\\/\\/.*\\n\\s*', // single-line comment '\\s+$', // tail whitespace ].join('|') +
const cssStringReStr: string
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
')', '\\s*;\\s*(}|$)\\s*', // $2: trailing semicolon '\\s*([{};:,])\\s*', // $3: whitespace around { } : , ; '(\\s)\\s+', // $4: 2+ spaces ].join('|'),separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
'g' ) export const minify =separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.(css: string): string => {
const minify: (css: string) => string
return css
(parameter) css: string
.replace
(parameter) css: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string (+3 overloads)
Replaces text in a string, using an object that supports replacement within a string.@param
searchValue
— A object can search for and replace matches within a string.@param
(minifyCssRe,replacer
— A function that returns the replacement text.(_,
const minifyCssRe: RegExp
$1,
(parameter) _: string
$2,
(parameter) $1: any
$3,
(parameter) $2: any
$4) =>
(parameter) $3: any
$1 ||
(parameter) $4: any
$2 ||
(parameter) $1: any
$3 ||
(parameter) $2: any
$4 || '')
(parameter) $3: any
} type CssVariableBasicType =
(parameter) $4: any
| CssClassName
type CssVariableBasicType = string | number | boolean | CssEscapedString | CssClassName | null | undefined
| CssEscapedString
interface CssClassName
| string | number | boolean | null | undefined type CssVariableAsyncType =
interface CssEscapedString
Promise
type CssVariableAsyncType = Promise<CssVariableBasicType>
<CssVariableBasicType>
interface Promise<T>
Represents the completion of an asynchronous operationtype CssVariableArrayType =
type CssVariableBasicType = string | number | boolean | CssEscapedString | CssClassName | null | undefined
(CssVariableBasicType |
type CssVariableArrayType = (CssVariableBasicType | CssVariableAsyncType)[]
CssVariableAsyncType)[]
type CssVariableBasicType = string | number | boolean | CssEscapedString | CssClassName | null | undefined
export type CssVariableType =
type CssVariableAsyncType = Promise<CssVariableBasicType>
CssVariableBasicType |
type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType
CssVariableAsyncType |
type CssVariableBasicType = string | number | boolean | CssEscapedString | CssClassName | null | undefined
CssVariableArrayType
type CssVariableAsyncType = Promise<CssVariableBasicType>
export const buildStyleString = (
type CssVariableArrayType = (CssVariableBasicType | CssVariableAsyncType)[]
strings:
const buildStyleString: (strings: TemplateStringsArray, values: CssVariableType[]) => [string, string, CssClassName[], string[]]
TemplateStringsArray,
(parameter) strings: TemplateStringsArray
values:
interface TemplateStringsArray
CssVariableType[]
(parameter) values: CssVariableType[]
): [string, string, CssClassName[], string[]] => {
type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType
const selectors:
interface CssClassName
CssClassName[] = []
const selectors: CssClassName[]
const externalClassNames: string[] = []
interface CssClassName
const label =
const externalClassNames: string[]
strings[0]
const label: string
.match(/^\s*\/\*(.*?)\*\//)?.[1] || ''
(parameter) strings: TemplateStringsArray
(method) String.match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null (+1 overload)
Matches a string or an object that supports being matched against, and returns an array containing the results of that search, or null if no matches are found.@param
let styleString = ''matcher
— An object that supports being matched against.for (let i = 0,
let styleString: string
len =
let i: number
strings
let len: number
.length;
(parameter) strings: TemplateStringsArray
i <
(property) ReadonlyArray<string>.length: number
Gets the length of the array. This is a number one higher than the highest element defined in an array.len;
let i: number
i++) {
let len: number
styleString +=
let i: number
strings
let styleString: string
[i]
(parameter) strings: TemplateStringsArray
let vArray =
let i: number
values
let vArray: CssVariableType
[i]
(parameter) values: CssVariableType[]
if (typeof vArray === 'boolean' ||
let i: number
vArray === null ||
let vArray: CssVariableType
vArray === undefined) {
let vArray: string | number | CssEscapedString | CssClassName | CssVariableAsyncType | CssVariableArrayType | null | undefined
continue } if (!Array
let vArray: string | number | CssEscapedString | CssClassName | CssVariableAsyncType | CssVariableArrayType | undefined
.isArray
var Array: ArrayConstructor
(vArray)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
vArray =
let vArray: string | number | CssEscapedString | CssClassName | CssVariableAsyncType | CssVariableArrayType
[vArray]
let vArray: CssVariableType
} for (let j = 0,
let vArray: string | number | CssEscapedString | CssClassName | CssVariableAsyncType
len =
let j: number
vArray
let len: number
.length;
let vArray: CssVariableArrayType
j <
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.len;
let j: number
j++) {
let len: number
let value =
let j: number
vArray
let value: CssVariableBasicType | CssVariableAsyncType
[j]
let vArray: CssVariableArrayType
if (typeof value === 'boolean' ||
let j: number
value === null ||
let value: CssVariableBasicType | CssVariableAsyncType
value === undefined) {
let value: string | number | CssEscapedString | CssClassName | CssVariableAsyncType | null | undefined
continue } if (typeof value === 'string') {
let value: string | number | CssEscapedString | CssClassName | CssVariableAsyncType | undefined
if (/([\\"'\/])/.test
let value: string | number | CssEscapedString | CssClassName | CssVariableAsyncType
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
(value)) {string
— String on which to perform the search.styleString +=
let value: string
value
let styleString: string
.replace(/([\\"']|(?<=<)\/)/g, '\\$1')
let value: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
} else { styleString +=replaceValue
— The replacement text.value
let styleString: string
} } else if (typeof value === 'number') {
let value: string
styleString +=
let value: number | CssEscapedString | CssClassName | CssVariableAsyncType
value
let styleString: string
} else if ((value as
let value: number
CssEscapedString)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
[CSS_ESCAPED]) {
interface CssEscapedString
styleString +=
const CSS_ESCAPED: typeof CSS_ESCAPED
(value as
let styleString: string
CssEscapedString)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
[CSS_ESCAPED]
interface CssEscapedString
} else if ((value as
const CSS_ESCAPED: typeof CSS_ESCAPED
CssClassName)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
[CLASS_NAME]
interface CssClassName
.startsWith('@keyframes ')) {
const CLASS_NAME: typeof CLASS_NAME
selectors
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false..push
const selectors: CssClassName[]
(method) Array<CssClassName>.push(...items: CssClassName[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(value asitems
— New elements to add to the array.CssClassName)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
styleString += ` ${
interface CssClassName
(value as
let styleString: string
CssClassName)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
[CLASS_NAME]
interface CssClassName
.substring(11)} `
const CLASS_NAME: typeof CLASS_NAME
(method) String.substring(start: number, end?: number): string
Returns the substring at the specified location within a String object.@param
start
— The zero-based index number indicating the beginning of the substring.@param
} else { if (stringsend
Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. If end is omitted, the characters from start through the end of the original string are returned.[i + 1]?
(parameter) strings: TemplateStringsArray
.match(/^\s*{/)) {
let i: number
(method) String.match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null (+1 overload)
Matches a string or an object that supports being matched against, and returns an array containing the results of that search, or null if no matches are found.@param
// assume this value is a class name selectorsmatcher
— An object that supports being matched against..push
const selectors: CssClassName[]
(method) Array<CssClassName>.push(...items: CssClassName[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(value asitems
— New elements to add to the array.CssClassName)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
value = `.${
interface CssClassName
(value as
let value: CssVariableBasicType | CssVariableAsyncType
CssClassName)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
[CLASS_NAME]}`
interface CssClassName
} else { selectors
const CLASS_NAME: typeof CLASS_NAME
.push(...
const selectors: CssClassName[]
(method) Array<CssClassName>.push(...items: CssClassName[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(value asitems
— New elements to add to the array.CssClassName)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
[SELECTORS])
interface CssClassName
externalClassNames
const SELECTORS: typeof SELECTORS
.push(...
const externalClassNames: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(value asitems
— New elements to add to the array.CssClassName)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
[EXTERNAL_CLASS_NAMES])
interface CssClassName
value =
const EXTERNAL_CLASS_NAMES: typeof EXTERNAL_CLASS_NAMES
(value as
let value: CssVariableBasicType | CssVariableAsyncType
CssClassName)
let value: CssEscapedString | CssClassName | CssVariableAsyncType
[STYLE_STRING]
interface CssClassName
const valueLen =
const STYLE_STRING: typeof STYLE_STRING
value
const valueLen: number
.length
let value: string
if (valueLen > 0) {
(property) String.length: number
Returns the length of a String object.const lastChar =
const valueLen: number
value
const lastChar: string
[valueLen - 1]
let value: string
if (lastChar !== ';' &&
const valueLen: number
lastChar !== '}') {
const lastChar: string
value += ';'
const lastChar: string
} } } styleString += `$
let value: string
{value || ''}`
let styleString: string
} } } return [label,
let value: string
minify
const label: string
(styleString),
const minify: (css: string) => string
selectors,
let styleString: string
externalClassNames]
const selectors: CssClassName[]
} export const cssCommon = (
const externalClassNames: string[]
strings:
const cssCommon: (strings: TemplateStringsArray, values: CssVariableType[]) => CssClassName
TemplateStringsArray,
(parameter) strings: TemplateStringsArray
values:
interface TemplateStringsArray
CssVariableType[]
(parameter) values: CssVariableType[]
): CssClassName => {
type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType
let [label,
interface CssClassName
thisStyleString,
let label: string
selectors,
let thisStyleString: string
externalClassNames] =
let selectors: CssClassName[]
buildStyleString
let externalClassNames: string[]
(strings,
const buildStyleString: (strings: TemplateStringsArray, values: CssVariableType[]) => [string, string, CssClassName[], string[]]
values)
(parameter) strings: TemplateStringsArray
const isPseudoGlobal =
(parameter) values: CssVariableType[]
isPseudoGlobalSelectorRe
const isPseudoGlobal: RegExpExecArray | null
.exec
const isPseudoGlobalSelectorRe: RegExp
(method) RegExp.exec(string: string): RegExpExecArray | null
Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.@param
(thisStyleString)string
— The String object or string literal on which to perform the search.if (isPseudoGlobal) {
let thisStyleString: string
thisStyleString =
const isPseudoGlobal: RegExpExecArray | null
isPseudoGlobal[1]
let thisStyleString: string
} const selector =
const isPseudoGlobal: RegExpExecArray
(isPseudoGlobal ?
const selector: string
PSEUDO_GLOBAL_SELECTOR : '') +
const isPseudoGlobal: RegExpExecArray | null
toHash
const PSEUDO_GLOBAL_SELECTOR: ":-hono-global"
(label +
const toHash: (str: string) => string
Used the goober'code as a reference: https://github.com/cristianbote/goober/blob/master/src/core/to-hash.js MIT License, Copyright (c) 2019 Cristian BotethisStyleString)
let label: string
const className = (
let thisStyleString: string
isPseudoGlobal ?
const className: string
selectors
const isPseudoGlobal: RegExpExecArray | null
.map(
let selectors: CssClassName[]
(method) Array<CssClassName>.map<string>(callbackfn: (value: CssClassName, index: number, array: CssClassName[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(s) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.s
(parameter) s: CssClassName
[CLASS_NAME]) :
(parameter) s: CssClassName
[selector, ..
const CLASS_NAME: typeof CLASS_NAME
.externalClassNames]
const selector: string
).join(' ')
let externalClassNames: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
return { [SELECTOR]:separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.selector,
const SELECTOR: typeof SELECTOR
[CLASS_NAME]:
const selector: string
className,
const CLASS_NAME: typeof CLASS_NAME
[STYLE_STRING]:
const className: string
thisStyleString,
const STYLE_STRING: typeof STYLE_STRING
[SELECTORS]:
let thisStyleString: string
selectors,
const SELECTORS: typeof SELECTORS
[EXTERNAL_CLASS_NAMES]:
let selectors: CssClassName[]
externalClassNames,
const EXTERNAL_CLASS_NAMES: typeof EXTERNAL_CLASS_NAMES
} } export const cxCommon = (
let externalClassNames: string[]
args: (string | boolean | null | undefined |
const cxCommon: (args: (string | boolean | null | undefined | CssClassName)[]) => (string | boolean | null | undefined | CssClassName)[]
CssClassName)[]
(parameter) args: (string | boolean | CssClassName | null | undefined)[]
): (string | boolean | null | undefined | CssClassName)[] => {
interface CssClassName
for (let i = 0,
interface CssClassName
len =
let i: number
args
let len: number
.length;
(parameter) args: (string | boolean | CssClassName | null | undefined)[]
i <
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.len;
let i: number
i++) {
let len: number
const arg =
let i: number
args
const arg: string | boolean | CssClassName | null | undefined
[i]
(parameter) args: (string | boolean | CssClassName | null | undefined)[]
if (typeof arg === 'string') {
let i: number
args
const arg: string | boolean | CssClassName | null | undefined
[i] = {
(parameter) args: (string | boolean | CssClassName | null | undefined)[]
[SELECTOR]: '',
let i: number
[CLASS_NAME]: '',
const SELECTOR: typeof SELECTOR
[STYLE_STRING]: '',
const CLASS_NAME: typeof CLASS_NAME
[SELECTORS]: [],
const STYLE_STRING: typeof STYLE_STRING
[EXTERNAL_CLASS_NAMES]:
const SELECTORS: typeof SELECTORS
[arg],
const EXTERNAL_CLASS_NAMES: typeof EXTERNAL_CLASS_NAMES
} } } return args
const arg: string
} export const keyframesCommon = (
(parameter) args: (string | boolean | CssClassName | null | undefined)[]
strings:
const keyframesCommon: (strings: TemplateStringsArray, ...values: CssVariableType[]) => CssClassName
TemplateStringsArray,
(parameter) strings: TemplateStringsArray
...values:
interface TemplateStringsArray
CssVariableType[]
(parameter) values: CssVariableType[]
): CssClassName => {
type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType
const [label,
interface CssClassName
styleString] =
const label: string
buildStyleString
const styleString: string
(strings,
const buildStyleString: (strings: TemplateStringsArray, values: CssVariableType[]) => [string, string, CssClassName[], string[]]
values)
(parameter) strings: TemplateStringsArray
return { [SELECTOR]: '',
(parameter) values: CssVariableType[]
[CLASS_NAME]: `@keyframes $
const SELECTOR: typeof SELECTOR
{toHash
const CLASS_NAME: typeof CLASS_NAME
(label +
const toHash: (str: string) => string
Used the goober'code as a reference: https://github.com/cristianbote/goober/blob/master/src/core/to-hash.js MIT License, Copyright (c) 2019 Cristian BotestyleString)}`,
const label: string
[STYLE_STRING]:
const styleString: string
styleString,
const STYLE_STRING: typeof STYLE_STRING
[SELECTORS]: [],
const styleString: string
[EXTERNAL_CLASS_NAMES]: [],
const SELECTORS: typeof SELECTORS
} } type ViewTransitionType = {
const EXTERNAL_CLASS_NAMES: typeof EXTERNAL_CLASS_NAMES
(strings:
type ViewTransitionType = { (strings: TemplateStringsArray, values: CssVariableType[]): CssClassName; (content: CssClassName): CssClassName; (): CssClassName; }
TemplateStringsArray,
(parameter) strings: TemplateStringsArray
values:
interface TemplateStringsArray
CssVariableType[]):
(parameter) values: CssVariableType[]
CssClassName
type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType
(content:
interface CssClassName
CssClassName):
(parameter) content: CssClassName
CssClassName
interface CssClassName
(): CssClassName
interface CssClassName
} let viewTransitionNameIndex = 0
interface CssClassName
export const viewTransitionCommon:
let viewTransitionNameIndex: number
ViewTransitionType = ((
const viewTransitionCommon: ViewTransitionType
strings:
type ViewTransitionType = { (strings: TemplateStringsArray, values: CssVariableType[]): CssClassName; (content: CssClassName): CssClassName; (): CssClassName; }
TemplateStringsArray |
(parameter) strings: TemplateStringsArray | CssClassName | undefined
CssClassName | undefined,
interface TemplateStringsArray
values:
interface CssClassName
CssVariableType[]
(parameter) values: CssVariableType[]
): CssClassName => {
type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType
if (!strings) {
interface CssClassName
// eslint-disable-next-line @typescript-eslint/no-explicit-any strings = [`/* h-v-t $
(parameter) strings: TemplateStringsArray | CssClassName | undefined
{viewTransitionNameIndex++} */`] as any
(parameter) strings: TemplateStringsArray | CssClassName | undefined
} const content =
let viewTransitionNameIndex: number
Array
const content: CssClassName
.isArray
var Array: ArrayConstructor
(strings)
(method) ArrayConstructor.isArray(arg: any): arg is any[]
? cssCommon
(parameter) strings: TemplateStringsArray | CssClassName | undefined
(strings as
const cssCommon: (strings: TemplateStringsArray, values: CssVariableType[]) => CssClassName
TemplateStringsArray,
(parameter) strings: (TemplateStringsArray & any[]) | (CssClassName & any[])
values)
interface TemplateStringsArray
: (strings as
(parameter) values: CssVariableType[]
CssClassName)
(parameter) strings: TemplateStringsArray | CssClassName | undefined
const transitionName =
interface CssClassName
content
const transitionName: string
[CLASS_NAME]
const content: CssClassName
// eslint-disable-next-line @typescript-eslint/no-explicit-any const res =
const CLASS_NAME: typeof CLASS_NAME
cssCommon(['view-transition-name:', ''] as any,
const res: CssClassName
[transitionName])
const cssCommon: (strings: TemplateStringsArray, values: CssVariableType[]) => CssClassName
content
const transitionName: string
[CLASS_NAME] =
const content: CssClassName
PSEUDO_GLOBAL_SELECTOR +
const CLASS_NAME: typeof CLASS_NAME
content
const PSEUDO_GLOBAL_SELECTOR: ":-hono-global"
[CLASS_NAME]
const content: CssClassName
content
const CLASS_NAME: typeof CLASS_NAME
[STYLE_STRING] =
const content: CssClassName
content
const STYLE_STRING: typeof STYLE_STRING
[STYLE_STRING]
const content: CssClassName
.replace(
const STYLE_STRING: typeof STYLE_STRING
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
/(?<=::view-transition(?:[a-z-]*)\()(?=\))/g, transitionNamereplaceValue
— The replacement text.) res
const transitionName: string
[CLASS_NAME] =
const res: CssClassName
res
const CLASS_NAME: typeof CLASS_NAME
[SELECTOR] =
const res: CssClassName
transitionName
const SELECTOR: typeof SELECTOR
res
const transitionName: string
[SELECTORS] = [..
const res: CssClassName
.content
const SELECTORS: typeof SELECTORS
[SELECTORS],
const content: CssClassName
content]
const SELECTORS: typeof SELECTORS
return res
const content: CssClassName
}) as ViewTransitionType
const res: CssClassName
type ViewTransitionType = { (strings: TemplateStringsArray, values: CssVariableType[]): CssClassName; (content: CssClassName): CssClassName; (): CssClassName; }
/** * @module * css Helper for Hono. */ import { raw } from '../../helper/html' import { DOM_RENDERER } from '../../jsx/constants' import { createCssJsxDomObjects } from '../../jsx/dom/css' import type { HtmlEscapedCallback, HtmlEscapedString } from '../../utils/html' import type { CssClassName as CssClassNameCommon, CssVariableType } from './common' import { CLASS_NAME, DEFAULT_STYLE_ID, PSEUDO_GLOBAL_SELECTOR, SELECTOR, SELECTORS, STYLE_STRING, cssCommon, cxCommon, keyframesCommon, viewTransitionCommon, } from './common' export { rawCssString } from './common'
(alias) const rawCssString: (value: string) => CssEscapedString export rawCssString
@experimental
type CssClassName =
rawCssString
is an experimental feature. The API might be changed.HtmlEscapedString &
type CssClassName = string & HtmlEscaped & CssClassNameCommon
CssClassNameCommon
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
type usedClassNameData = [
(alias) interface CssClassNameCommon import CssClassNameCommon
Record
type usedClassNameData = [Record<string, string>, Record<string, true>]
, // class name to add Record
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T// class name already added ] interface CssType {
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T(strings:
interface CssType
TemplateStringsArray, ..
(parameter) strings: TemplateStringsArray
.values:
interface TemplateStringsArray
CssVariableType[]):
(parameter) values: CssVariableType[]
Promise
(alias) type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType import CssVariableType
} interface CxType {
interface Promise<T>
Represents the completion of an asynchronous operation( ...args:
interface CxType
(CssClassName |
(parameter) args: (string | boolean | Promise<string> | CssClassName | null | undefined)[]
Promise
type CssClassName = string & HtmlEscaped & CssClassNameCommon
| string | boolean | null | undefined)[] ): Promise
interface Promise<T>
Represents the completion of an asynchronous operation} interface KeyframesType {
interface Promise<T>
Represents the completion of an asynchronous operation(strings:
interface KeyframesType
TemplateStringsArray, ..
(parameter) strings: TemplateStringsArray
.values:
interface TemplateStringsArray
CssVariableType[]):
(parameter) values: CssVariableType[]
CssClassNameCommon
(alias) type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType import CssVariableType
} interface ViewTransitionType {
(alias) interface CssClassNameCommon import CssClassNameCommon
(strings:
interface ViewTransitionType
TemplateStringsArray, ..
(parameter) strings: TemplateStringsArray
.values:
interface TemplateStringsArray
CssVariableType[]):
(parameter) values: CssVariableType[]
Promise
(alias) type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType import CssVariableType
(content:
interface Promise<T>
Represents the completion of an asynchronous operationPromise
(parameter) content: Promise<string>
): Promise
interface Promise<T>
Represents the completion of an asynchronous operation(): Promise
interface Promise<T>
Represents the completion of an asynchronous operation} interface StyleType {
interface Promise<T>
Represents the completion of an asynchronous operation(args?: {
interface StyleType
children?:
(parameter) args: { children?: Promise<string>; } | undefined
Promise
(property) children?: Promise<string> | undefined
}): HtmlEscapedString
interface Promise<T>
Represents the completion of an asynchronous operation} /** * @experimental * `createCssContext` is an experimental feature. * The API might be changed. */ export const createCssContext = ({
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
const createCssContext: ({ id }: { id: Readonly<string>; }) => DefaultContextType
@experimental
id }: {
createCssContext
is an experimental feature. The API might be changed.id:
(parameter) id: string
Readonly
(property) id: string
}): DefaultContextType => {
type Readonly<T> = { readonly [P in keyof T]: T[P]; }
Make all properties in T readonlyconst [cssJsxDomObject,
interface DefaultContextType
StyleRenderToDom] =
const cssJsxDomObject: { toString(this: CssClassNameCommon): string; }
createCssJsxDomObjects({
const StyleRenderToDom: FC<PropsWithChildren<void>>
id })
(alias) createCssJsxDomObjects(args: { id: Readonly<string>; }): readonly [{ toString(this: CssClassNameCommon): string; }, FC<PropsWithChildren<void>>] import createCssJsxDomObjects
const contextMap:
(property) id: string
WeakMap usedClassNameData> = new
const contextMap: WeakMap<object, usedClassNameData>
WeakMap()
type usedClassNameData = [Record<string, string>, Record<string, true>]
const replaceStyleRe = new
var WeakMap: WeakMapConstructor new <object, usedClassNameData>(entries?: readonly (readonly [object, usedClassNameData])[] | null | undefined) => WeakMap<object, usedClassNameData> (+1 overload)
RegExp(`()`)
const replaceStyleRe: RegExp
const newCssClassNameObject =
(parameter) id: string
(cssClassName:
const newCssClassNameObject: (cssClassName: CssClassNameCommon) => Promise<string>
CssClassNameCommon):
(parameter) cssClassName: CssClassNameCommon
Promise
(alias) interface CssClassNameCommon import CssClassNameCommon
=> { const appendStyle:
interface Promise<T>
Represents the completion of an asynchronous operationHtmlEscapedCallback = ({
const appendStyle: HtmlEscapedCallback
buffer,
(alias) type HtmlEscapedCallback = (opts: HtmlEscapedCallbackOpts) => Promise<string> | undefined import HtmlEscapedCallback
context }):
(parameter) buffer: [string] | undefined
Promise
(parameter) context: object
| undefined => { const [toAdd,
interface Promise<T>
Represents the completion of an asynchronous operationadded] =
const toAdd: Record<string, string>
contextMap
const added: Record<string, true>
.get
const contextMap: WeakMap<object, usedClassNameData>
(method) WeakMap<object, usedClassNameData>.get(key: object): usedClassNameData | undefined
@returns — a specified element.
(context) asusedClassNameData
(parameter) context: object
const names =
type usedClassNameData = [Record<string, string>, Record<string, true>]
Object
const names: string[]
.keys
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.keys(o: {}): string[] (+1 overload)
Returns the names of the enumerable string properties and methods of an object.@param
(toAdd)o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.if (!names
const toAdd: Record<string, string>
.length) {
const names: string[]
return } let stylesStr = ''
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.names
let stylesStr: string
.forEach(
const names: string[]
(method) Array<string>.forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(className) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.added
(parameter) className: string
[className] = true
const added: Record<string, true>
stylesStr +=
(parameter) className: string
className
let stylesStr: string
.startsWith
(parameter) className: string
(PSEUDO_GLOBAL_SELECTOR)
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.? toAdd
(alias) const PSEUDO_GLOBAL_SELECTOR: ":-hono-global" import PSEUDO_GLOBAL_SELECTOR
[className]
const toAdd: Record<string, string>
: `${className[0] === '@' ? '' : '.'}$
(parameter) className: string
{className}{$
(parameter) className: string
{toAdd
(parameter) className: string
[className]}}`
const toAdd: Record<string, string>
}) contextMap
(parameter) className: string
.set
const contextMap: WeakMap<object, usedClassNameData>
(method) WeakMap<object, usedClassNameData>.set(key: object, value: usedClassNameData): WeakMap<object, usedClassNameData>
Adds a new element with a specified key and value.@param
(context, [{},key
— Must be an object or symbol.added])
(parameter) context: object
if (buffer &&
const added: Record<string, true>
replaceStyleRe
(parameter) buffer: [string] | undefined
.test
const replaceStyleRe: RegExp
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
(buffer[0])) {string
— String on which to perform the search.buffer[0] =
(parameter) buffer: [string]
buffer[0]
(parameter) buffer: [string]
.replace
(parameter) buffer: [string]
(method) String.replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string (+3 overloads)
Replaces text in a string, using an object that supports replacement within a string.@param
searchValue
— A object can search for and replace matches within a string.@param
(replaceStyleRe,replacer
— A function that returns the replacement text.(_,
const replaceStyleRe: RegExp
pre,
(parameter) _: string
post) => `$
(parameter) pre: any
{pre}$
(parameter) post: any
{stylesStr}$
(parameter) pre: any
{post}`)
let stylesStr: string
return } const appendStyleScript = `` if (buffer) {
(parameter) post: any
buffer[0] = `$
(parameter) buffer: [string] | undefined
{appendStyleScript}$
(parameter) buffer: [string]
{buffer[0]}`
const appendStyleScript: string
return } return Promise
(parameter) buffer: [string]
.resolve
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
(method) PromiseConstructor.resolve<string>(value: string): Promise<string> (+2 overloads)
Creates a new resolved promise for the provided value.@param
value
— A promise.@returns — A promise whose internal state matches the provided promise.
(appendStyleScript)} const addClassNameToContext:
const appendStyleScript: string
HtmlEscapedCallback = ({
const addClassNameToContext: HtmlEscapedCallback
context }) => {
(alias) type HtmlEscapedCallback = (opts: HtmlEscapedCallbackOpts) => Promise<string> | undefined import HtmlEscapedCallback
if (!contextMap
(parameter) context: object
.get
const contextMap: WeakMap<object, usedClassNameData>
(method) WeakMap<object, usedClassNameData>.get(key: object): usedClassNameData | undefined
@returns — a specified element.
(context)) {contextMap
(parameter) context: object
.set
const contextMap: WeakMap<object, usedClassNameData>
(method) WeakMap<object, usedClassNameData>.set(key: object, value: usedClassNameData): WeakMap<object, usedClassNameData>
Adds a new element with a specified key and value.@param
(context, [{}, {}])key
— Must be an object or symbol.} const [toAdd,
(parameter) context: object
added] =
const toAdd: Record<string, string>
contextMap
const added: Record<string, true>
.get
const contextMap: WeakMap<object, usedClassNameData>
(method) WeakMap<object, usedClassNameData>.get(key: object): usedClassNameData | undefined
@returns — a specified element.
(context) asusedClassNameData
(parameter) context: object
let allAdded = true
type usedClassNameData = [Record<string, string>, Record<string, true>]
if (!added
let allAdded: boolean
[cssClassName
const added: Record<string, true>
[SELECTOR]]) {
(parameter) cssClassName: CssClassNameCommon
allAdded = false
(alias) const SELECTOR: typeof SELECTOR import SELECTOR
toAdd
let allAdded: boolean
[cssClassName
const toAdd: Record<string, string>
[SELECTOR]] =
(parameter) cssClassName: CssClassNameCommon
cssClassName
(alias) const SELECTOR: typeof SELECTOR import SELECTOR
[STYLE_STRING]
(parameter) cssClassName: CssClassNameCommon
} cssClassName
(alias) const STYLE_STRING: typeof STYLE_STRING import STYLE_STRING
[SELECTORS]
(parameter) cssClassName: CssClassNameCommon
.forEach(
(alias) const SELECTORS: typeof SELECTORS import SELECTORS
(method) Array<CssClassName>.forEach(callbackfn: (value: CssClassNameCommon, index: number, array: CssClassNameCommon[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
({ [CLASS_NAME]:thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.className,
(alias) const CLASS_NAME: typeof CLASS_NAME import CLASS_NAME
[STYLE_STRING]:
(parameter) className: string
styleString }) => {
(alias) const STYLE_STRING: typeof STYLE_STRING import STYLE_STRING
if (!added
(parameter) styleString: string
[className]) {
const added: Record<string, true>
allAdded = false
(parameter) className: string
toAdd
let allAdded: boolean
[className] =
const toAdd: Record<string, string>
styleString
(parameter) className: string
} } ) if (allAdded) {
(parameter) styleString: string
return } return Promise
let allAdded: boolean
.resolve
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
(method) PromiseConstructor.resolve<HtmlEscapedString>(value: HtmlEscapedString): Promise<HtmlEscapedString> (+2 overloads)
Creates a new resolved promise for the provided value.@param
value
— A promise.@returns — A promise whose internal state matches the provided promise.
(raw('',[appendStyle]))
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
} const className = new
const appendStyle: HtmlEscapedCallback
String
const className: CssClassName
(cssClassName
var String: StringConstructor new (value?: any) => String
Allows manipulation and formatting of text strings and determination and location of substrings within strings.[CLASS_NAME]) as
(parameter) cssClassName: CssClassNameCommon
CssClassName
(alias) const CLASS_NAME: typeof CLASS_NAME import CLASS_NAME
Object
type CssClassName = string & HtmlEscaped & CssClassNameCommon
.assign
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.assign<CssClassName, CssClassNameCommon>(target: CssClassName, source: CssClassNameCommon): string & HtmlEscaped & CssClassNameCommon (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.@param
target
— The target object to copy to.@param
(className,source
— The source object from which to copy properties.cssClassName)
const className: CssClassName
;(className as
(parameter) cssClassName: CssClassNameCommon
HtmlEscapedString)
const className: CssClassName
.isEscaped = true
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
;(className as
(property) isEscaped: true
HtmlEscapedString)
const className: CssClassName
.callbacks =
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
[addClassNameToContext]
(property) callbacks?: HtmlEscapedCallback[] | undefined
const promise =
const addClassNameToContext: HtmlEscapedCallback
Promise
const promise: Promise<CssClassName>
.resolve
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
(method) PromiseConstructor.resolve<CssClassName>(value: CssClassName): Promise<CssClassName> (+2 overloads)
Creates a new resolved promise for the provided value.@param
value
— A promise.@returns — A promise whose internal state matches the provided promise.
(className)Object
const className: CssClassName
.assign
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.assign<Promise<CssClassName>, CssClassNameCommon>(target: Promise<CssClassName>, source: CssClassNameCommon): Promise<...> & CssClassNameCommon (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.@param
target
— The target object to copy to.@param
(promise,source
— The source object from which to copy properties.cssClassName)
const promise: Promise<CssClassName>
promise
(parameter) cssClassName: CssClassNameCommon
.toString =
const promise: Promise<CssClassName>
cssJsxDomObject
(method) Object.toString(): string
Returns a string representation of an object..toString
const cssJsxDomObject: { toString(this: CssClassNameCommon): string; }
return promise
(method) toString(this: CssClassNameCommon): string
} const css:
const promise: Promise<CssClassName>
CssType =
const css: CssType
(strings, ..
interface CssType
.values) => {
(parameter) strings: TemplateStringsArray
return newCssClassNameObject
(parameter) values: CssVariableType[]
(cssCommon
const newCssClassNameObject: (cssClassName: CssClassNameCommon) => Promise<string>
(strings,
(alias) cssCommon(strings: TemplateStringsArray, values: CssVariableType[]): CssClassNameCommon import cssCommon
values))
(parameter) strings: TemplateStringsArray
} const cx:
(parameter) values: CssVariableType[]
CxType = (..
const cx: CxType
.args) => {
interface CxType
// eslint-disable-next-line @typescript-eslint/no-explicit-any args =
(parameter) args: (string | boolean | Promise<string> | CssClassName | null | undefined)[]
cxCommon
(parameter) args: (string | boolean | Promise<string> | CssClassName | null | undefined)[]
(args as any) as any
(alias) cxCommon(args: (string | boolean | null | undefined | CssClassNameCommon)[]): (string | boolean | null | undefined | CssClassNameCommon)[] import cxCommon
// eslint-disable-next-line @typescript-eslint/no-explicit-any return css
(parameter) args: (string | boolean | Promise<string> | CssClassName | null | undefined)[]
(Array
const css: CssType (strings: TemplateStringsArray, ...values: CssVariableType[]) => Promise<string>
(args
var Array: ArrayConstructor (arrayLength?: number) => any[] (+2 overloads)
.length)
(parameter) args: (string | boolean | Promise<string> | CssClassName | null | undefined)[]
.fill('') as any, ..
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
(method) Array<any>.fill(value: any, start?: number, end?: number): any[]
Changes all array elements fromstart
toend
index to a staticvalue
and returns the modified array@param
value
— value to fill array section with@param
start
index to start filling the array at. If start is negative, it is treated as length+start where length is the length of the array.@param
.args)end
index to stop filling the array at. If end is negative, it is treated as length+end.} const keyframes =
(parameter) args: (string | boolean | Promise<string> | CssClassName | null | undefined)[]
keyframesCommon
const keyframes: (strings: TemplateStringsArray, ...values: CssVariableType[]) => CssClassNameCommon
const viewTransition:
(alias) const keyframesCommon: (strings: TemplateStringsArray, ...values: CssVariableType[]) => CssClassNameCommon import keyframesCommon
ViewTransitionType = ((
const viewTransition: ViewTransitionType
strings:
interface ViewTransitionType
TemplateStringsArray |
(parameter) strings: Promise<string> | TemplateStringsArray | undefined
Promise
interface TemplateStringsArray
| undefined, ...values:
interface Promise<T>
Represents the completion of an asynchronous operationCssVariableType[]
(parameter) values: CssVariableType[]
) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any return newCssClassNameObject
(alias) type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType import CssVariableType
(viewTransitionCommon
const newCssClassNameObject: (cssClassName: CssClassNameCommon) => Promise<string>
(strings as any,
(alias) viewTransitionCommon(strings: TemplateStringsArray, values: CssVariableType[]): CssClassNameCommon (+2 overloads) import viewTransitionCommon
values))
(parameter) strings: Promise<string> | TemplateStringsArray | undefined
}) as ViewTransitionType
(parameter) values: CssVariableType[]
const Style:
interface ViewTransitionType
StyleType = ({
const Style: StyleType
children } = {}) =>
interface StyleType
children
(parameter) children: Promise<string> | undefined
? raw(``)
(parameter) children: Promise<string> | undefined
: raw(``)
(alias) const STYLE_STRING: typeof STYLE_STRING import STYLE_STRING
// eslint-disable-next-line @typescript-eslint/no-explicit-any ;(Style as any)
(parameter) id: string
[DOM_RENDERER] =
const Style: StyleType
StyleRenderToDom
(alias) const DOM_RENDERER: typeof DOM_RENDERER import DOM_RENDERER
return { css,
const StyleRenderToDom: FC<PropsWithChildren<void>>
cx,
(property) DefaultContextType.css: CssType
keyframes,
(property) DefaultContextType.cx: CxType
viewTransition:
(property) DefaultContextType.keyframes: KeyframesType
viewTransition as
(property) DefaultContextType.viewTransition: ViewTransitionType
ViewTransitionType,
const viewTransition: ViewTransitionType
Style,
interface ViewTransitionType
} } interface DefaultContextType {
(property) DefaultContextType.Style: StyleType
css:
interface DefaultContextType
CssType
(property) DefaultContextType.css: CssType
cx:
interface CssType
CxType
(property) DefaultContextType.cx: CxType
keyframes:
interface CxType
KeyframesType
(property) DefaultContextType.keyframes: KeyframesType
viewTransition:
interface KeyframesType
ViewTransitionType
(property) DefaultContextType.viewTransition: ViewTransitionType
Style:
interface ViewTransitionType
StyleType
(property) DefaultContextType.Style: StyleType
} const defaultContext:
interface StyleType
DefaultContextType =
const defaultContext: DefaultContextType
createCssContext({
interface DefaultContextType
const createCssContext: ({ id }: { id: Readonly<string>; }) => DefaultContextType
@experimental
id:
createCssContext
is an experimental feature. The API might be changed.DEFAULT_STYLE_ID,
(property) id: string
}) /** * @experimental * `css` is an experimental feature. * The API might be changed. */ export const css =
(alias) const DEFAULT_STYLE_ID: "hono-css" import DEFAULT_STYLE_ID
const css: CssType
@experimental
defaultContext
css
is an experimental feature. The API might be changed..css
const defaultContext: DefaultContextType
/** * @experimental * `cx` is an experimental feature. * The API might be changed. */ export const cx =
(property) DefaultContextType.css: CssType
const cx: CxType
@experimental
defaultContext
cx
is an experimental feature. The API might be changed..cx
const defaultContext: DefaultContextType
/** * @experimental * `keyframes` is an experimental feature. * The API might be changed. */ export const keyframes =
(property) DefaultContextType.cx: CxType
const keyframes: KeyframesType
@experimental
defaultContext
keyframes
is an experimental feature. The API might be changed..keyframes
const defaultContext: DefaultContextType
/** * @experimental * `viewTransition` is an experimental feature. * The API might be changed. */ export const viewTransition =
(property) DefaultContextType.keyframes: KeyframesType
const viewTransition: ViewTransitionType
@experimental
defaultContext
viewTransition
is an experimental feature. The API might be changed..viewTransition
const defaultContext: DefaultContextType
/** * @experimental * `Style` is an experimental feature. * The API might be changed. */ export const Style =
(property) DefaultContextType.viewTransition: ViewTransitionType
const Style: StyleType
@experimental
defaultContext
Style
is an experimental feature. The API might be changed..Style
const defaultContext: DefaultContextType
(property) DefaultContextType.Style: StyleType
import { Hono } from '../../hono' import { RegExpRouter } from '../../router/reg-exp-router' import type { Handler, MiddlewareHandler } from '../../types' import { getRouterName, inspectRoutes, showRoutes } from '.' const namedMiddleware:MiddlewareHandler =
const namedMiddleware: MiddlewareHandler
(_,
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
next) =>
(parameter) _: Context<any, string, {}>
next()
(parameter) next: Next
const namedHandler:
(parameter) next: () => Promise<void>
Handler =
const namedHandler: Handler
(c) =>
(alias) 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 import Handler
c
(parameter) c: Context<any, any, BlankInput>
.text('hi')
(parameter) c: Context<any, any, BlankInput>
const app = new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
Hono()
const app: Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & ... 5 more ... & { ...; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.use('*',options
— Optional configuration options for the Hono instance.(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) =>
(parameter) c: Context<BlankEnv, "*", {}>
next())
(parameter) next: Next
.get(
(parameter) next: () => Promise<void>
'/', (_,
(property) Hono<{}, { "*": {}; }, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, BlankInput, {}, {}>(path: "/", handlers_0: H<{}, "/", BlankInput, any>, handlers_1: H<...>) => Hono<...> (+22 overloads)
next) =>
(parameter) _: Context<{}, "/", BlankInput>
next(),
(parameter) next: Next
(c) =>
(parameter) next: () => Promise<void>
c
(parameter) c: Context<{}, "/", BlankInput>
.text('hi')
(parameter) c: Context<{}, "/", BlankInput>
) .get('/named',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
namedMiddleware,
(property) Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/named", any, any, {}, BlankInput, any, any>(path: "/named", handlers_0: H<any, any, {}, any>, handlers_1: H<any, any, BlankInput, any>) => Hono<{}, { ...; } & { ...; } & { ...; }, "/"> (+22 overloads)
namedHandler)
const namedMiddleware: MiddlewareHandler
.post('/',
const namedHandler: Handler
(c) =>
(property) Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; }, "/">.post: HandlerInterface <"/", "/", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, {}>(path: "/", handler: H<{}, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<{}, "/", BlankInput>
.text('hi'))
(parameter) c: Context<{}, "/", BlankInput>
.put('/',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
(c) =>
(property) Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & { ...; }, "/">.put: HandlerInterface <"/", "/", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, {}>(path: "/", handler: H<{}, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<{}, "/", BlankInput>
.text('hi'))
(parameter) c: Context<{}, "/", BlankInput>
.patch('/',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
(c) =>
(property) Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & { ...; } & { ...; }, "/">.patch: HandlerInterface <"/", "/", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, {}>(path: "/", handler: H<{}, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<{}, "/", BlankInput>
.text('hi'))
(parameter) c: Context<{}, "/", BlankInput>
.delete('/',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
(c) =>
(property) Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & { ...; } & { ...; } & { ...; }, "/">.delete: HandlerInterface <"/", "/", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, {}>(path: "/", handler: H<{}, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<{}, "/", BlankInput>
.text('hi'))
(parameter) c: Context<{}, "/", BlankInput>
.options('/',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
(c) =>
(property) Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & { ...; } & { ...; } & { ...; } & { ...; }, "/">.options: HandlerInterface <"/", "/", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, {}>(path: "/", handler: H<{}, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<{}, "/", BlankInput>
.text('hi'))
(parameter) c: Context<{}, "/", BlankInput>
.get('/static', () => new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
Response('hi'))
(property) Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & ... 4 more ... & { ...; }, "/">.get: HandlerInterface <"/static", "/static", Response, BlankInput, {}>(path: "/static", handler: H<{}, "/static", BlankInput, Response>) => Hono<{}, { "*": {}; } & ... 7 more ... & { ...; }, "/"> (+22 overloads)
describe('inspectRoutes()', () => { it('should return correct data', async () => { expect(inspectRoutes
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.(app)).toEqual([
(alias) inspectRoutes<{}>(hono: Hono<{}, BlankSchema, "/">): RouteData[] import inspectRoutes
{ path: '/*',
const app: Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & ... 5 more ... & { ...; }, "/">
method: 'ALL',
(property) path: string
name: '[middleware]',
(property) method: string
isMiddleware: true },
(property) name: string
{ path: '/',
(property) isMiddleware: boolean
method: 'GET',
(property) path: string
name: '[middleware]',
(property) method: string
isMiddleware: true },
(property) name: string
{ path: '/',
(property) isMiddleware: boolean
method: 'GET',
(property) path: string
name: '[handler]',
(property) method: string
isMiddleware: false },
(property) name: string
{ path: '/named',
(property) isMiddleware: boolean
method: 'GET',
(property) path: string
name: 'namedMiddleware',
(property) method: string
isMiddleware: true },
(property) name: string
{ path: '/named',
(property) isMiddleware: boolean
method: 'GET',
(property) path: string
name: 'namedHandler',
(property) method: string
isMiddleware: false },
(property) name: string
{ path: '/',
(property) isMiddleware: boolean
method: 'POST',
(property) path: string
name: '[handler]',
(property) method: string
isMiddleware: false },
(property) name: string
{ path: '/',
(property) isMiddleware: boolean
method: 'PUT',
(property) path: string
name: '[handler]',
(property) method: string
isMiddleware: false },
(property) name: string
{ path: '/',
(property) isMiddleware: boolean
method: 'PATCH',
(property) path: string
name: '[handler]',
(property) method: string
isMiddleware: false },
(property) name: string
{ path: '/',
(property) isMiddleware: boolean
method: 'DELETE',
(property) path: string
name: '[handler]',
(property) method: string
isMiddleware: false },
(property) name: string
{ path: '/',
(property) isMiddleware: boolean
method: 'OPTIONS',
(property) path: string
name: '[handler]',
(property) method: string
isMiddleware: false },
(property) name: string
{ path: '/static',
(property) isMiddleware: boolean
method: 'GET',
(property) path: string
name: '[handler]',
(property) method: string
isMiddleware: false },
(property) name: string
]) }) it('should return [handler] also for sub app', async () => { const subApp = new
(property) isMiddleware: boolean
Hono()
const subApp: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
subAppoptions
— Optional configuration options for the Hono instance..get('/',
const subApp: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", JSONRespondReturn<0, StatusCode>, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.json(0))
(parameter) c: Context<BlankEnv, "/", BlankInput>
subApp
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <0, StatusCode>(object: 0, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<0, StatusCode> (+1 overload)
.onError(
const subApp: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(_,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) =>
(parameter) _: Error | HTTPResponseError
c
(parameter) c: Context<BlankEnv, any, {}>
.json(0))
(parameter) c: Context<BlankEnv, any, {}>
const mainApp = new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <0, StatusCode>(object: 0, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<0, StatusCode> (+1 overload)
Hono()
const mainApp: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
mainAppoptions
— Optional configuration options for the Hono instance..route('/',
const mainApp: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/", BlankEnv, BlankSchema, "/">(path: "/", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
subApp)expect(inspectRoutes
const subApp: Hono<BlankEnv, BlankSchema, "/">
(mainApp)).toEqual([
(alias) inspectRoutes<BlankEnv>(hono: Hono<BlankEnv, BlankSchema, "/">): RouteData[] import inspectRoutes
{ isMiddleware: false,
const mainApp: Hono<BlankEnv, BlankSchema, "/">
method: 'GET',
(property) isMiddleware: boolean
name: '[handler]',
(property) method: string
path: '/',
(property) name: string
}, ]) }) }) describe('showRoutes()', () => { let logs: string[] = []
(property) path: string
let originalLog: typeof
let logs: string[]
console
let originalLog: (...data: any[]) => void
.log
var console: Console
beforeAll(() => { originalLog =
(method) Console.log(...data: any[]): void
MDN Referenceconsole
let originalLog: (...data: any[]) => void
.log
var console: Console
console
(method) Console.log(...data: any[]): void
MDN Reference.log = (..
var console: Console
.args) =>
(method) Console.log(...data: any[]): void
MDN Referencelogs
(parameter) args: any[]
.push(..
let logs: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
.args)items
— New elements to add to the array.}) afterAll(() => { console
(parameter) args: any[]
.log =
var console: Console
originalLog
(method) Console.log(...data: any[]): void
MDN Reference}) beforeEach(() => { logs = []
let originalLog: (...data: any[]) => void
}) it('should render simple output', async () => { showRoutes
let logs: string[]
(app)
(alias) showRoutes<{}>(hono: Hono<{}, BlankSchema, "/">, opts?: ShowRoutesOptions): void import showRoutes
expect(logs).toEqual([
const app: Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & ... 5 more ... & { ...; }, "/">
'\x1b[32mGET\x1b[0m /', '\x1b[32mGET\x1b[0m /named', '\x1b[32mPOST\x1b[0m /', '\x1b[32mPUT\x1b[0m /', '\x1b[32mPATCH\x1b[0m /', '\x1b[32mDELETE\x1b[0m /', '\x1b[32mOPTIONS\x1b[0m /', '\x1b[32mGET\x1b[0m /static', ]) }) it('should render output includes handlers and middlewares', async () => { showRoutes
let logs: string[]
(app, {
(alias) showRoutes<{}>(hono: Hono<{}, BlankSchema, "/">, opts?: ShowRoutesOptions): void import showRoutes
verbose: true })
const app: Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & ... 5 more ... & { ...; }, "/">
expect(logs).toEqual([
(property) ShowRoutesOptions.verbose?: boolean | undefined
'\x1b[32mALL\x1b[0m /*', ' [middleware]', '\x1b[32mGET\x1b[0m /', ' [middleware]', ' [handler]', '\x1b[32mGET\x1b[0m /named', ' namedMiddleware', ' namedHandler', '\x1b[32mPOST\x1b[0m /', ' [handler]', '\x1b[32mPUT\x1b[0m /', ' [handler]', '\x1b[32mPATCH\x1b[0m /', ' [handler]', '\x1b[32mDELETE\x1b[0m /', ' [handler]', '\x1b[32mOPTIONS\x1b[0m /', ' [handler]', '\x1b[32mGET\x1b[0m /static', ' [handler]', ]) }) it('should render not colorized output', async () => { showRoutes
let logs: string[]
(app, {
(alias) showRoutes<{}>(hono: Hono<{}, BlankSchema, "/">, opts?: ShowRoutesOptions): void import showRoutes
colorize: false })
const app: Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & ... 5 more ... & { ...; }, "/">
expect(logs).toEqual([
(property) ShowRoutesOptions.colorize?: boolean | undefined
'GET /', 'GET /named', 'POST /', 'PUT /', 'PATCH /', 'DELETE /', 'OPTIONS /', 'GET /static', ]) }) }) describe('showRoutes() in NO_COLOR', () => { let logs: string[] = []
let logs: string[]
let originalLog: typeof
let logs: string[]
console
let originalLog: (...data: any[]) => void
.log
var console: Console
beforeAll(() => { vi.stubEnv('NO_COLOR', '1') originalLog =
(method) Console.log(...data: any[]): void
MDN Referenceconsole
let originalLog: (...data: any[]) => void
.log
var console: Console
console
(method) Console.log(...data: any[]): void
MDN Reference.log = (..
var console: Console
.args) =>
(method) Console.log(...data: any[]): void
MDN Referencelogs
(parameter) args: any[]
.push(..
let logs: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
.args)items
— New elements to add to the array.}) afterAll(() => { vi.unstubAllEnvs() console
(parameter) args: any[]
.log =
var console: Console
originalLog
(method) Console.log(...data: any[]): void
MDN Reference}) beforeEach(() => { logs = []
let originalLog: (...data: any[]) => void
}) it('should render not colorized output', async () => { showRoutes
let logs: string[]
(app)
(alias) showRoutes<{}>(hono: Hono<{}, BlankSchema, "/">, opts?: ShowRoutesOptions): void import showRoutes
expect(logs).toEqual([
const app: Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & ... 5 more ... & { ...; }, "/">
'GET /', 'GET /named', 'POST /', 'PUT /', 'PATCH /', 'DELETE /', 'OPTIONS /', 'GET /static', ]) }) it('should render colorized output if colorize: true', async () => { showRoutes
let logs: string[]
(app, {
(alias) showRoutes<{}>(hono: Hono<{}, BlankSchema, "/">, opts?: ShowRoutesOptions): void import showRoutes
colorize: true })
const app: Hono<{}, { "*": {}; } & { "/": { $get: { input: {}; output: "hi"; outputFormat: "text"; status: StatusCode; }; }; } & { "/named": { $get: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; } & ... 5 more ... & { ...; }, "/">
expect(logs).toEqual([
(property) ShowRoutesOptions.colorize?: boolean | undefined
'\x1b[32mGET\x1b[0m /', '\x1b[32mGET\x1b[0m /named', '\x1b[32mPOST\x1b[0m /', '\x1b[32mPUT\x1b[0m /', '\x1b[32mPATCH\x1b[0m /', '\x1b[32mDELETE\x1b[0m /', '\x1b[32mOPTIONS\x1b[0m /', '\x1b[32mGET\x1b[0m /static', ]) }) }) describe('getRouterName()', () => { it('Should return the correct router name', async () => { const app = new
let logs: string[]
Hono({
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
router: newoptions
— Optional configuration options for the Hono instance.
(property) router?: Router<[H, RouterRoute]> | undefined
router
option specifices which router to use.@see — https://hono.dev/docs/api/hono#router-option
@example
RegExpRouter(),
ts const app = new Hono({ router: new RegExpRouter() })
}) expect(getRouterName
(alias) new RegExpRouter<[H, RouterRoute]>(): RegExpRouter<[H, RouterRoute]> import RegExpRouter
(app)).toBe('RegExpRouter')
(alias) getRouterName<BlankEnv>(app: Hono<BlankEnv, BlankSchema, "/">): string import getRouterName
}) })
const app: Hono<BlankEnv, BlankSchema, "/">
/** * @module * Dev Helper for Hono. */ import type { Hono } from '../../hono' import type { Env, RouterRoute } from '../../types' import { getColorEnabled } from '../../utils/color' import { findTargetHandler, isMiddleware } from '../../utils/handler' interface ShowRoutesOptions {verbose?: boolean
interface ShowRoutesOptions
colorize?: boolean
(property) ShowRoutesOptions.verbose?: boolean | undefined
} interface RouteData {
(property) ShowRoutesOptions.colorize?: boolean | undefined
path: string
interface RouteData
method: string
(property) RouteData.path: string
name: string
(property) RouteData.method: string
isMiddleware: boolean
(property) RouteData.name: string
} const handlerName =
(property) RouteData.isMiddleware: boolean
(handler:
const handlerName: (handler: Function) => string
Function): string => {
(parameter) handler: Function
return handler
interface Function
Creates a new function..name ||
(parameter) handler: Function
(isMiddleware
(property) Function.name: string
Returns the name of the function. Function names are read-only and can not be changed.(handler) ? '[middleware]' : '[handler]')
(alias) isMiddleware(handler: Function): boolean import isMiddleware
} export const inspectRoutes =
(parameter) handler: Function
<E extends
const inspectRoutes: <E extends Env>(hono: Hono<E>) => RouteData[]
Env>
(type parameter) E in <E extends Env>(hono: Hono<E>): RouteData[]
(hono:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Hono
(parameter) hono: Hono<E, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E>):BasePath
— The base path type.RouteData[] => {
(type parameter) E in <E extends Env>(hono: Hono<E>): RouteData[]
return hono
interface RouteData
.routes
(parameter) hono: Hono<E, BlankSchema, "/">
.map(({
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.routes: RouterRoute[]
(method) Array<RouterRoute>.map<{ path: string; method: string; name: string; isMiddleware: boolean; }>(callbackfn: (value: RouterRoute, index: number, array: RouterRoute[]) => { path: string; method: string; name: string; isMiddleware: boolean; }, thisArg?: any): { path: string; method: string; name: string; isMiddleware: boolean; }[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
path,thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.method,
(parameter) path: string
handler }:
(parameter) method: string
RouterRoute) => {
(parameter) handler: H<any, any, BlankInput, any>
const targetHandler =
(alias) interface RouterRoute import RouterRoute
findTargetHandler
const targetHandler: Function
(handler)
(alias) findTargetHandler(handler: Function): Function import findTargetHandler
return { path,
(parameter) handler: H<any, any, BlankInput, any>
method,
(property) path: string
name:
(property) method: string
handlerName
(property) name: string
(targetHandler),
const handlerName: (handler: Function) => string
isMiddleware:
const targetHandler: Function
isMiddleware
(property) isMiddleware: boolean
(targetHandler),
(alias) isMiddleware(handler: Function): boolean import isMiddleware
} }) } export const showRoutes =
const targetHandler: Function
<E extends
const showRoutes: <E extends Env>(hono: Hono<E>, opts?: ShowRoutesOptions) => void
Env>
(type parameter) E in <E extends Env>(hono: Hono<E>, opts?: ShowRoutesOptions): void
(hono:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Hono
(parameter) hono: Hono<E, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E>,BasePath
— The base path type.opts?:
(type parameter) E in <E extends Env>(hono: Hono<E>, opts?: ShowRoutesOptions): void
ShowRoutesOptions): void => {
(parameter) opts: ShowRoutesOptions | undefined
const colorEnabled =
interface ShowRoutesOptions
opts?
const colorEnabled: boolean
.colorize ??
(parameter) opts: ShowRoutesOptions | undefined
getColorEnabled()
(property) ShowRoutesOptions.colorize?: boolean | undefined
(alias) getColorEnabled(): boolean import getColorEnabled
Get whether color change on terminal is enabled or disabled. IfNO_COLOR
environment variable is set, this function returnsfalse
.@see — https://no-color.org/
@returns
const routeData:Record
const routeData: Record<string, RouteData[]>
RouteData[]> = {}
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type Tlet maxMethodLength = 0
interface RouteData
let maxPathLength = 0
let maxMethodLength: number
inspectRoutes
let maxPathLength: number
(hono)
const inspectRoutes: <E>(hono: Hono<E, BlankSchema, "/">) => RouteData[]
.filter(({
(parameter) hono: Hono<E, BlankSchema, "/">
(method) Array<RouteData>.filter(predicate: (value: RouteData, index: number, array: RouteData[]) => unknown, thisArg?: any): RouteData[] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.@param
predicate
— A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@param
isMiddleware }) =>thisArg
— An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.opts?
(parameter) isMiddleware: boolean
.verbose ||
(parameter) opts: ShowRoutesOptions | undefined
!isMiddleware)
(property) ShowRoutesOptions.verbose?: boolean | undefined
.map(
(parameter) isMiddleware: boolean
(method) Array<RouteData>.map<{ method: string; path: string; routes: RouteData[]; } | undefined>(callbackfn: (value: RouteData, index: number, array: RouteData[]) => { method: string; path: string; routes: RouteData[]; } | undefined, thisArg?: any): ({ method: string; path: string; routes: RouteData[]; } | undefined)[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(route) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.const key = `$
(parameter) route: RouteData
{route
const key: string
.method}-$
(parameter) route: RouteData
{route
(property) RouteData.method: string
.path}`
(parameter) route: RouteData
;(routeData
(property) RouteData.path: string
[key] ||= [])
const routeData: Record<string, RouteData[]>
.push
const key: string
(method) Array<RouteData>.push(...items: RouteData[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(route)items
— New elements to add to the array.if (routeData
(parameter) route: RouteData
[key]
const routeData: Record<string, RouteData[]>
.length > 1) {
const key: string
return } maxMethodLength =
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.Math
let maxMethodLength: number
.max
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.
(method) Math.max(...values: number[]): number
Returns the larger of a set of supplied numeric expressions.@param
(maxMethodLength,values
— Numeric expressions to be evaluated.route
let maxMethodLength: number
.method
(parameter) route: RouteData
.length)
(property) RouteData.method: string
maxPathLength =
(property) String.length: number
Returns the length of a String object.Math
let maxPathLength: number
.max
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants.
(method) Math.max(...values: number[]): number
Returns the larger of a set of supplied numeric expressions.@param
(maxPathLength,values
— Numeric expressions to be evaluated.route
let maxPathLength: number
.path
(parameter) route: RouteData
.length)
(property) RouteData.path: string
return { method:
(property) String.length: number
Returns the length of a String object.route
(property) method: string
.method,
(parameter) route: RouteData
path:
(property) RouteData.method: string
route
(property) path: string
.path,
(parameter) route: RouteData
routes:
(property) RouteData.path: string
routeData
(property) routes: RouteData[]
[key] }
const routeData: Record<string, RouteData[]>
}) .forEach(
const key: string
(method) Array<{ method: string; path: string; routes: RouteData[]; } | undefined>.forEach(callbackfn: (value: { method: string; path: string; routes: RouteData[]; } | undefined, index: number, array: ({ method: string; path: string; routes: RouteData[]; } | undefined)[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(data) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.if (!data) {
(parameter) data: { method: string; path: string; routes: RouteData[]; } | undefined
return } const { method,
(parameter) data: { method: string; path: string; routes: RouteData[]; } | undefined
path,
const method: string
routes } =
const path: string
data
const routes: RouteData[]
const methodStr =
(parameter) data: { method: string; path: string; routes: RouteData[]; }
colorEnabled ? `\x1b[32m$
const methodStr: string
{method}\x1b[0m` :
const colorEnabled: boolean
method
const method: string
console
const method: string
.log(`$
var console: Console
{methodStr} ${' '
(method) Console.log(...data: any[]): void
MDN Reference.repeat
const methodStr: string
(method) String.repeat(count: number): string
Returns a String value that is made from count copies appended together. If count is 0, the empty string is returned.@param
(maxMethodLength -count
— number of copies to appendmethod
let maxMethodLength: number
.length)} $
const method: string
{path}`)
(property) String.length: number
Returns the length of a String object.if (!opts?
const path: string
.verbose) {
(parameter) opts: ShowRoutesOptions | undefined
return } routes
(property) ShowRoutesOptions.verbose?: boolean | undefined
.forEach(({
const routes: RouteData[]
(method) Array<RouteData>.forEach(callbackfn: (value: RouteData, index: number, array: RouteData[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
name }) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.console
(parameter) name: string
.log(`${' '
var console: Console
.repeat
(method) Console.log(...data: any[]): void
MDN Reference
(method) String.repeat(count: number): string
Returns a String value that is made from count copies appended together. If count is 0, the empty string is returned.@param
(maxMethodLength + 3)} $count
— number of copies to append{name}`)
let maxMethodLength: number
}) }) } export const getRouterName =
(parameter) name: string
<E extends
const getRouterName: <E extends Env>(app: Hono<E>) => string
Env>
(type parameter) E in <E extends Env>(app: Hono<E>): string
(app:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Hono
(parameter) app: Hono<E, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E>): string => {BasePath
— The base path type.app
(type parameter) E in <E extends Env>(app: Hono<E>): string
.router
(parameter) app: Hono<E, BlankSchema, "/">
.match('GET', '/')
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.router: Router<[H, RouterRoute]>
(method) Router<[H, RouterRoute]>.match(method: string, path: string): Result<[H, RouterRoute]>
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.
return app.router
(parameter) app: Hono<E, BlankSchema, "/">
.name
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.router: Router<[H, RouterRoute]>
}
(property) Router<[H, RouterRoute]>.name: string
The name of the router.
/* eslint-disable @typescript-eslint/no-unused-vars */ import { expectTypeOf } from 'vitest' import { hc } from '../../client' import type { ClientRequest } from '../../client/types' import { Hono } from '../../index' import type { ToSchema, TypedResponse } from '../../types' import type { StatusCode } from '../../utils/http-status' import { validator } from '../../validator' import { createFactory, createMiddleware } from './index' describe('createMiddleware', () => { type Env = {Variables: {
type Env = { Variables: { foo: string; }; }
foo: string } }
(property) Variables: { foo: string; }
const app = new
(property) foo: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const mw =options
— Optional configuration options for the Hono instance.(message: string) =>
const mw: (message: string) => MiddlewareHandler<Env, string, {}>
createMiddleware
(parameter) message: string
<Env>(async
(alias) createMiddleware<Env, string, {}>(middleware: MiddlewareHandler<Env, string, {}>): MiddlewareHandler<Env, string, {}> import createMiddleware
(c,
type Env = { Variables: { foo: string; }; }
next) => {
(parameter) c: Context<Env, string, {}>
expectTypeOf(c
(parameter) next: Next
.var
(parameter) c: Context<Env, string, {}>
(property) Context<Env, string, {}>.var: Readonly<ContextVariableMap & { foo: string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.foo).toEqualTypeOf
ts const result = c.var.client.oneMethod()
() c
(property) foo: string
.set('foo', 'bar')
(parameter) c: Context<Env, string, {}>
await next()
(property) Context<Env, string, {}>.set: Set <"foo">(key: "foo", value: string) => void (+1 overload)
c
(parameter) next: () => Promise<void>
.header('X-Message',
(parameter) c: Context<Env, string, {}>
message)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
}) const route =
(parameter) message: string
app
const route: Hono<BlankEnv, { "/message": { $get: { input: {}; output: `Hey, ${string}`; outputFormat: "text"; status: StatusCode; }; }; }, "/">
.get('/message',
const app: Hono<BlankEnv, BlankSchema, "/">
mw('Hello Middleware'),
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/message", "/message", Response & TypedResponse<`Hey, ${string}`, StatusCode, "text">, {}, {}, Env, Env>(path: "/message", handlers_0: H<Env, "/message", {}, any>, handlers_1: H<...>) => Hono<...> (+22 overloads)
(c) => {
const mw: (message: string) => MiddlewareHandler<Env, string, {}>
return c
(parameter) c: Context<Env, "/message", {}>
.text(`Hey, $
(parameter) c: Context<Env, "/message", {}>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`Hey, ${string}`, StatusCode>(text: `Hey, ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.var
(parameter) c: Context<Env, "/message", {}>
(property) Context<Env, "/message", {}>.var: Readonly<ContextVariableMap & { foo: string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.foo}`)
ts const result = c.var.client.oneMethod()
}) it('Should return the correct header and the content', async () => { const res = await
(property) foo: string
app
const res: Response
.request('/message')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('x-message')).toBe('Hello Middleware')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('Hey, bar')
const res: Response
}) it('Should provide the correct types', async () => { const client =
(method) Body.text(): Promise<string>
MDN Referencehc
const client: { message: ClientRequest<{ $get: { input: {}; output: `Hey, ${string}`; outputFormat: "text"; status: StatusCode; }; }>; }
route>('http://localhost')
(alias) hc<Hono<BlankEnv, { "/message": { $get: { input: {}; output: `Hey, ${string}`; outputFormat: "text"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
const url =
const route: Hono<BlankEnv, { "/message": { $get: { input: {}; output: `Hey, ${string}`; outputFormat: "text"; status: StatusCode; }; }; }, "/">
client.message
const url: URL
.$url()
const client: { message: ClientRequest<{ $get: { input: {}; output: `Hey, ${string}`; outputFormat: "text"; status: StatusCode; }; }>; }
expect(url
(property) $url: (arg?: {} | undefined) => URL
.pathname).toBe('/message')
const url: URL
}) }) describe('createHandler', () => { const mw =
(property) URL.pathname: string
MDN Reference(message: string) =>
const mw: (message: string) => MiddlewareHandler<any, string, {}>
createMiddleware(async
(parameter) message: string
(c,
(alias) createMiddleware<any, string, {}>(middleware: MiddlewareHandler<any, string, {}>): MiddlewareHandler<any, string, {}> import createMiddleware
next) => {
(parameter) c: Context<any, string, {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.header('x-message',
(parameter) c: Context<any, string, {}>
message)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
}) describe('Basic', () => { const factory =
(parameter) message: string
createFactory()
const factory: Factory<any, any>
const app = new
(alias) createFactory<any, any>(init?: { initApp?: InitApp<any> | undefined; } | undefined): Factory<any, any> import createFactory
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const handlersA =options
— Optional configuration options for the Hono instance.factory
const handlersA: [H<any, any, {}, Response & TypedResponse<"A", StatusCode, "text">>]
.createHandlers(
const factory: Factory<any, any>
(c) => {
(property) Factory<any, any>.createHandlers: CreateHandlersInterface <{}, Response & TypedResponse<"A", StatusCode, "text">>(handler1: H<any, any, {}, Response & TypedResponse<"A", StatusCode, "text">>) => [...] (+9 overloads)
return c
(parameter) c: Context<any, any, {}>
.text('A')
(parameter) c: Context<any, any, {}>
}) const routesA =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"A", StatusCode>(text: "A", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"A", StatusCode, "text"> (+1 overload)
app
const routesA: Hono<BlankEnv, { "/a": { $get: { input: {}; output: "A"; outputFormat: "text"; status: StatusCode; }; }; }, "/">
.get('/a', ..
const app: Hono<BlankEnv, BlankSchema, "/">
.handlersA)
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/a", any, Response & TypedResponse<"A", StatusCode, "text">, {}, any>(path: "/a", handler: H<any, any, {}, Response & TypedResponse<"A", StatusCode, "text">>) => Hono<...> (+22 overloads)
const handlersB =
const handlersA: [H<any, any, {}, Response & TypedResponse<"A", StatusCode, "text">>]
factory
const handlersB: [H<any, any, {}, Response & TypedResponse<"B", StatusCode, "text">>, H<any, any, {}, Response & TypedResponse<"B", StatusCode, "text">>]
.createHandlers
const factory: Factory<any, any>
(mw('B'),
(property) Factory<any, any>.createHandlers: CreateHandlersInterface <{}, {}, Response & TypedResponse<"B", StatusCode, "text">>(handler1: H<any, any, {}, Response & TypedResponse<"B", StatusCode, "text">>, handler2: H<...>) => [...] (+9 overloads)
(c) => {
const mw: (message: string) => MiddlewareHandler<any, string, {}>
return c
(parameter) c: Context<any, any, {}>
.text('B')
(parameter) c: Context<any, any, {}>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"B", StatusCode>(text: "B", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"B", StatusCode, "text"> (+1 overload)
.get('/b', ..
const app: Hono<BlankEnv, BlankSchema, "/">
.handlersB)
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/b", any, Response & TypedResponse<"B", StatusCode, "text">, {}, {}, any, any>(path: "/b", handlers_0: H<any, any, {}, any>, handlers_1: H<any, any, {}, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
it('Should return 200 response - GET /a', async () => { const res = await
const handlersB: [H<any, any, {}, Response & TypedResponse<"B", StatusCode, "text">>, H<any, any, {}, Response & TypedResponse<"B", StatusCode, "text">>]
app
const res: Response
.request('/a')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('A')
const res: Response
}) it('Should return 200 response with a custom header - GET /b', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/b')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('x-message')).toBe('B')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('B')
const res: Response
}) it('Should return correct path types - /a', () => { const client =
(method) Body.text(): Promise<string>
MDN Referencehc
const client: { a: ClientRequest<{ $get: { input: {}; output: "A"; outputFormat: "text"; status: StatusCode; }; }>; }
routesA>('/')
(alias) hc<Hono<BlankEnv, { "/a": { $get: { input: {}; output: "A"; outputFormat: "text"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
expectTypeOf(client).toEqualTypeOf<{
const routesA: Hono<BlankEnv, { "/a": { $get: { input: {}; output: "A"; outputFormat: "text"; status: StatusCode; }; }; }, "/">
a:
const client: { a: ClientRequest<{ $get: { input: {}; output: "A"; outputFormat: "text"; status: StatusCode; }; }>; }
ClientRequest<{
(property) a: ClientRequest<{ $get: { input: {}; output: "A"; outputFormat: "text"; status: StatusCode; }; }>
$get: {
(alias) type ClientRequest<S extends Schema> = { [M in keyof S]: S[M] extends Endpoint & { input: infer R; } ? R extends object ? HasRequiredKeys<R> extends true ? (args: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<...>> : (args?: R, options?: ClientRequestOptions) => Promise<ClientResponseOfEndpoint<...>> : never : never; } & { ...; } & (S["$get"] extends { ...; } ? S["$get"] extends { ...; } ? { ...; } : {} : {}) import ClientRequest
input: {}
(property) $get: { input: {}; output: "A"; outputFormat: "text"; status: StatusCode; }
output: 'A'
(property) input: {}
outputFormat: 'text'
(property) output: "A"
status:
(property) outputFormat: "text"
StatusCode
(property) status: StatusCode
} }> }>() }) }) describe('Types', () => { type Env = {
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.Variables: {
type Env = { Variables: { foo: string; }; }
foo: string } }
(property) Variables: { foo: string; }
const factory =
(property) foo: string
createFactory
const factory: Factory<Env, any>
<Env>()
(alias) createFactory<Env, any>(init?: { initApp?: InitApp<Env> | undefined; } | undefined): Factory<Env, any> import createFactory
const app = new
type Env = { Variables: { foo: string; }; }
Hono
const app: Hono<Env, BlankSchema, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance.const handlers =
type Env = { Variables: { foo: string; }; }
factory
const handlers: [H<Env, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, JSONRespondReturn<{ page: string; foo: string; }, StatusCode>>, H<...>]
.createHandlers(
const factory: Factory<Env, any>
validator('query', () => {
(property) Factory<Env, any>.createHandlers: CreateHandlersInterface <{ in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, JSONRespondReturn<{ page: string; foo: string; }, StatusCode>>(handler1: H<...>, handler2: H<...>) => [...] (+9 overloads)
return { page: '1',
(alias) validator<unknown, any, string, "query", { page: string; }, { page: string; }, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, Env>(target: "query", validationFunc: ValidationFunction<Record<string, string | string[]>, { ...; }, Env, any>): MiddlewareHandler<...> import validator
} }), (c) => {
(property) page: string
const foo =
(parameter) c: Context<Env, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }>
c
const foo: string
.var
(parameter) c: Context<Env, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }>
(property) Context<Env, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }>.var: Readonly<ContextVariableMap & { foo: string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.foo
ts const result = c.var.client.oneMethod()
const { page } =
(property) foo: string
c
const page: string
.req
(parameter) c: Context<Env, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }>
.valid('query')
(property) Context<Env, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }>.req: HonoRequest<any, { query: { page: string; }; }>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, { query: { page: string; }; }>.valid<"query">(target: "query"): { page: string; }
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
return c.json({
(parameter) c: Context<Env, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }>
page,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ page: string; foo: string; }, StatusCode>(object: { page: string; foo: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
foo })
(property) page: string
} ) const routes =
(property) foo: string
app
const routes: Hono<Env, { "/posts": { $get: { input: { query: { page: string | string[]; }; }; output: { page: string; foo: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
.get('/posts', ..
const app: Hono<Env, BlankSchema, "/">
.handlers)
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/posts", any, JSONRespondReturn<{ page: string; foo: string; }, StatusCode>, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, Env, Env>(path: "/posts", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
type Expected =
const handlers: [H<Env, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, JSONRespondReturn<{ page: string; foo: string; }, StatusCode>>, H<...>]
Hono<
type Expected = Hono<Env, { "/posts": { $get: { input: { query: { page: string; }; }; output: { page: string; foo: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
Env,BasePath
— The base path type.ToSchema<
type Env = { Variables: { foo: string; }; }
'get', '/posts', { in: {
(alias) type ToSchema<M extends string, P extends string, I extends Input | Input["in"], RorO> = { [KeyType in keyof { [K in P]: { [K2 in M as `$${Lowercase<K2>}`]: { [KeyType in keyof ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))]: ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))[KeyType]; }; }; }]: { [K in P]: { [K2 in M as `$${Lowercase<K2>}`]: { [KeyType in keyof ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))]: ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))[KeyType]; }; }; }[KeyType]; } import ToSchema
query: {
(property) in: { query: { page: string; }; }
page: string
(property) query: { page: string; }
} } }, TypedResponse<{
(property) page: string
page: string
(alias) type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : string> = { _data: T; _status: U; _format: F; } import TypedResponse
foo: string
(property) page: string
}> >, '/' > it('Should return correct types', () => { expectTypeOf(routes).toEqualTypeOf
(property) foo: string
<Expected>()
const routes: Hono<Env, { "/posts": { $get: { input: { query: { page: string | string[]; }; }; output: { page: string; foo: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
}) }) // It's difficult to cover all possible patterns, // so these tests will only cover the minimal cases. describe('Types - Complex', () => { type Env = {
type Expected = Hono<Env, { "/posts": { $get: { input: { query: { page: string; }; }; output: { page: string; foo: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
Variables: {
type Env = { Variables: { foo: string; }; }
foo: string } }
(property) Variables: { foo: string; }
const factory =
(property) foo: string
createFactory
const factory: Factory<Env, any>
<Env>()
(alias) createFactory<Env, any>(init?: { initApp?: InitApp<Env> | undefined; } | undefined): Factory<Env, any> import createFactory
const app = new
type Env = { Variables: { foo: string; }; }
Hono
const app: Hono<Env, BlankSchema, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance.const handlers =
type Env = { Variables: { foo: string; }; }
factory
const handlers: [H<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; }, JSONRespondReturn<{ auth: string; page: string; foo: string; id: number; }, StatusCode>>, H<...>, H<...>, H<...>]
.createHandlers(
const factory: Factory<Env, any>
validator('header', () => {
(property) Factory<Env, any>.createHandlers: CreateHandlersInterface <{ in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; }, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, { in: { json: { id: number; }; }; out: { json: { id: number; }; }; }, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & ... 1 more ... & { in: { json: { id: number; }; }; out: { json: { id: number; }; }; }, JSONRespondReturn<...>>(handler1: H<...>, handler2: H<...>, handler3: H<...>, handler4: H<...>) => [...] (+9 overloads)
return { auth: 'token',
(alias) validator<unknown, any, string, "header", { auth: string; }, { auth: string; }, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; }, Env>(target: "header", validationFunc: ValidationFunction<Record<string, string>, { ...; }, Env, any>): MiddlewareHandler<...> import validator
} }), validator('query', () => {
(property) auth: string
return { page: '1',
(alias) validator<unknown, any, string, "query", { page: string; }, { page: string; }, any, { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; }, Env>(target: "query", validationFunc: ValidationFunction<Record<string, string | string[]>, { ...; }, Env, any>): MiddlewareHandler<...> import validator
} }), validator('json', () => {
(property) page: string
return { id: 123,
(alias) validator<unknown, any, string, "json", { id: number; }, { id: number; }, any, { in: { json: { id: number; }; }; out: { json: { id: number; }; }; }, Env>(target: "json", validationFunc: ValidationFunction<any, { id: number; }, Env, any>): MiddlewareHandler<...> import validator
} }), (c) => {
(property) id: number
const foo =
(parameter) c: Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>
c
const foo: string
.var
(parameter) c: Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>
(property) Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>.var: Readonly<ContextVariableMap & { foo: string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.foo
ts const result = c.var.client.oneMethod()
const { auth } =
(property) foo: string
c
const auth: string
.req
(parameter) c: Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>
.valid('header')
(property) Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>.req: HonoRequest<any, { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }>.valid<"header">(target: "header"): { auth: string; }
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
const { page } =c
const page: string
.req
(parameter) c: Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>
.valid('query')
(property) Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>.req: HonoRequest<any, { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }>.valid<"query">(target: "query"): { page: string; }
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
const { id } =c
const id: number
.req
(parameter) c: Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>
.valid('json')
(property) Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>.req: HonoRequest<any, { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }>.valid<"json">(target: "json"): { id: number; }
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
return c.json({
(parameter) c: Context<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & { in: { query: { page: string | string[]; }; }; out: { query: { page: string; }; }; } & { in: { json: { id: number; }; }; out: { ...; }; }>
auth,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ auth: string; page: string; foo: string; id: number; }, StatusCode>(object: { auth: string; page: string; foo: string; id: number; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
page,
(property) auth: string
foo,
(property) page: string
id })
(property) foo: string
} ) const routes =
(property) id: number
app
const routes: Hono<Env, { "/posts": { $get: { input: { header: { auth: string; }; } & { query: { page: string | string[]; }; } & { json: { id: number; }; }; output: { auth: string; page: string; foo: string; id: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
.get('/posts', ..
const app: Hono<Env, BlankSchema, "/">
.handlers)
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/posts", any, JSONRespondReturn<{ auth: string; page: string; foo: string; id: number; }, StatusCode>, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; }, { ...; }, { ...; }, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; } & ... 1 more ... & { ...; }, Env, Env, Env, Env>(path: "/posts", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
type Expected =
const handlers: [H<Env, any, { in: { header: { auth: string; }; }; out: { header: { auth: string; }; }; }, JSONRespondReturn<{ auth: string; page: string; foo: string; id: number; }, StatusCode>>, H<...>, H<...>, H<...>]
Hono<
type Expected = Hono<Env, { "/posts": { $get: { input: { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }; output: { ...; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
Env,BasePath
— The base path type.ToSchema<
type Env = { Variables: { foo: string; }; }
'get', '/posts', { in: {
(alias) type ToSchema<M extends string, P extends string, I extends Input | Input["in"], RorO> = { [KeyType in keyof { [K in P]: { [K2 in M as `$${Lowercase<K2>}`]: { [KeyType in keyof ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))]: ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))[KeyType]; }; }; }]: { [K in P]: { [K2 in M as `$${Lowercase<K2>}`]: { [KeyType in keyof ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))]: ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))[KeyType]; }; }; }[KeyType]; } import ToSchema
header: {
(property) in: { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }
auth: string
(property) header: { auth: string; }
} } & { query: {
(property) auth: string
page: string
(property) query: { page: string; }
} } & { json: {
(property) page: string
id: number
(property) json: { id: number; }
} } }, TypedResponse<{
(property) id: number
auth: string
(alias) type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : string> = { _data: T; _status: U; _format: F; } import TypedResponse
page: string
(property) auth: string
foo: string
(property) page: string
id: number
(property) foo: string
}> >, '/' > it('Should return correct types', () => { expectTypeOf(routes).toEqualTypeOf
(property) id: number
<Expected>()
const routes: Hono<Env, { "/posts": { $get: { input: { header: { auth: string; }; } & { query: { page: string | string[]; }; } & { json: { id: number; }; }; output: { auth: string; page: string; foo: string; id: number; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
}) }) }) describe('createApp', () => { type Env = {
type Expected = Hono<Env, { "/posts": { $get: { input: { header: { auth: string; }; } & { query: { page: string; }; } & { json: { id: number; }; }; output: { ...; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
Variables: {
type Env = { Variables: { foo: string; }; }
foo: string } }
(property) Variables: { foo: string; }
const factory =
(property) foo: string
createFactory
const factory: Factory<Env, any>
<Env>({
(alias) createFactory<Env, any>(init?: { initApp?: InitApp<Env> | undefined; } | undefined): Factory<Env, any> import createFactory
initApp:
type Env = { Variables: { foo: string; }; }
(app) => {
(property) initApp?: InitApp<Env> | undefined
app
(parameter) app: Hono<Env, BlankSchema, "/">
.use(
(parameter) app: Hono<Env, BlankSchema, "/">
(c,
(property) Hono<Env, BlankSchema, "/">.use: MiddlewareHandlerInterface <Env>(...handlers: MiddlewareHandler<Env, never, {}>[]) => Hono<Env, BlankSchema, "/"> (+20 overloads)
next) => {
(parameter) c: Context<Env, never, {}>
c
(parameter) next: Next
.set('foo', 'bar')
(parameter) c: Context<Env, never, {}>
return next()
(property) Context<Env, never, {}>.set: Set <"foo">(key: "foo", value: string) => void (+1 overload)
}) }, }) const app =
(parameter) next: () => Promise<void>
factory
const app: Hono<Env, BlankSchema, "/">
.createApp()
const factory: Factory<Env, any>
it('Should set the correct type and initialize the app', async () => { app
(property) Factory<Env, any>.createApp: () => Hono<Env, BlankSchema, "/">
.get('/',
const app: Hono<Env, BlankSchema, "/">
(c) => {
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<string, StatusCode, "text">, BlankInput, Env>(path: "/", handler: H<Env, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
expectTypeOf(c
(parameter) c: Context<Env, "/", BlankInput>
.var
(parameter) c: Context<Env, "/", BlankInput>
(property) Context<Env, "/", BlankInput>.var: Readonly<ContextVariableMap & { foo: string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.foo).toEqualTypeOf
ts const result = c.var.client.oneMethod()
() return c
(property) foo: string
.text
(parameter) c: Context<Env, "/", BlankInput>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<Env, "/", BlankInput>
(property) Context<Env, "/", BlankInput>.var: Readonly<ContextVariableMap & { foo: string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.foo)
ts const result = c.var.client.oneMethod()
}) const res = await
(property) foo: string
app
const res: Response
.request('/')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('bar')
const res: Response
}) }) describe('Lint rules', () => { it('Should not throw a eslint `unbound-method` error if destructed', () => { const { createApp,
(method) Body.text(): Promise<string>
MDN ReferencecreateHandlers,
const createApp: () => Hono<any, BlankSchema, "/">
createMiddleware } =
const createHandlers: CreateHandlersInterface<any, any>
createFactory()
const createMiddleware: <I extends Input = {}>(middleware: MiddlewareHandler<any, any, I>) => MiddlewareHandler<any, any, I>
expect(createApp).toBeDefined()
(alias) createFactory<any, any>(init?: { initApp?: InitApp<any> | undefined; } | undefined): Factory<any, any> import createFactory
expect(createHandlers).toBeDefined()
const createApp: () => Hono<any, BlankSchema, "/">
expect(createMiddleware).toBeDefined()
const createHandlers: CreateHandlersInterface<any, any>
}) })
const createMiddleware: <I extends Input = {}>(middleware: MiddlewareHandler<any, any, I>) => MiddlewareHandler<any, any, I>
/** * @module * Factory Helper for Hono. */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Hono } from '../../hono' import type { Env, H, HandlerResponse, Input, MiddlewareHandler } from '../../types' type InitApp<E extends
type InitApp<E extends Env = Env> = (app: Hono<E>) => void
Env =
(type parameter) E in type InitApp<E extends Env = Env>
Env> =
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
(app:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Hono
(parameter) app: Hono<E, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E>) => voidBasePath
— The base path type.export interface CreateHandlersInterface
(type parameter) E in type InitApp<E extends Env = Env>
<E extends
interface CreateHandlersInterface<E extends Env, P extends string>
Env,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
P extends string> {
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
<I extends
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
Input = {},
(type parameter) I in <I extends Input = {}, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>): [H<E, P, I, R>]
R extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
HandlerResponse
(type parameter) R in <I extends Input = {}, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>): [H<E, P, I, R>]
= any> (handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>): [
(type parameter) I in <I extends Input = {}, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>): [H<E, P, I, R>]
H
(type parameter) R in <I extends Input = {}, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>): [H<E, P, I, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I in <I extends Input = {}, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>): [H<E, P, I, R>]
] // handler x2 <I extends
(type parameter) R in <I extends Input = {}, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>): [H<E, P, I, R>]
Input = {},
(type parameter) I in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
R extends
(type parameter) I in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
HandlerResponse
(type parameter) R in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
= any>( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
handler2:
(type parameter) R in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
): [H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>]
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
// handler x3 < I extends
(type parameter) R in <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>]
Input = {},
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I3 extends
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
Input =
(type parameter) I3 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2,
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
R extends
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
HandlerResponse
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
= any >( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
handler2:
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
handler3:
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
H
(parameter) handler3: H<E, P, I3, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I3 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
): [H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>]
(type parameter) I3 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
// handler x4 < I extends
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>]
Input = {},
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I3 extends
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
Input =
(type parameter) I3 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2,
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
I4 extends
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
Input =
(type parameter) I4 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
I3,
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
R extends
(type parameter) I3 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
HandlerResponse
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
= any >( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
handler2:
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
handler3:
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
H
(parameter) handler3: H<E, P, I3, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
handler4:
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
H
(parameter) handler4: H<E, P, I4, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I4 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
): [H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
H
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>]
(type parameter) I4 in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
// handler x5 < I extends
(type parameter) R in <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>]
Input = {},
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I3 extends
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
Input =
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2,
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I4 extends
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
Input =
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I3,
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I5 extends
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
Input =
(type parameter) I5 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I3 &
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
I4,
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
R extends
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
HandlerResponse
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
= any >( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
handler2:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
handler3:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
H
(parameter) handler3: H<E, P, I3, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
handler4:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
H
(parameter) handler4: H<E, P, I4, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
handler5:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
H
(parameter) handler5: H<E, P, I5, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I5 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
): [H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>]
(type parameter) I5 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
// handler x6 < I extends
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>]
Input = {},
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I3 extends
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
Input =
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2,
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I4 extends
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
Input =
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I3,
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I5 extends
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
Input =
(type parameter) I5 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I3 &
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I4,
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I6 extends
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
Input =
(type parameter) I6 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I3 &
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I4 &
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
I5,
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
R extends
(type parameter) I5 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
HandlerResponse
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
= any >( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
handler2:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
handler3:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(parameter) handler3: H<E, P, I3, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
handler4:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(parameter) handler4: H<E, P, I4, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
handler5:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(parameter) handler5: H<E, P, I5, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
handler6:
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(parameter) handler6: H<E, P, I6, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I6 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
): [H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
H
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>]
(type parameter) I6 in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
// handler x7 < I extends
(type parameter) R in <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>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>]
Input = {},
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I3 extends
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
Input =
(type parameter) I3 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2,
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I4 extends
(type parameter) I2 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
Input =
(type parameter) I4 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I3,
(type parameter) I2 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I5 extends
(type parameter) I3 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
Input =
(type parameter) I5 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I4,
(type parameter) I3 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I6 extends
(type parameter) I4 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
Input =
(type parameter) I6 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I5,
(type parameter) I4 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I7 extends
(type parameter) I5 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
Input =
(type parameter) I7 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
I6,
(type parameter) I5 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
R extends
(type parameter) I6 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
HandlerResponse
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
= any >( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
handler2:
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
handler3:
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(parameter) handler3: H<E, P, I3, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
handler4:
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(parameter) handler4: H<E, P, I4, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
handler5:
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(parameter) handler5: H<E, P, I5, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
handler6:
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(parameter) handler6: H<E, P, I6, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I6 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
handler7:
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(parameter) handler7: H<E, P, I7, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I7,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I7 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
): [ H
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I6 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I7,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I7 in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
] // handler x8 < I extends
(type parameter) R in <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 & ... 4 more ... & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>]
Input = {},
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I3 extends
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
Input =
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I4 extends
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
Input =
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I3,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I5 extends
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
Input =
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I4,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I6 extends
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
Input =
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I5,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I7 extends
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
Input =
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I6,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I8 extends
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
Input =
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I6 &
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
I7,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
R extends
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
HandlerResponse
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
= any >( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
handler2:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
handler3:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(parameter) handler3: H<E, P, I3, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
handler4:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(parameter) handler4: H<E, P, I4, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
handler5:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(parameter) handler5: H<E, P, I5, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
handler6:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(parameter) handler6: H<E, P, I6, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
handler7:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(parameter) handler7: H<E, P, I7, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I7,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
handler8:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(parameter) handler8: H<E, P, I8, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I8,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
): [ H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I7,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I8,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
] // handler x9 < I extends
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>]
Input = {},
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I3 extends
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
Input =
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I4 extends
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
Input =
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I3,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I5 extends
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
Input =
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I4,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I6 extends
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
Input =
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I5,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I7 extends
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
Input =
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I6,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I8 extends
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
Input =
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I6 &
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I7,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I9 extends
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
Input =
(type parameter) I9 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I6 &
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I7 &
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
I8,
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
R extends
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
HandlerResponse
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
= any >( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
handler2:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
handler3:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(parameter) handler3: H<E, P, I3, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
handler4:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(parameter) handler4: H<E, P, I4, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
handler5:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(parameter) handler5: H<E, P, I5, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
handler6:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(parameter) handler6: H<E, P, I6, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
handler7:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(parameter) handler7: H<E, P, I7, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I7,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
handler8:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(parameter) handler8: H<E, P, I8, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I8,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
handler9:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(parameter) handler9: H<E, P, I9, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I9,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I9 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
): [ H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I7,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I8,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I9,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I9 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
] // handler x10 < I extends
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>]
Input = {},
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I2 extends
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
Input =
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I3 extends
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
Input =
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I4 extends
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
Input =
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I3,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I5 extends
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
Input =
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I4,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I6 extends
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
Input =
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I5,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I7 extends
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
Input =
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I6,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I8 extends
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
Input =
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I6 &
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I7,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I9 extends
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
Input =
(type parameter) I9 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I6 &
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I7 &
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I8,
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I10 extends
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
Input =
(type parameter) I10 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I &
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
I2 &
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I3 &
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I4 &
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I5 &
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I6 &
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I7 &
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I8 &
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
I9,
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
R extends
(type parameter) I9 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
HandlerResponse
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
= any >( handler1:
(alias) type HandlerResponse<O> = Response | TypedResponse<O, StatusCode, O extends string ? "text" : O extends JSONValue ? "json" : string> | Promise<...> import HandlerResponse
H
(parameter) handler1: H<E, P, I, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler2:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler2: H<E, P, I2, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler3:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler3: H<E, P, I3, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler4:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler4: H<E, P, I4, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler5:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler5: H<E, P, I5, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler6:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler6: H<E, P, I6, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler7:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler7: H<E, P, I7, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I7,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler8:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler8: H<E, P, I8, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I8,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler9:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler9: H<E, P, I9, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I9,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I9 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
handler10:
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(parameter) handler10: H<E, P, I10, R>
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I10,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I10 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
): [ H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I2,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I2 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I3,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I3 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I4,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I4 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I5,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I5 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I6,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I6 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I7,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I7 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I8,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I8 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I9,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>,
(type parameter) I9 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
H
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E,
(alias) 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> import H
P,
(type parameter) E in CreateHandlersInterface<E extends Env, P extends string>
I10,
(type parameter) P in CreateHandlersInterface<E extends Env, P extends string>
R>
(type parameter) I10 in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
] } export class Factory
(type parameter) R in <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 & ... 4 more ... & I6, I8 extends Input = I & ... 5 more ... & I7, I9 extends Input = I & ... 6 more ... & I8, I10 extends Input = I & ... 7 more ... & I9, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>, handler8: H<E, P, I8, R>, handler9: H<E, P, I9, R>, handler10: H<E, P, I10, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>, H<E, P, I7, R>, H<E, P, I8, R>, H<E, P, I9, R>, H<E, P, I10, R>]
<E extends
class Factory<E extends Env = any, P extends string = any>
Env = any,
(type parameter) E in Factory<E extends Env = any, P extends string = any>
P extends string = any> {
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
private initApp?:
(type parameter) P in Factory<E extends Env = any, P extends string = any>
InitApp
(property) Factory<E extends Env = any, P extends string = any>.initApp?: InitApp<E> | undefined
<E>
type InitApp<E extends Env = Env> = (app: Hono<E>) => void
constructor(init?: {
(type parameter) E in Factory<E extends Env = any, P extends string = any>
initApp?:
(parameter) init: { initApp?: InitApp<E>; } | undefined
InitApp
(property) initApp?: InitApp<E> | undefined
<E> }) {
type InitApp<E extends Env = Env> = (app: Hono<E>) => void
this.initApp =
(type parameter) E in Factory<E extends Env = any, P extends string = any>
init?
(property) Factory<E extends Env = any, P extends string = any>.initApp?: InitApp<E> | undefined
.initApp
(parameter) init: { initApp?: InitApp<E>; } | undefined
} createApp = ():
(property) initApp?: InitApp<E> | undefined
Hono
(property) Factory<E extends Env = any, P extends string = any>.createApp: () => Hono<E>
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E> => {BasePath
— The base path type.const app = new
(type parameter) E in Factory<E extends Env = any, P extends string = any>
Hono
const app: Hono<E, BlankSchema, "/">
(alias) new Hono<E, BlankSchema, "/">(options?: HonoOptions<E>): Hono<E, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<E>()options
— Optional configuration options for the Hono instance.if (this.initApp) {
(type parameter) E in Factory<E extends Env = any, P extends string = any>
this.initApp
(property) Factory<E extends Env = any, P extends string = any>.initApp?: InitApp<E> | undefined
(app)
(property) Factory<E extends Env = any, P extends string = any>.initApp?: (app: Hono<E, BlankSchema, "/">) => void
} return app
const app: Hono<E, BlankSchema, "/">
} createMiddleware =
const app: Hono<E, BlankSchema, "/">
<I extends
(property) Factory<E extends Env = any, P extends string = any>.createMiddleware: <I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>
Input = {}>
(type parameter) I in <I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
(middleware:
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
MiddlewareHandler
(parameter) middleware: MiddlewareHandler<E, P, I>
<E,
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
P,
(type parameter) E in Factory<E extends Env = any, P extends string = any>
I>) =>
(type parameter) P in Factory<E extends Env = any, P extends string = any>
middleware
(type parameter) I in <I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
createHandlers:
(parameter) middleware: MiddlewareHandler<E, P, I>
CreateHandlersInterface
(property) Factory<E extends Env = any, P extends string = any>.createHandlers: CreateHandlersInterface<E, P>
<E,
interface CreateHandlersInterface<E extends Env, P extends string>
P> = (..
(type parameter) E in Factory<E extends Env = any, P extends string = any>
.handlers: any) => {
(type parameter) P in Factory<E extends Env = any, P extends string = any>
// @ts-expect-error this should not be typed return handlers.filter(
(parameter) handlers: any
(handler) =>
(parameter) handlers: any
handler !== undefined)
(parameter) handler: any
} } export const createFactory =
(parameter) handler: any
<E extends
const createFactory: <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }) => Factory<E, P>
Env = any,
(type parameter) E in <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }): Factory<E, P>
P extends string = any>
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
(init?: {
(type parameter) P in <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }): Factory<E, P>
initApp?:
(parameter) init: { initApp?: InitApp<E>; } | undefined
InitApp
(property) initApp?: InitApp<E> | undefined
<E>
type InitApp<E extends Env = Env> = (app: Hono<E>) => void
}): Factory
(type parameter) E in <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }): Factory<E, P>
<E,
class Factory<E extends Env = any, P extends string = any>
P> => new
(type parameter) E in <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }): Factory<E, P>
Factory
(type parameter) P in <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }): Factory<E, P>
<E,
constructor Factory<E, P>(init?: { initApp?: InitApp<E> | undefined; } | undefined): Factory<E, P>
P>
(type parameter) E in <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }): Factory<E, P>
(init)
(type parameter) P in <E extends Env = any, P extends string = any>(init?: { initApp?: InitApp<E>; }): Factory<E, P>
export const createMiddleware = <
(parameter) init: { initApp?: InitApp<E>; } | undefined
E extends
const createMiddleware: <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>
Env = any,
(type parameter) E in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
P extends string = string,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
I extends
(type parameter) P in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
Input = {}
(type parameter) I in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
>( middleware:
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } import Input
MiddlewareHandler
(parameter) middleware: MiddlewareHandler<E, P, I>
<E,
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
P,
(type parameter) E in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
I>
(type parameter) P in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
): MiddlewareHandler
(type parameter) I in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
<E,
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
P,
(type parameter) E in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
I> =>
(type parameter) P in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
createFactory
(type parameter) I in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
<E,
const createFactory: <E, P>(init?: { initApp?: InitApp<E> | undefined; } | undefined) => Factory<E, P>
P>()
(type parameter) E in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
.createMiddleware
(type parameter) P in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
<I>
(property) Factory<E, P>.createMiddleware: <I>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>
(middleware)
(type parameter) I in <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>): MiddlewareHandler<E, P, I>
(parameter) middleware: MiddlewareHandler<E, P, I>
import { HtmlEscapedCallbackPhase, resolveCallback } from '../../utils/html' import { html, raw } from '.' describe('Tagged Template Literals', () => { it('Should escape special characters', () => { const name = 'John "Johnny" Smith'// eslint-disable-next-line quotes expect(html`
const name: "John \"Johnny\" Smith"
I'm $
{name}.`
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
.toString()).toBe("
const name: "John \"Johnny\" Smith"
I'm John "Johnny" Smith.
")}) describe('Booleans, Null, and Undefined Are Ignored', () => { it.each([true, false, undefined, null])('%s', (item) => {
(method) toString(): string
Returns a string representation of an object.expect(html`$
(parameter) item: any
{item}`
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
.toString()).toBe('')
(parameter) item: any
}) it('falsy value', () => { expect(html`${0}`
(method) toString(): string
Returns a string representation of an object..toString()).toBe('0')
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
}) }) it('Should call $array.flat(Infinity)', () => { const values = [
(method) toString(): string
Returns a string representation of an object.'Name:', ['John "Johnny" Smith', undefined, null], ' Contact:', [html`My Website`],
const values: (string | (string | null | undefined)[] | (HtmlEscapedString | Promise<HtmlEscapedString>)[])[]
] expect(html`
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
$
{values}`
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
.toString()).toBe(
const values: (string | (string | null | undefined)[] | (HtmlEscapedString | Promise<HtmlEscapedString>)[])[]
'
(method) toString(): string
Returns a string representation of an object.Name:John "Johnny" Smith Contact:My Website
' ) }) describe('Promise', () => { it('Should return Promisewhen some variables contains Promise const name =in variables', async () => { Promise
const name: Promise<string>
.resolve('John "Johnny" Smith')
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
(method) PromiseConstructor.resolve<string>(value: string): Promise<string> (+2 overloads)
Creates a new resolved promise for the provided value.@param
value
— A promise.@returns — A promise whose internal state matches the provided promise.
const res =html`
const res: HtmlEscapedString | Promise<HtmlEscapedString>
I'm $
{name}.`
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
expect(res).toBeInstanceOf
const name: Promise<string>
(Promise)
const res: HtmlEscapedString | Promise<HtmlEscapedString>
// eslint-disable-next-line quotes expect((await res)
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.toString()).toBe("
const res: HtmlEscapedString | Promise<HtmlEscapedString>
I'm John "Johnny" Smith.
")}) it('Should return raw value when some variables contains Promise
(method) String.toString(): string
Returns a string representation of a string.in variables', async () => { const name =Promise
const name: Promise<HtmlEscapedString>
.resolve
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
(method) PromiseConstructor.resolve<HtmlEscapedString>(value: HtmlEscapedString): Promise<HtmlEscapedString> (+2 overloads)
Creates a new resolved promise for the provided value.@param
value
— A promise.@returns — A promise whose internal state matches the provided promise.
(raw('John "Johnny" Smith'))const res =
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
html`
const res: HtmlEscapedString | Promise<HtmlEscapedString>
I'm $
{name}.`
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
expect(res).toBeInstanceOf
const name: Promise<HtmlEscapedString>
(Promise)
const res: HtmlEscapedString | Promise<HtmlEscapedString>
expect((await res)
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.toString()).toBe('
const res: HtmlEscapedString | Promise<HtmlEscapedString>
I\'m John "Johnny" Smith.
')}) }) describe('HtmlEscapedString', () => { it('Should preserve callbacks', async () => { const name =
(method) String.toString(): string
Returns a string representation of a string.raw('Hono', [
const name: HtmlEscapedString
({ buffer }) => {
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
if (buffer) {
(parameter) buffer: [string] | undefined
buffer[0] =
(parameter) buffer: [string] | undefined
buffer[0]
(parameter) buffer: [string]
.replace('Hono', 'Hono!')
(parameter) buffer: [string]
(method) String.replace(searchValue: string | RegExp, replaceValue: string): string (+3 overloads)
Replaces text in a string, using a regular expression or search string.@param
searchValue
— A string or regular expression to search for.@param
} return undefined }, ]) const res =replaceValue
— A string containing the text to replace. When thesearchValue
is aRegExp
, all matches are replaced if theg
flag is set (or only those matches at the beginning, if they
flag is also present). Otherwise, only the first match ofsearchValue
is replaced.html`
const res: HtmlEscapedString | Promise<HtmlEscapedString>
I'm $
{name}.`
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
expect(res).toBeInstanceOf
const name: HtmlEscapedString
(Promise)
const res: HtmlEscapedString | Promise<HtmlEscapedString>
// eslint-disable-next-line quotes expect((await res)
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.toString()).toBe("
const res: HtmlEscapedString | Promise<HtmlEscapedString>
I'm Hono.
")expect(await resolveCallback(await
(method) String.toString(): string
Returns a string representation of a string.res,
(alias) resolveCallback(str: string | HtmlEscapedString | Promise<string>, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [string]): Promise<string> import resolveCallback
HtmlEscapedCallbackPhase
const res: HtmlEscapedString | Promise<HtmlEscapedString>
(alias) const HtmlEscapedCallbackPhase: { readonly Stringify: 1; readonly BeforeStream: 2; readonly Stream: 3; } import HtmlEscapedCallbackPhase
@module — HTML utility.
.Stringify, false, {})).toBe(// eslint-disable-next-line quotes "
(property) Stringify: 1
I'm Hono!.
" ) }) }) }) describe('raw', () => { it('Should be marked as escaped.', () => { const name = 'John "Johnny" Smith'expect(html`
const name: "John "Johnny" Smith"
I'm $
{raw
(alias) const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString> import html
(name)}.`
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
.toString()).toBe(
const name: "John "Johnny" Smith"
// eslint-disable-next-line quotes "
(method) toString(): string
Returns a string representation of an object.I'm John "Johnny" Smith.
" ) }) })
/** * @module * html Helper for Hono. */ import { escapeToBuffer, raw, resolveCallbackSync, stringBufferToString } from '../../utils/html' import type { HtmlEscaped, HtmlEscapedString, StringBufferWithCallbacks } from '../../utils/html' export { raw }export const html = (
(alias) const raw: (value: unknown, callbacks?: HtmlEscapedCallback[]) => HtmlEscapedString export raw
strings:
const html: (strings: TemplateStringsArray, ...values: unknown[]) => HtmlEscapedString | Promise<HtmlEscapedString>
TemplateStringsArray,
(parameter) strings: TemplateStringsArray
...values: unknown[]
interface TemplateStringsArray
): HtmlEscapedString |
(parameter) values: unknown[]
Promise
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
<HtmlEscapedString> => {
interface Promise<T>
Represents the completion of an asynchronous operationconst buffer:
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
StringBufferWithCallbacks = [''] as
const buffer: StringBufferWithCallbacks
StringBufferWithCallbacks
(alias) type StringBufferWithCallbacks = StringBuffer & { callbacks: HtmlEscapedCallback[]; } import StringBufferWithCallbacks
for (let i = 0,
(alias) type StringBufferWithCallbacks = StringBuffer & { callbacks: HtmlEscapedCallback[]; } import StringBufferWithCallbacks
len =
let i: number
strings
let len: number
.length - 1;
(parameter) strings: TemplateStringsArray
i <
(property) ReadonlyArray<string>.length: number
Gets the length of the array. This is a number one higher than the highest element defined in an array.len;
let i: number
i++) {
let len: number
buffer[0] +=
let i: number
strings
const buffer: StringBufferWithCallbacks
[i]
(parameter) strings: TemplateStringsArray
const children =
let i: number
values
const children: unknown[]
[i] instanceof
(parameter) values: unknown[]
Array ?
let i: number
(values
var Array: ArrayConstructor
[i] as
(parameter) values: unknown[]
Array
let i: number
) .flat(Infinity) :
interface Array<T>
(method) Array<unknown>.flat<unknown[], number>(this: unknown[], depth?: number | undefined): unknown[]
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.@param
[valuesdepth
— The maximum recursion depth[i]]
(parameter) values: unknown[]
for (let i = 0,
let i: number
len =
let i: number
children
let len: number
.length;
const children: unknown[]
i <
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.len;
let i: number
i++) {
let len: number
// eslint-disable-next-line @typescript-eslint/no-explicit-any const child =
let i: number
children
const child: any
[i] as any
const children: unknown[]
if (typeof child === 'string') {
let i: number
escapeToBuffer
const child: any
(child,
(alias) escapeToBuffer(str: string, buffer: StringBuffer): void import escapeToBuffer
buffer)
const child: string
} else if (typeof child === 'number') {
const buffer: StringBufferWithCallbacks
;(buffer[0] as string) +=
const child: any
child
const buffer: StringBufferWithCallbacks
} else if (typeof child === 'boolean' ||
const child: number
child === null ||
const child: any
child === undefined) {
const child: any
continue } else if (typeof child === 'object' &&
const child: any
(child as
const child: any
HtmlEscaped)
const child: any
.isEscaped) {
(alias) type HtmlEscaped = { isEscaped: true; callbacks?: HtmlEscapedCallback[]; } import HtmlEscaped
if ((child as
(property) isEscaped: true
HtmlEscapedString)
const child: any
.callbacks) {
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
buffer
(property) callbacks?: HtmlEscapedCallback[] | undefined
.unshift('',
const buffer: StringBufferWithCallbacks
(method) Array<string | Promise<string>>.unshift(...items: (string | Promise<string>)[]): number
Inserts new elements at the start of an array, and returns the new length of the array.@param
child)items
— Elements to insert at the start of the array.} else { const tmp =
const child: any
child.toString()
const tmp: any
if (tmp instanceof
const child: any
Promise) {
const tmp: any
buffer
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.unshift('',
const buffer: StringBufferWithCallbacks
(method) Array<string | Promise<string>>.unshift(...items: (string | Promise<string>)[]): number
Inserts new elements at the start of an array, and returns the new length of the array.@param
tmp)items
— Elements to insert at the start of the array.} else { buffer[0] +=
const tmp: Promise<any>
tmp
const buffer: StringBufferWithCallbacks
} } } else if (child instanceof
const tmp: any
Promise) {
const child: any
buffer
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.unshift('',
const buffer: StringBufferWithCallbacks
(method) Array<string | Promise<string>>.unshift(...items: (string | Promise<string>)[]): number
Inserts new elements at the start of an array, and returns the new length of the array.@param
child)items
— Elements to insert at the start of the array.} else { escapeToBuffer
const child: Promise<any>
(child.toString(),
(alias) escapeToBuffer(str: string, buffer: StringBuffer): void import escapeToBuffer
buffer)
const child: any
} } } buffer[0] +=
const buffer: StringBufferWithCallbacks
strings
const buffer: StringBufferWithCallbacks
[strings
(parameter) strings: TemplateStringsArray
.length - 1]
(parameter) strings: TemplateStringsArray
return buffer
(property) ReadonlyArray<string>.length: number
Gets the length of the array. This is a number one higher than the highest element defined in an array..length === 1
const buffer: StringBufferWithCallbacks
? 'callbacks' in buffer
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.? raw
const buffer: StringBufferWithCallbacks
(resolveCallbackSync
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
(raw
(alias) resolveCallbackSync(str: string | HtmlEscapedString): string import resolveCallbackSync
(buffer[0],
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
buffer
const buffer: StringBufferWithCallbacks
.callbacks)))
const buffer: StringBufferWithCallbacks
: raw
(property) callbacks: HtmlEscapedCallback[]
(buffer[0])
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
: stringBufferToString
const buffer: never
(buffer,
(alias) stringBufferToString(buffer: StringBuffer, callbacks: HtmlEscapedCallback[] | undefined): Promise<HtmlEscapedString> import stringBufferToString
buffer
const buffer: StringBufferWithCallbacks
.callbacks)
const buffer: StringBufferWithCallbacks
}
(property) callbacks: HtmlEscapedCallback[]
/** * @module * SSG Helper for Hono. */ export * from './ssg' export { X_HONO_DISABLE_SSG_HEADER_KEY,ssgParams,
(alias) const X_HONO_DISABLE_SSG_HEADER_KEY: "x-hono-disable-ssg" export X_HONO_DISABLE_SSG_HEADER_KEY
isSSGContext,
(alias) const ssgParams: SSGParamsMiddleware export ssgParams
Define SSG Route
(alias) const isSSGContext: (c: Context) => boolean export isSSGContext
@experimental
disableSSG,
isSSGContext
is an experimental feature. The API might be changed.
(alias) const disableSSG: () => MiddlewareHandler export disableSSG
@experimental
onlySSG,
disableSSG
is an experimental feature. The API might be changed.
(alias) const onlySSG: () => MiddlewareHandler export onlySSG
@experimental
} from './middleware'
onlySSG
is an experimental feature. The API might be changed.
import type { Context } from '../../context' import type { Env, MiddlewareHandler } from '../../types' export const SSG_CONTEXT = 'HONO_SSG_CONTEXT'export const X_HONO_DISABLE_SSG_HEADER_KEY = 'x-hono-disable-ssg'
const SSG_CONTEXT: "HONO_SSG_CONTEXT"
/** * @deprecated * Use `X_HONO_DISABLE_SSG_HEADER_KEY` instead. * This constant will be removed in the next minor version. */ export const SSG_DISABLED_RESPONSE = (() => {
const X_HONO_DISABLE_SSG_HEADER_KEY: "x-hono-disable-ssg"
const SSG_DISABLED_RESPONSE: Response
@deprecated
try { return new Response('SSG is disabled', {
UseX_HONO_DISABLE_SSG_HEADER_KEY
instead. This constant will be removed in the next minor version.status: 404,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.headers: {
(property) ResponseInit.status?: number | undefined
[X_HONO_DISABLE_SSG_HEADER_KEY]: 'true' },
(property) ResponseInit.headers?: HeadersInit | undefined
}) } catch { return null } })() as Response
const X_HONO_DISABLE_SSG_HEADER_KEY: "x-hono-disable-ssg"
interface SSGParam {
interface Response
This Fetch API interface represents the response to a request.[key: string]: string
interface SSGParam
} export type SSGParams =
(parameter) key: string
SSGParam[]
type SSGParams = SSGParam[]
interface SSGParamsMiddleware {
interface SSGParam
<E extends
interface SSGParamsMiddleware
Env =
(type parameter) E in <E extends Env = Env>(generateParams: (c: Context<E>) => SSGParams | Promise<SSGParams>): MiddlewareHandler<E>
Env>(
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
generateParams:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
(c:
(parameter) generateParams: (c: Context<E>) => SSGParams | Promise<SSGParams>
Context
(parameter) c: Context<E, any, {}>
<E>) =>
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
SSGParams |
(type parameter) E in <E extends Env = Env>(generateParams: (c: Context<E>) => SSGParams | Promise<SSGParams>): MiddlewareHandler<E>
Promise
type SSGParams = SSGParam[]
<SSGParams>
interface Promise<T>
Represents the completion of an asynchronous operation): MiddlewareHandler
type SSGParams = SSGParam[]
<E>
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
<E extends
(type parameter) E in <E extends Env = Env>(generateParams: (c: Context<E>) => SSGParams | Promise<SSGParams>): MiddlewareHandler<E>
Env =
(type parameter) E in <E extends Env = Env>(params: SSGParams): MiddlewareHandler<E>
Env>
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
(params:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
SSGParams):
(parameter) params: SSGParams
MiddlewareHandler
type SSGParams = SSGParam[]
<E>
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
} export type AddedSSGDataRequest =
(type parameter) E in <E extends Env = Env>(params: SSGParams): MiddlewareHandler<E>
Request & {
type AddedSSGDataRequest = Request & { ssgParams?: SSGParams; }
ssgParams?:
interface Request
This Fetch API interface represents a resource request.SSGParams
(property) ssgParams?: SSGParams | undefined
} /** * Define SSG Route */ export const ssgParams:
type SSGParams = SSGParam[]
SSGParamsMiddleware =
const ssgParams: SSGParamsMiddleware
Define SSG Route(params) => async
interface SSGParamsMiddleware
(c,
(parameter) params: ((c: Context<E>) => SSGParams | Promise<SSGParams>) | SSGParams
next) => {
(parameter) c: Context<E, string, {}>
;(c
(parameter) next: Next
.req
(parameter) c: Context<E, string, {}>
.raw as
(property) Context<E, string, {}>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
AddedSSGDataRequest)
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.ssgParams =
type AddedSSGDataRequest = Request & { ssgParams?: SSGParams; }
Array
(property) ssgParams?: SSGParams | undefined
.isArray
var Array: ArrayConstructor
(params) ?
(method) ArrayConstructor.isArray(arg: any): arg is any[]
params : await
(parameter) params: ((c: Context<E>) => SSGParams | Promise<SSGParams>) | SSGParams
params
(parameter) params: SSGParams
(c)
(parameter) params: (c: Context<E>) => SSGParams | Promise<SSGParams>
await next()
(parameter) c: Context<E, string, {}>
} /** * @experimental * `isSSGContext` is an experimental feature. * The API might be changed. */ export const isSSGContext =
(parameter) next: () => Promise<void>
const isSSGContext: (c: Context) => boolean
@experimental
(c:
isSSGContext
is an experimental feature. The API might be changed.Context): boolean => !
(parameter) c: Context<any, any, {}>
!c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.env?.
(parameter) c: Context<any, any, {}>
(property) Context<any, any, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
[SSG_CONTEXT]
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
/** * @experimental * `disableSSG` is an experimental feature. * The API might be changed. */ export const disableSSG = ():
const SSG_CONTEXT: "HONO_SSG_CONTEXT"
const disableSSG: () => MiddlewareHandler
@experimental
MiddlewareHandler =>
disableSSG
is an experimental feature. The API might be changed.async function disableSSG
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
(c,
(local function) disableSSG(c: Context<any, string, {}>, next: Next): Promise<Response | undefined>
next) {
(parameter) c: Context<any, string, {}>
if (isSSGContext
(parameter) next: Next
const isSSGContext: (c: Context) => boolean
@experimental
(c)) {
isSSGContext
is an experimental feature. The API might be changed.c
(parameter) c: Context<any, string, {}>
.header
(parameter) c: Context<any, string, {}>
(X_HONO_DISABLE_SSG_HEADER_KEY, 'true')
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
return c
const X_HONO_DISABLE_SSG_HEADER_KEY: "x-hono-disable-ssg"
.notFound()
(parameter) c: Context<any, string, {}>
(property) Context<any, string, {}>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
} await next()
ts app.get('/notfound', (c) => { return c.notFound() })
} /** * @experimental * `onlySSG` is an experimental feature. * The API might be changed. */ export const onlySSG = ():
(parameter) next: () => Promise<void>
const onlySSG: () => MiddlewareHandler
@experimental
MiddlewareHandler =>
onlySSG
is an experimental feature. The API might be changed.async function onlySSG
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
(c,
(local function) onlySSG(c: Context<any, string, {}>, next: Next): Promise<Response | undefined>
next) {
(parameter) c: Context<any, string, {}>
if (!isSSGContext
(parameter) next: Next
const isSSGContext: (c: Context) => boolean
@experimental
(c)) {
isSSGContext
is an experimental feature. The API might be changed.return c
(parameter) c: Context<any, string, {}>
.notFound()
(parameter) c: Context<any, string, {}>
(property) Context<any, string, {}>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
} await next()
ts app.get('/notfound', (c) => { return c.notFound() })
}
(parameter) next: () => Promise<void>
import { replaceUrlParam } from '../../client/utils' import type { Hono } from '../../hono' import type { Env, Schema } from '../../types' import { createPool } from '../../utils/concurrent' import { getExtension } from '../../utils/mime' import type { AddedSSGDataRequest, SSGParams } from './middleware' import { SSG_CONTEXT, X_HONO_DISABLE_SSG_HEADER_KEY } from './middleware' import { dirname, filterStaticGenerateRoutes, joinPaths } from './utils' const DEFAULT_CONCURRENCY = 2 // default concurrency for ssg// 'default_content_type' is designed according to Bun's performance optimization, // which omits Content-Type by default for text responses. // This is based on benchmarks showing performance gains without Content-Type. // In Hono, using `c.text()` without a Content-Type implicitly assumes 'text/plain; charset=UTF-8'. // This approach maintains performance consistency across different environments. // For details, see GitHub issues: oven-sh/bun#8530 and https://github.com/honojs/hono/issues/2284. const DEFAULT_CONTENT_TYPE = 'text/plain'
const DEFAULT_CONCURRENCY: 2
/** * @experimental * `FileSystemModule` is an experimental feature. * The API might be changed. */ export interface FileSystemModule {
const DEFAULT_CONTENT_TYPE: "text/plain"
interface FileSystemModule
@experimental
writeFile
FileSystemModule
is an experimental feature. The API might be changed.(path: string,
(method) FileSystemModule.writeFile(path: string, data: string | Uint8Array): Promise<void>
data: string |
(parameter) path: string
Uint8Array):
(parameter) data: string | Uint8Array
Promise
interface Uint8Array
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.mkdir
interface Promise<T>
Represents the completion of an asynchronous operation(path: string,
(method) FileSystemModule.mkdir(path: string, options: { recursive: boolean; }): Promise<void | string>
options: {
(parameter) path: string
recursive: boolean }):
(parameter) options: { recursive: boolean; }
Promise
(property) recursive: boolean
} /** * @experimental * `ToSSGResult` is an experimental feature. * The API might be changed. */ export interface ToSSGResult {
interface Promise<T>
Represents the completion of an asynchronous operation
interface ToSSGResult
@experimental
success: boolean
ToSSGResult
is an experimental feature. The API might be changed.files: string[]
(property) ToSSGResult.success: boolean
error?:
(property) ToSSGResult.files: string[]
Error
(property) ToSSGResult.error?: Error | undefined
} const generateFilePath = (
interface Error
routePath: string,
const generateFilePath: (routePath: string, outDir: string, mimeType: string, extensionMap?: Record<string, string>) => string
outDir: string,
(parameter) routePath: string
mimeType: string,
(parameter) outDir: string
extensionMap?:
(parameter) mimeType: string
Record
(parameter) extensionMap: Record<string, string> | undefined
): string => { const extension =
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TdetermineExtension
const extension: string
(mimeType,
const determineExtension: (mimeType: string, userExtensionMap?: Record<string, string>) => string
extensionMap)
(parameter) mimeType: string
if (routePath
(parameter) extensionMap: Record<string, string> | undefined
.endsWith(`.$
(parameter) routePath: string
{extension}`)) {
(method) String.endsWith(searchString: string, endPosition?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at endPosition – length(this). Otherwise returns false.return joinPaths
const extension: string
(outDir,
(alias) joinPaths(...paths: string[]): string import joinPaths
routePath)
(parameter) outDir: string
} if (routePath === '/') {
(parameter) routePath: string
return joinPaths
(parameter) routePath: string
(outDir, `index.$
(alias) joinPaths(...paths: string[]): string import joinPaths
{extension}`)
(parameter) outDir: string
} if (routePath
const extension: string
.endsWith('/')) {
(parameter) routePath: string
return joinPaths
(method) String.endsWith(searchString: string, endPosition?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at endPosition – length(this). Otherwise returns false.(outDir,
(alias) joinPaths(...paths: string[]): string import joinPaths
routePath, `index.$
(parameter) outDir: string
{extension}`)
(parameter) routePath: string
} return joinPaths
const extension: string
(outDir, `$
(alias) joinPaths(...paths: string[]): string import joinPaths
{routePath}.$
(parameter) outDir: string
{extension}`)
(parameter) routePath: string
} const parseResponseContent = async
const extension: string
(response:
const parseResponseContent: (response: Response) => Promise<string | ArrayBuffer>
Response):
(parameter) response: Response
Promise
interface Response
This Fetch API interface represents the response to a request.ArrayBuffer> => {
interface Promise<T>
Represents the completion of an asynchronous operationconst contentType =
interface ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.response
const contentType: string | null
.headers
(parameter) response: Response
.get('Content-Type')
(property) Response.headers: Headers
MDN Referencetry { if (contentType?
(method) Headers.get(name: string): string | null
MDN Reference.includes('text') ||
const contentType: string | null
(method) String.includes(searchString: string, position?: number): boolean
Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.@param
searchString
— search string@param
contentType?position
— If position is undefined, 0 is assumed, so as to search all of the String..includes('json')) {
const contentType: string | null
(method) String.includes(searchString: string, position?: number): boolean
Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.@param
searchString
— search string@param
return await responseposition
— If position is undefined, 0 is assumed, so as to search all of the String..text()
(parameter) response: Response
} else { return await response
(method) Body.text(): Promise<string>
MDN Reference.arrayBuffer()
(parameter) response: Response
} } catch (error) {
(method) Body.arrayBuffer(): Promise<ArrayBuffer>
MDN Referencethrow new Error(
(local var) error: unknown
`Error processing response: ${error instanceof
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
Error ?
(local var) error: unknown
error
var Error: ErrorConstructor
.message : 'Unknown error'}`
(local var) error: Error
) } } export const defaultExtensionMap:
(property) Error.message: string
Record
const defaultExtensionMap: Record<string, string>
= { 'text/html': 'html', 'text/xml': 'xml', 'application/xml': 'xml', 'application/yaml': 'yaml', } const determineExtension = (
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TmimeType: string,
const determineExtension: (mimeType: string, userExtensionMap?: Record<string, string>) => string
userExtensionMap?:
(parameter) mimeType: string
Record
(parameter) userExtensionMap: Record<string, string> | undefined
): string => { const extensionMap =
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type TuserExtensionMap ||
const extensionMap: Record<string, string>
defaultExtensionMap
(parameter) userExtensionMap: Record<string, string> | undefined
if (mimeType in
const defaultExtensionMap: Record<string, string>
extensionMap) {
(parameter) mimeType: string
return extensionMap
const extensionMap: Record<string, string>
[mimeType]
const extensionMap: Record<string, string>
} return getExtension
(parameter) mimeType: string
(mimeType) || 'html'
(alias) getExtension(mimeType: string): string | undefined import getExtension
} export type BeforeRequestHook =
(parameter) mimeType: string
(req:
type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>
Request) =>
(parameter) req: Request
Request | false |
interface Request
This Fetch API interface represents a resource request.Promise
interface Request
This Fetch API interface represents a resource request.<Request | false>
interface Promise<T>
Represents the completion of an asynchronous operationexport type AfterResponseHook =
interface Request
This Fetch API interface represents a resource request.(res:
type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>
Response) =>
(parameter) res: Response
Response | false |
interface Response
This Fetch API interface represents the response to a request.Promise
interface Response
This Fetch API interface represents the response to a request.<Response | false>
interface Promise<T>
Represents the completion of an asynchronous operationexport type AfterGenerateHook =
interface Response
This Fetch API interface represents the response to a request.(result:
type AfterGenerateHook = (result: ToSSGResult) => void | Promise<void>
ToSSGResult) => void |
(parameter) result: ToSSGResult
interface ToSSGResult
@experimental
Promise
ToSSGResult
is an experimental feature. The API might be changed.export const combineBeforeRequestHooks = (
interface Promise<T>
Represents the completion of an asynchronous operationhooks:
const combineBeforeRequestHooks: (hooks: BeforeRequestHook | BeforeRequestHook[]) => BeforeRequestHook
BeforeRequestHook |
(parameter) hooks: BeforeRequestHook | BeforeRequestHook[]
BeforeRequestHook[]
type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>
): BeforeRequestHook => {
type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>
if (!Array
type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>
.isArray
var Array: ArrayConstructor
(hooks)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
return hooks
(parameter) hooks: BeforeRequestHook | BeforeRequestHook[]
} return async (req:
(parameter) hooks: BeforeRequestHook
Request):
(parameter) req: Request
Promise
interface Request
This Fetch API interface represents a resource request.<Request | false> => {
interface Promise<T>
Represents the completion of an asynchronous operationlet currentReq =
interface Request
This Fetch API interface represents a resource request.req
let currentReq: Request
for (const hook of
(parameter) req: Request
hooks) {
const hook: BeforeRequestHook
const result = await
(parameter) hooks: BeforeRequestHook[]
hook
const result: false | Request
(currentReq)
const hook: (req: Request) => Request | false | Promise<Request | false>
if (result === false) {
let currentReq: Request
return false } if (result instanceof
const result: false | Request
Request) {
const result: Request
currentReq =
var Request: { new (input: RequestInfo | URL, init?: RequestInit): Request; prototype: Request; }
This Fetch API interface represents a resource request.result
let currentReq: Request
} } return currentReq
const result: Request
} } export const combineAfterResponseHooks = (
let currentReq: Request
hooks:
const combineAfterResponseHooks: (hooks: AfterResponseHook | AfterResponseHook[]) => AfterResponseHook
AfterResponseHook |
(parameter) hooks: AfterResponseHook | AfterResponseHook[]
AfterResponseHook[]
type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>
): AfterResponseHook => {
type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>
if (!Array
type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>
.isArray
var Array: ArrayConstructor
(hooks)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
return hooks
(parameter) hooks: AfterResponseHook | AfterResponseHook[]
} return async (res:
(parameter) hooks: AfterResponseHook
Response):
(parameter) res: Response
Promise
interface Response
This Fetch API interface represents the response to a request.<Response | false> => {
interface Promise<T>
Represents the completion of an asynchronous operationlet currentRes =
interface Response
This Fetch API interface represents the response to a request.res
let currentRes: Response
for (const hook of
(parameter) res: Response
hooks) {
const hook: AfterResponseHook
const result = await
(parameter) hooks: AfterResponseHook[]
hook
const result: false | Response
(currentRes)
const hook: (res: Response) => Response | false | Promise<Response | false>
if (result === false) {
let currentRes: Response
return false } if (result instanceof
const result: false | Response
Response) {
const result: Response
currentRes =
var Response: { new (body?: BodyInit | null, init?: ResponseInit): Response; prototype: Response; error(): Response; json(data: any, init?: ResponseInit): Response; redirect(url: string | URL, status?: number): Response; }
This Fetch API interface represents the response to a request.result
let currentRes: Response
} } return currentRes
const result: Response
} } export const combineAfterGenerateHooks = (
let currentRes: Response
hooks:
const combineAfterGenerateHooks: (hooks: AfterGenerateHook | AfterGenerateHook[]) => AfterGenerateHook
AfterGenerateHook |
(parameter) hooks: AfterGenerateHook | AfterGenerateHook[]
AfterGenerateHook[]
type AfterGenerateHook = (result: ToSSGResult) => void | Promise<void>
): AfterGenerateHook => {
type AfterGenerateHook = (result: ToSSGResult) => void | Promise<void>
if (!Array
type AfterGenerateHook = (result: ToSSGResult) => void | Promise<void>
.isArray
var Array: ArrayConstructor
(hooks)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
return hooks
(parameter) hooks: AfterGenerateHook | AfterGenerateHook[]
} return async (result:
(parameter) hooks: AfterGenerateHook
ToSSGResult):
(parameter) result: ToSSGResult
interface ToSSGResult
@experimental
Promise
ToSSGResult
is an experimental feature. The API might be changed.=> { for (const hook of
interface Promise<T>
Represents the completion of an asynchronous operationhooks) {
const hook: AfterGenerateHook
await hook
(parameter) hooks: AfterGenerateHook[]
(result)
const hook: (result: ToSSGResult) => void | Promise<void>
} } } export interface ToSSGOptions {
(parameter) result: ToSSGResult
dir?: string
interface ToSSGOptions
beforeRequestHook?:
(property) ToSSGOptions.dir?: string | undefined
BeforeRequestHook |
(property) ToSSGOptions.beforeRequestHook?: BeforeRequestHook | BeforeRequestHook[] | undefined
BeforeRequestHook[]
type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>
afterResponseHook?:
type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>
AfterResponseHook |
(property) ToSSGOptions.afterResponseHook?: AfterResponseHook | AfterResponseHook[] | undefined
AfterResponseHook[]
type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>
afterGenerateHook?:
type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>
AfterGenerateHook |
(property) ToSSGOptions.afterGenerateHook?: AfterGenerateHook | AfterGenerateHook[] | undefined
AfterGenerateHook[]
type AfterGenerateHook = (result: ToSSGResult) => void | Promise<void>
concurrency?: number
type AfterGenerateHook = (result: ToSSGResult) => void | Promise<void>
extensionMap?:
(property) ToSSGOptions.concurrency?: number | undefined
Record
(property) ToSSGOptions.extensionMap?: Record<string, string> | undefined
} /** * @experimental * `fetchRoutesContent` is an experimental feature. * The API might be changed. */ export const fetchRoutesContent = function* <
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T
const fetchRoutesContent: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>, beforeRequestHook?: BeforeRequestHook, afterResponseHook?: AfterResponseHook, concurrency?: number) => Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>> | undefined>>
@experimental
E extends
fetchRoutesContent
is an experimental feature. The API might be changed.Env =
(type parameter) E in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>, beforeRequestHook?: BeforeRequestHook, afterResponseHook?: AfterResponseHook, concurrency?: number): Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>> | undefined>>
Env,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
S extends
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Schema = {},
(type parameter) S in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>, beforeRequestHook?: BeforeRequestHook, afterResponseHook?: AfterResponseHook, concurrency?: number): Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>> | undefined>>
BasePath extends string = '/'
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
>( app:
(type parameter) BasePath in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>, beforeRequestHook?: BeforeRequestHook, afterResponseHook?: AfterResponseHook, concurrency?: number): Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>> | undefined>>
Hono
(parameter) app: Hono<E, S, BasePath>
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E,BasePath
— The base path type.S,
(type parameter) E in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>, beforeRequestHook?: BeforeRequestHook, afterResponseHook?: AfterResponseHook, concurrency?: number): Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>> | undefined>>
BasePath>,
(type parameter) S in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>, beforeRequestHook?: BeforeRequestHook, afterResponseHook?: AfterResponseHook, concurrency?: number): Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>> | undefined>>
beforeRequestHook?:
(type parameter) BasePath in <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>, beforeRequestHook?: BeforeRequestHook, afterResponseHook?: AfterResponseHook, concurrency?: number): Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>> | undefined>>
BeforeRequestHook,
(parameter) beforeRequestHook: BeforeRequestHook | undefined
afterResponseHook?:
type BeforeRequestHook = (req: Request) => Request | false | Promise<Request | false>
AfterResponseHook,
(parameter) afterResponseHook: AfterResponseHook | undefined
concurrency?: number
type AfterResponseHook = (res: Response) => Response | false | Promise<Response | false>
): Generator<
(parameter) concurrency: number | undefined
Promise<
interface Generator<T = unknown, TReturn = any, TNext = any>
| Generator<
interface Promise<T>
Represents the completion of an asynchronous operationPromise<{
interface Generator<T = unknown, TReturn = any, TNext = any>
routePath: string;
interface Promise<T>
Represents the completion of an asynchronous operationmimeType: string;
(property) routePath: string
content: string |
(property) mimeType: string
ArrayBuffer } | undefined>
(property) content: string | ArrayBuffer
> | undefined > > { const baseURL = 'http://localhost'
interface ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.const pool =
const baseURL: "http://localhost"
createPool({
const pool: Pool
concurrency })
(alias) createPool({ concurrency, interval, }?: { concurrency?: number; interval?: number; }): Pool import createPool
for (const route of
(property) concurrency?: number | undefined
filterStaticGenerateRoutes
const route: FilterStaticGenerateRouteData
(app)) {
(alias) filterStaticGenerateRoutes<E>(hono: Hono<E, BlankSchema, "/">): FilterStaticGenerateRouteData[] import filterStaticGenerateRoutes
// GET Route Info const thisRouteBaseURL = new
(parameter) app: Hono<E, S, BasePath>
URL
const thisRouteBaseURL: string
(route
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs..path,
const route: FilterStaticGenerateRouteData
baseURL)
(property) FilterStaticGenerateRouteData.path: string
.toString()
const baseURL: "http://localhost"
let forGetInfoURLRequest = new
(method) URL.toString(): string
Request
let forGetInfoURLRequest: AddedSSGDataRequest
(thisRouteBaseURL) as
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.AddedSSGDataRequest
const thisRouteBaseURL: string
// eslint-disable-next-line no-async-promise-executor yield new Promise(async
(alias) type AddedSSGDataRequest = Request & { ssgParams?: SSGParams; } import AddedSSGDataRequest
var Promise: PromiseConstructor new <Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined>(executor: (resolve: (value: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | PromiseLike<...> | undefined) => void, reject: (reason?: any) => void) => void) => Promise<...>
Creates a new Promise.@param
(resolveGetInfo,executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.rejectGetInfo) => {
(parameter) resolveGetInfo: (value: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | PromiseLike<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined> | undefined) => void
try { if (beforeRequestHook) {
(parameter) rejectGetInfo: (reason?: any) => void
const maybeRequest = await
(parameter) beforeRequestHook: BeforeRequestHook | undefined
beforeRequestHook
const maybeRequest: false | Request
(forGetInfoURLRequest)
(parameter) beforeRequestHook: (req: Request) => Request | false | Promise<Request | false>
if (!maybeRequest) {
let forGetInfoURLRequest: AddedSSGDataRequest
resolveGetInfo(undefined)
const maybeRequest: false | Request
return } forGetInfoURLRequest =
(parameter) resolveGetInfo: (value: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | PromiseLike<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined> | undefined) => void
maybeRequest as unknown as
let forGetInfoURLRequest: AddedSSGDataRequest
AddedSSGDataRequest
const maybeRequest: Request
} await pool
(alias) type AddedSSGDataRequest = Request & { ssgParams?: SSGParams; } import AddedSSGDataRequest
.run(() =>
const pool: Pool
app
(method) Pool.run<Response | Promise<Response>>(fn: () => Response | Promise<Response>): Promise<Response | Promise<Response>>
.fetch
(parameter) app: Hono<E, S, BasePath>
(property) Hono<E, S, BasePath>.fetch: (request: Request, Env?: {} | E["Bindings"] | undefined, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(forGetInfoURLRequest))if (!forGetInfoURLRequest
let forGetInfoURLRequest: AddedSSGDataRequest
.ssgParams) {
let forGetInfoURLRequest: AddedSSGDataRequest
if (isDynamicRoute
(property) ssgParams?: SSGParams | undefined
(route
const isDynamicRoute: (path: string) => boolean
.path)) {
const route: FilterStaticGenerateRouteData
resolveGetInfo(undefined)
(property) FilterStaticGenerateRouteData.path: string
return } forGetInfoURLRequest
(parameter) resolveGetInfo: (value: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | PromiseLike<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined> | undefined) => void
.ssgParams = [{}]
let forGetInfoURLRequest: AddedSSGDataRequest
} const requestInit = {
(property) ssgParams?: SSGParams | undefined
method:
const requestInit: { method: string; headers: Headers; }
forGetInfoURLRequest
(property) method: string
.method,
let forGetInfoURLRequest: AddedSSGDataRequest
headers:
(property) Request.method: string
Returns request's HTTP method, which is "GET" by default.forGetInfoURLRequest
(property) headers: Headers
.headers,
let forGetInfoURLRequest: AddedSSGDataRequest
} resolveGetInfo(
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.(function* () { for (const param of
(parameter) resolveGetInfo: (value: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | PromiseLike<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined> | undefined) => void
forGetInfoURLRequest
const param: SSGParam
.ssgParams as
let forGetInfoURLRequest: AddedSSGDataRequest
SSGParams) {
(property) ssgParams?: SSGParams | undefined
// eslint-disable-next-line no-async-promise-executor yield new Promise(async
(alias) type SSGParams = SSGParam[] import SSGParams
var Promise: PromiseConstructor new <{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>(executor: (resolve: (value: { routePath: string; mimeType: string; content: string | ArrayBuffer; } | PromiseLike<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined> | undefined) => void, reject: (reason?: any) => void) => void) => Promise<...>
Creates a new Promise.@param
(resolveReq,executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.rejectReq) => {
(parameter) resolveReq: (value: { routePath: string; mimeType: string; content: string | ArrayBuffer; } | PromiseLike<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined> | undefined) => void
try { const replacedUrlParam =
(parameter) rejectReq: (reason?: any) => void
replaceUrlParam
const replacedUrlParam: string
(route
(alias) replaceUrlParam(urlString: string, params: Record<string, string | undefined>): string import replaceUrlParam
.path,
const route: FilterStaticGenerateRouteData
param)
(property) FilterStaticGenerateRouteData.path: string
let response = await
const param: SSGParam
pool
let response: Response
.run(() =>
const pool: Pool
app
(method) Pool.run<Response | Promise<Response>>(fn: () => Response | Promise<Response>): Promise<Response | Promise<Response>>
.request
(parameter) app: Hono<E, S, BasePath>
(property) Hono<E, S, BasePath>.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | E["Bindings"] | undefined, 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
(replacedUrlParam,requestInit, {
const replacedUrlParam: string
[SSG_CONTEXT]: true,
const requestInit: { method: string; headers: Headers; }
}) ) if (response
(alias) const SSG_CONTEXT: "HONO_SSG_CONTEXT" import SSG_CONTEXT
.headers
let response: Response
.get
(property) Response.headers: Headers
MDN Reference(X_HONO_DISABLE_SSG_HEADER_KEY)) {
(method) Headers.get(name: string): string | null
MDN ReferenceresolveReq(undefined)
(alias) const X_HONO_DISABLE_SSG_HEADER_KEY: "x-hono-disable-ssg" import X_HONO_DISABLE_SSG_HEADER_KEY
return } if (afterResponseHook) {
(parameter) resolveReq: (value: { routePath: string; mimeType: string; content: string | ArrayBuffer; } | PromiseLike<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined> | undefined) => void
const maybeResponse = await
(parameter) afterResponseHook: AfterResponseHook | undefined
afterResponseHook
const maybeResponse: false | Response
(response)
(parameter) afterResponseHook: (res: Response) => Response | false | Promise<Response | false>
if (!maybeResponse) {
let response: Response
resolveReq(undefined)
const maybeResponse: false | Response
return } response =
(parameter) resolveReq: (value: { routePath: string; mimeType: string; content: string | ArrayBuffer; } | PromiseLike<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined> | undefined) => void
maybeResponse
let response: Response
} const mimeType =
const maybeResponse: Response
response
const mimeType: string
.headers
let response: Response
.get('Content-Type')?
(property) Response.headers: Headers
MDN Reference.split(';')[0] ||
(method) Headers.get(name: string): string | null
MDN Reference
(method) String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
separator
— A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.@param
DEFAULT_CONTENT_TYPElimit
— A value used to limit the number of elements returned in the array.const content = await
const DEFAULT_CONTENT_TYPE: "text/plain"
parseResponseContent
const content: string | ArrayBuffer
(response)
const parseResponseContent: (response: Response) => Promise<string | ArrayBuffer>
resolveReq({
let response: Response
routePath:
(parameter) resolveReq: (value: { routePath: string; mimeType: string; content: string | ArrayBuffer; } | PromiseLike<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined> | undefined) => void
replacedUrlParam,
(property) routePath: string
mimeType,
const replacedUrlParam: string
content,
(property) mimeType: string
}) } catch (error) {
(property) content: string | ArrayBuffer
rejectReq
(local var) error: unknown
(error)
(parameter) rejectReq: (reason?: any) => void
} }) } })() ) } catch (error) {
(local var) error: unknown
rejectGetInfo
(local var) error: unknown
(error)
(parameter) rejectGetInfo: (reason?: any) => void
} }) } } const isDynamicRoute =
(local var) error: unknown
(path: string): boolean => {
const isDynamicRoute: (path: string) => boolean
return path
(parameter) path: string
.split('/')
(parameter) path: string
(method) String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
separator
— A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.@param
.some(limit
— A value used to limit the number of elements returned in the array.
(method) Array<string>.some(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean
Determines whether the specified callback function returns true for any element of an array.@param
predicate
A function that accepts up to three arguments. The some method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value true, or until the end of the array.@param
(segment) =>thisArg
An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.segment
(parameter) segment: string
.startsWith(':') ||
(parameter) segment: string
segment
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false..includes('*'))
(parameter) segment: string
(method) String.includes(searchString: string, position?: number): boolean
Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.@param
searchString
— search string@param
} /** * @experimental * `saveContentToFile` is an experimental feature. * The API might be changed. */ const createdDirs:position
— If position is undefined, 0 is assumed, so as to search all of the String.
const createdDirs: Set<string>
@experimental
Set
saveContentToFile
is an experimental feature. The API might be changed.= new Set()
interface Set<T>
export const saveContentToFile = async (
var Set: SetConstructor new <string>(iterable?: Iterable<string> | null | undefined) => Set<string> (+1 overload)
data:
const saveContentToFile: (data: Promise<{ routePath: string; content: string | ArrayBuffer; mimeType: string; } | undefined>, fsModule: FileSystemModule, outDir: string, extensionMap?: Record<string, string>) => Promise<string | undefined>
Promise<{
(parameter) data: Promise<{ routePath: string; content: string | ArrayBuffer; mimeType: string; } | undefined>
routePath: string;
interface Promise<T>
Represents the completion of an asynchronous operationcontent: string |
(property) routePath: string
ArrayBuffer;
(property) content: string | ArrayBuffer
mimeType: string } | undefined>,
interface ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.fsModule:
(property) mimeType: string
FileSystemModule,
(parameter) fsModule: FileSystemModule
interface FileSystemModule
@experimental
outDir: string,
FileSystemModule
is an experimental feature. The API might be changed.extensionMap?:
(parameter) outDir: string
Record
(parameter) extensionMap: Record<string, string> | undefined
): Promise
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T=> { const awaitedData = await
interface Promise<T>
Represents the completion of an asynchronous operationdata
const awaitedData: { routePath: string; content: string | ArrayBuffer; mimeType: string; } | undefined
if (!awaitedData) {
(parameter) data: Promise<{ routePath: string; content: string | ArrayBuffer; mimeType: string; } | undefined>
return } const { routePath,
const awaitedData: { routePath: string; content: string | ArrayBuffer; mimeType: string; } | undefined
content,
const routePath: string
mimeType } =
const content: string | ArrayBuffer
awaitedData
const mimeType: string
const filePath =
const awaitedData: { routePath: string; content: string | ArrayBuffer; mimeType: string; }
generateFilePath
const filePath: string
(routePath,
const generateFilePath: (routePath: string, outDir: string, mimeType: string, extensionMap?: Record<string, string>) => string
outDir,
const routePath: string
mimeType,
(parameter) outDir: string
extensionMap)
const mimeType: string
const dirPath =
(parameter) extensionMap: Record<string, string> | undefined
dirname
const dirPath: string
(alias) dirname(path: string): string import dirname
Get dirname@param
path
— File Path@returns — Parent dir path
(filePath)if (!createdDirs
const filePath: string
const createdDirs: Set<string>
@experimental
.has
saveContentToFile
is an experimental feature. The API might be changed.
(method) Set<string>.has(value: string): boolean
@returns — a boolean indicating whether an element with the specified value exists in the Set or not.
(dirPath)) {await fsModule
const dirPath: string
.mkdir
(parameter) fsModule: FileSystemModule
(dirPath, {
(method) FileSystemModule.mkdir(path: string, options: { recursive: boolean; }): Promise<void | string>
recursive: true })
const dirPath: string
createdDirs
(property) recursive: boolean
const createdDirs: Set<string>
@experimental
.add
saveContentToFile
is an experimental feature. The API might be changed.(dirPath)
(method) Set<string>.add(value: string): Set<string>
Appends a new element with a specified value to the end of the Set.} if (typeof content === 'string') {
const dirPath: string
await fsModule
const content: string | ArrayBuffer
.writeFile
(parameter) fsModule: FileSystemModule
(filePath,
(method) FileSystemModule.writeFile(path: string, data: string | Uint8Array): Promise<void>
content)
const filePath: string
} else if (content instanceof
const content: string
ArrayBuffer) {
const content: ArrayBuffer
await fsModule
var ArrayBuffer: ArrayBufferConstructor
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed..writeFile
(parameter) fsModule: FileSystemModule
(filePath, new
(method) FileSystemModule.writeFile(path: string, data: string | Uint8Array): Promise<void>
Uint8Array
const filePath: string
(content))
var Uint8Array: Uint8ArrayConstructor new (array: ArrayLike<number> | ArrayBufferLike) => Uint8Array (+4 overloads)
} return filePath
const content: ArrayBuffer
} /** * @experimental * `ToSSGInterface` is an experimental feature. * The API might be changed. */ export interface ToSSGInterface {
const filePath: string
interface ToSSGInterface
@experimental
( // eslint-disable-next-line @typescript-eslint/no-explicit-any app:
ToSSGInterface
is an experimental feature. The API might be changed.Hono
(parameter) app: Hono<any, any, any>
, fsModule:
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.FileSystemModule,
(parameter) fsModule: FileSystemModule
interface FileSystemModule
@experimental
options?:
FileSystemModule
is an experimental feature. The API might be changed.ToSSGOptions
(parameter) options: ToSSGOptions | undefined
): Promise
interface ToSSGOptions
<ToSSGResult>
interface Promise<T>
Represents the completion of an asynchronous operation
interface ToSSGResult
@experimental
} /** * @experimental * `ToSSGAdaptorInterface` is an experimental feature. * The API might be changed. */ export interface ToSSGAdaptorInterface<
ToSSGResult
is an experimental feature. The API might be changed.
interface ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
@experimental
E extends
ToSSGAdaptorInterface
is an experimental feature. The API might be changed.Env =
(type parameter) E in ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
Env,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
S extends
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Schema = {},
(type parameter) S in ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath extends string = '/'
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
> { (app:
(type parameter) BasePath in ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
Hono
(parameter) app: Hono<E, S, BasePath>
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E,BasePath
— The base path type.S,
(type parameter) E in ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>,
(type parameter) S in ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
options?:
(type parameter) BasePath in ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
ToSSGOptions):
(parameter) options: ToSSGOptions | undefined
Promise
interface ToSSGOptions
<ToSSGResult>
interface Promise<T>
Represents the completion of an asynchronous operation
interface ToSSGResult
@experimental
} /** * @experimental * `toSSG` is an experimental feature. * The API might be changed. */ export const toSSG:
ToSSGResult
is an experimental feature. The API might be changed.
const toSSG: ToSSGInterface
@experimental
ToSSGInterface = async
toSSG
is an experimental feature. The API might be changed.
interface ToSSGInterface
@experimental
(app,
ToSSGInterface
is an experimental feature. The API might be changed.fs,
(parameter) app: Hono<any, any, any>
options) => {
(parameter) fs: FileSystemModule
let result:
(parameter) options: ToSSGOptions | undefined
ToSSGResult | undefined
let result: ToSSGResult | undefined
interface ToSSGResult
@experimental
const getInfoPromises:
ToSSGResult
is an experimental feature. The API might be changed.Promise
const getInfoPromises: Promise<unknown>[]
[] = [] const savePromises:
interface Promise<T>
Represents the completion of an asynchronous operationPromise
const savePromises: Promise<string | undefined>[]
[] = [] try { const outputDir =
interface Promise<T>
Represents the completion of an asynchronous operationoptions?
const outputDir: string
.dir ?? './static'
(parameter) options: ToSSGOptions | undefined
const concurrency =
(property) ToSSGOptions.dir?: string | undefined
options?
const concurrency: number
.concurrency ??
(parameter) options: ToSSGOptions | undefined
DEFAULT_CONCURRENCY
(property) ToSSGOptions.concurrency?: number | undefined
const combinedBeforeRequestHook =
const DEFAULT_CONCURRENCY: 2
combineBeforeRequestHooks(
const combinedBeforeRequestHook: BeforeRequestHook
options?
const combineBeforeRequestHooks: (hooks: BeforeRequestHook | BeforeRequestHook[]) => BeforeRequestHook
.beforeRequestHook || (
(parameter) options: ToSSGOptions | undefined
(req) =>
(property) ToSSGOptions.beforeRequestHook?: BeforeRequestHook | BeforeRequestHook[] | undefined
req)
(parameter) req: Request
) const combinedAfterResponseHook =
(parameter) req: Request
combineAfterResponseHooks(
const combinedAfterResponseHook: AfterResponseHook
options?
const combineAfterResponseHooks: (hooks: AfterResponseHook | AfterResponseHook[]) => AfterResponseHook
.afterResponseHook || (
(parameter) options: ToSSGOptions | undefined
(req) =>
(property) ToSSGOptions.afterResponseHook?: AfterResponseHook | AfterResponseHook[] | undefined
req)
(parameter) req: Response
) const getInfoGen =
(parameter) req: Response
fetchRoutesContent(
const getInfoGen: Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined>, any, any>
const fetchRoutesContent: <any, any, any>(app: Hono<any, any, any>, beforeRequestHook?: BeforeRequestHook, afterResponseHook?: AfterResponseHook, concurrency?: number) => Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>> | undefined>>
@experimental
app,
fetchRoutesContent
is an experimental feature. The API might be changed.combinedBeforeRequestHook,
(parameter) app: Hono<any, any, any>
combinedAfterResponseHook,
const combinedBeforeRequestHook: BeforeRequestHook
concurrency
const combinedAfterResponseHook: AfterResponseHook
) for (const getInfo of
const concurrency: number
getInfoGen) {
const getInfo: Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined>
getInfoPromises
const getInfoGen: Generator<Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined>, any, any>
.push(
const getInfoPromises: Promise<unknown>[]
(method) Array<Promise<unknown>>.push(...items: Promise<unknown>[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
getInfoitems
— New elements to add to the array..then(
const getInfo: Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined>
(method) Promise<Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined>.then<void, unknown>(onfulfilled?: ((value: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined) => void | PromiseLike<...>) | null | undefined, onrejected?: ((reason: any) => unknown) | ... 1 more ... | undefined): Promise<...>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(getContentGen) => {if (!getContentGen) {
(parameter) getContentGen: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined
return } for (const content of
(parameter) getContentGen: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any> | undefined
getContentGen) {
const content: Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>
savePromises
(parameter) getContentGen: Generator<Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>, any, any>
.push
const savePromises: Promise<string | undefined>[]
(method) Array<Promise<string | undefined>>.push(...items: Promise<string | undefined>[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(saveContentToFileitems
— New elements to add to the array.(content,
const saveContentToFile: (data: Promise<{ routePath: string; content: string | ArrayBuffer; mimeType: string; } | undefined>, fsModule: FileSystemModule, outDir: string, extensionMap?: Record<string, string>) => Promise<string | undefined>
fs,
const content: Promise<{ routePath: string; mimeType: string; content: string | ArrayBuffer; } | undefined>
outputDir)
(parameter) fs: FileSystemModule
.catch(
const outputDir: string
(method) Promise<string | undefined>.catch<any>(onrejected?: ((reason: any) => any) | null | undefined): Promise<any>
Attaches a callback for only the rejection of the Promise.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of the callback.
(e) =>e))
(parameter) e: any
} }) ) } await Promise
(parameter) e: any
.all
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
(method) PromiseConstructor.all<Promise<unknown>[]>(values: Promise<unknown>[]): Promise<unknown[]> (+1 overload)
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.@param
values
— An array of Promises.@returns — A new Promise.
(getInfoPromises)const files: string[] = []
const getInfoPromises: Promise<unknown>[]
for (const savePromise of
const files: string[]
savePromises) {
const savePromise: Promise<string | undefined>
const fileOrError = await
const savePromises: Promise<string | undefined>[]
savePromise
const fileOrError: string | undefined
if (typeof fileOrError === 'string') {
const savePromise: Promise<string | undefined>
files
const fileOrError: string | undefined
.push
const files: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(fileOrError)items
— New elements to add to the array.} else if (fileOrError) {
const fileOrError: string
throw fileOrError
const fileOrError: undefined
} } result = {
const fileOrError: never
success: true,
let result: ToSSGResult | undefined
files }
(property) ToSSGResult.success: boolean
} catch (error) {
(property) ToSSGResult.files: string[]
const errorObj =
(local var) error: unknown
error instanceof
const errorObj: Error
Error ?
(local var) error: unknown
error : new
var Error: ErrorConstructor
Error
(local var) error: Error
(String
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
(error))
var String: StringConstructor (value?: any) => string
Allows manipulation and formatting of text strings and determination and location of substrings within strings.result = {
(local var) error: unknown
success: false,
let result: ToSSGResult | undefined
files: [],
(property) ToSSGResult.success: boolean
error:
(property) ToSSGResult.files: string[]
errorObj }
(property) ToSSGResult.error?: Error | undefined
} if (options?
const errorObj: Error
.afterGenerateHook) {
(parameter) options: ToSSGOptions | undefined
const conbinedAfterGenerateHooks =
(property) ToSSGOptions.afterGenerateHook?: AfterGenerateHook | AfterGenerateHook[] | undefined
combineAfterGenerateHooks
const conbinedAfterGenerateHooks: AfterGenerateHook
(options?
const combineAfterGenerateHooks: (hooks: AfterGenerateHook | AfterGenerateHook[]) => AfterGenerateHook
.afterGenerateHook)
(parameter) options: ToSSGOptions
await conbinedAfterGenerateHooks
(property) ToSSGOptions.afterGenerateHook?: AfterGenerateHook | AfterGenerateHook[]
(result)
const conbinedAfterGenerateHooks: (result: ToSSGResult) => void | Promise<void>
} return result
let result: ToSSGResult
}
let result: ToSSGResult
import { describe, expect, it } from 'vitest' import { dirname, joinPaths } from './utils' describe('joinPath', () => { it('Should joined path is valid.', () => { expect(joinPaths('test')).toBe('test') //singleexpect(joinPaths('.test')).toBe('.test') //single with dot
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('/.test')).toBe('/.test') //single with dot with root
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('test', 'test2')).toBe('test/test2') // single and single
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('test', 'test2', '../test3')).toBe('test/test3') // single and single and single with parent
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('.', '../')).toBe('..') // dot and parent
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('test/', 'test2/')).toBe('test/test2') // trailing slashes
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('./test', './test2')).toBe('test/test2') // dot and slash
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('', 'test')).toBe('test') // empty path
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('/test', '/test2')).toBe('/test/test2') // root path
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('../', 'test')).toBe('../test') // parent and single
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('test', '..', 'test2')).toBe('test2') // single triple dot and single
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('test', '...', 'test2')).toBe('test/.../test2') // single triple dot and single
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('test', './test2', '.test3.')).toBe('test/test2/.test3.') // single and single with slash and single with dot
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('test', '../', '.test2')).toBe('.test2') // single and parent and single with dot
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('..', '..', 'test')).toBe('../../test') // parent and parent and single
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('..', '..')).toBe('../..') // parent and parent
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('.test../test2/../')).toBe('.test..') //shuffle
(alias) joinPaths(...paths: string[]): string import joinPaths
expect(joinPaths('.test./.test2/../')).toBe('.test.') //shuffle2
(alias) joinPaths(...paths: string[]): string import joinPaths
}) it('Should windows path is valid.', () => { expect(joinPaths('a\\b\\c', 'd\\e')).toBe('a/b/c/d/e')
(alias) joinPaths(...paths: string[]): string import joinPaths
}) }) describe('dirname', () => { it('Should dirname is valid.', () => { expect(dirname('parent/child')).toBe('parent')
(alias) joinPaths(...paths: string[]): string import joinPaths
(alias) dirname(path: string): string import dirname
Get dirname@param
path
— File Path@returns — Parent dir path
expect(dirname('windows\\test.txt')).toBe('windows')
(alias) dirname(path: string): string import dirname
Get dirname@param
path
— File Path@returns — Parent dir path
}) })
import type { Hono } from '../../hono' import { METHOD_NAME_ALL } from '../../router' import type { Env, RouterRoute } from '../../types' import { findTargetHandler, isMiddleware } from '../../utils/handler' /** * Get dirname * @param path File Path * @returns Parent dir path */ export const dirname =
const dirname: (path: string) => string
Get dirname@param
path
— File Path@returns — Parent dir path
(path: string): string => {
(parameter) path: string
File Path@param
const splittedPath =path
— File Pathpath
const splittedPath: string[]
(parameter) path: string
File Path@param
.split(/[\/\\]/)path
— File Path
(method) String.split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
splitter
— An object that can split a string.@param
return splittedPathlimit
— A value used to limit the number of elements returned in the array..slice(0, -1)
const splittedPath: string[]
(method) Array<string>.slice(start?: number, end?: number): string[]
Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.@param
start
The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.@param
.join('/') // Windows supports slash pathend
The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array.
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} const normalizePath =separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.(path: string): string => {
const normalizePath: (path: string) => string
return path
(parameter) path: string
.replace(/(\\)/g, '/')
(parameter) path: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
.replace(/\/$/g, '')replaceValue
— The replacement text.
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
} const handleParent =replaceValue
— The replacement text.(resultPaths: string[],
const handleParent: (resultPaths: string[], beforeParentFlag: boolean) => void
beforeParentFlag: boolean): void => {
(parameter) resultPaths: string[]
if (resultPaths
(parameter) beforeParentFlag: boolean
.length === 0 ||
(parameter) resultPaths: string[]
beforeParentFlag) {
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.resultPaths
(parameter) beforeParentFlag: boolean
.push('..')
(parameter) resultPaths: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
} else { resultPathsitems
— New elements to add to the array..pop()
(parameter) resultPaths: string[]
} } const handleNonDot =
(method) Array<string>.pop(): string | undefined
Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.(path: string,
const handleNonDot: (path: string, resultPaths: string[]) => void
resultPaths: string[]): void => {
(parameter) path: string
path =
(parameter) resultPaths: string[]
path
(parameter) path: string
.replace(/^\.(?!.)/, '')
(parameter) path: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
if (path !== '') {replaceValue
— The replacement text.resultPaths
(parameter) path: string
.push
(parameter) resultPaths: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(path)items
— New elements to add to the array.} } const handleSegments =
(parameter) path: string
(paths: string[],
const handleSegments: (paths: string[], resultPaths: string[]) => void
resultPaths: string[]): void => {
(parameter) paths: string[]
let beforeParentFlag = false
(parameter) resultPaths: string[]
for (const path of
let beforeParentFlag: boolean
paths) {
const path: string
// Handle `..` if (path === '..') {
(parameter) paths: string[]
handleParent
const path: string
(resultPaths,
const handleParent: (resultPaths: string[], beforeParentFlag: boolean) => void
beforeParentFlag)
(parameter) resultPaths: string[]
beforeParentFlag = true
let beforeParentFlag: boolean
} else { // Handle `.` or `abc` handleNonDot
let beforeParentFlag: boolean
(path,
const handleNonDot: (path: string, resultPaths: string[]) => void
resultPaths)
const path: string
beforeParentFlag = false
(parameter) resultPaths: string[]
} } } export const joinPaths = (..
let beforeParentFlag: boolean
.paths: string[]): string => {
const joinPaths: (...paths: string[]) => string
paths =
(parameter) paths: string[]
paths
(parameter) paths: string[]
.map
(parameter) paths: string[]
(method) Array<string>.map<string>(callbackfn: (value: string, index: number, array: string[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(normalizePath)thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.const resultPaths: string[] = []
const normalizePath: (path: string) => string
handleSegments
const resultPaths: string[]
(paths
const handleSegments: (paths: string[], resultPaths: string[]) => void
.join('/')
(parameter) paths: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
.split('/'),separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.
(method) String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
separator
— A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.@param
resultPaths)limit
— A value used to limit the number of elements returned in the array.return (paths[0][0] === '/' ? '/' : '') +
const resultPaths: string[]
resultPaths
(parameter) paths: string[]
.join('/')
const resultPaths: string[]
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} interface FilterStaticGenerateRouteData {separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.path: string
interface FilterStaticGenerateRouteData
} export const filterStaticGenerateRoutes =
(property) FilterStaticGenerateRouteData.path: string
<E extends
const filterStaticGenerateRoutes: <E extends Env>(hono: Hono<E>) => FilterStaticGenerateRouteData[]
Env>(
(type parameter) E in <E extends Env>(hono: Hono<E>): FilterStaticGenerateRouteData[]
hono:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Hono
(parameter) hono: Hono<E, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
<E>BasePath
— The base path type.): FilterStaticGenerateRouteData[] => {
(type parameter) E in <E extends Env>(hono: Hono<E>): FilterStaticGenerateRouteData[]
return hono
interface FilterStaticGenerateRouteData
.routes
(parameter) hono: Hono<E, BlankSchema, "/">
.reduce(
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.routes: RouterRoute[]
(method) Array<RouterRoute>.reduce<FilterStaticGenerateRouteData[]>(callbackfn: (previousValue: FilterStaticGenerateRouteData[], currentValue: RouterRoute, currentIndex: number, array: RouterRoute[]) => FilterStaticGenerateRouteData[], initialValue: FilterStaticGenerateRouteData[]): FilterStaticGenerateRouteData[] (+2 overloads)
Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.@param
callbackfn
— A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.@param
(acc, {initialValue
— If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.method,
(parameter) acc: FilterStaticGenerateRouteData[]
handler,
(parameter) method: string
path }:
(parameter) handler: H<any, any, BlankInput, any>
RouterRoute) => {
(parameter) path: string
const targetHandler =
(alias) interface RouterRoute import RouterRoute
findTargetHandler
const targetHandler: Function
(handler)
(alias) findTargetHandler(handler: Function): Function import findTargetHandler
if (['GET', METHOD_NAME_ALL]
(parameter) handler: H<any, any, BlankInput, any>
.includes
(alias) const METHOD_NAME_ALL: "ALL" import METHOD_NAME_ALL
Constant representing all HTTP methods in uppercase.
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
(method) &&fromIndex
— The position in this array at which to begin searching for searchElement.!isMiddleware
(parameter) method: string
(targetHandler)) {
(alias) isMiddleware(handler: Function): boolean import isMiddleware
acc
const targetHandler: Function
.push({
(parameter) acc: FilterStaticGenerateRouteData[]
(method) Array<FilterStaticGenerateRouteData>.push(...items: FilterStaticGenerateRouteData[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
path })items
— New elements to add to the array.} return acc
(property) FilterStaticGenerateRouteData.path: string
}, [] as FilterStaticGenerateRouteData[])
(parameter) acc: FilterStaticGenerateRouteData[]
}
interface FilterStaticGenerateRouteData
/** * @module * Streaming Helper for Hono. */ export { stream } from './stream'export type { SSEMessage } from './sse'
(alias) const stream: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response export stream
export { streamSSE,
(alias) interface SSEMessage export SSEMessage
SSEStreamingApi } from './sse'
(alias) const streamSSE: (c: Context, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>) => Response export streamSSE
export { streamText } from './text'
(alias) class SSEStreamingApi export SSEStreamingApi
(alias) const streamText: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response export streamText
import type { Context } from '../../context' import { HtmlEscapedCallbackPhase, resolveCallback } from '../../utils/html' import { StreamingApi } from '../../utils/stream' export interface SSEMessage {data: string |
interface SSEMessage
Promise
(property) SSEMessage.data: string | Promise<string>
event?: string
interface Promise<T>
Represents the completion of an asynchronous operationid?: string
(property) SSEMessage.event?: string | undefined
retry?: number
(property) SSEMessage.id?: string | undefined
} export class SSEStreamingApi extends
(property) SSEMessage.retry?: number | undefined
StreamingApi {
class SSEStreamingApi
(alias) class StreamingApi import StreamingApi
@module — Stream utility.
constructor(writable:WritableStream,
(parameter) writable: WritableStream<any>
readable:
interface WritableStream<W = any>
This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.ReadableStream) {
(parameter) readable: ReadableStream<any>
super(writable,
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.readable)
(parameter) writable: WritableStream<any>
} async writeSSE
(parameter) readable: ReadableStream<any>
(message:
(method) SSEStreamingApi.writeSSE(message: SSEMessage): Promise<void>
SSEMessage) {
(parameter) message: SSEMessage
const data = await
interface SSEMessage
resolveCallback
const data: string
(message
(alias) resolveCallback(str: string | HtmlEscapedString | Promise<string>, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [string]): Promise<string> import resolveCallback
.data,
(parameter) message: SSEMessage
HtmlEscapedCallbackPhase
(property) SSEMessage.data: string | Promise<string>
(alias) const HtmlEscapedCallbackPhase: { readonly Stringify: 1; readonly BeforeStream: 2; readonly Stream: 3; } import HtmlEscapedCallbackPhase
@module — HTML utility.
.Stringify, false, {})const dataLines =
(property) Stringify: 1
(data as string)
const dataLines: string
.split('\n')
const data: string
(method) String.split(separator: string | RegExp, limit?: number): string[] (+1 overload)
Split a string into substrings using the specified separator and return them as an array.@param
separator
— A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.@param
.map(limit
— A value used to limit the number of elements returned in the array.
(method) Array<string>.map<string>(callbackfn: (value: string, index: number, array: string[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(line) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.return `data: ${line}`
(parameter) line: string
}) .join('\n')
(parameter) line: string
(method) Array<string>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
const sseData =separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.[ message
const sseData: string
.event && `event: $
(parameter) message: SSEMessage
{message
(property) SSEMessage.event?: string | undefined
.event}`,
(parameter) message: SSEMessage
dataLines,
(property) SSEMessage.event?: string
message
const dataLines: string
.id && `id: $
(parameter) message: SSEMessage
{message
(property) SSEMessage.id?: string | undefined
.id}`,
(parameter) message: SSEMessage
message
(property) SSEMessage.id?: string
.retry && `retry: $
(parameter) message: SSEMessage
{message
(property) SSEMessage.retry?: number | undefined
.retry}`,
(parameter) message: SSEMessage
] .filter
(property) SSEMessage.retry?: number
(method) Array<string | 0 | undefined>.filter(predicate: (value: string | 0 | undefined, index: number, array: (string | 0 | undefined)[]) => unknown, thisArg?: any): (string | 0 | undefined)[] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.@param
predicate
— A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.@param
(Boolean)thisArg
— An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value..join('\n') + '\n\n'
var Boolean: BooleanConstructor
(method) Array<string | 0 | undefined>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
await this.writeseparator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.(sseData)
(method) StreamingApi.write(input: Uint8Array | string): Promise<StreamingApi>
} } const run = async (
const sseData: string
stream:
const run: (stream: SSEStreamingApi, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>) => Promise<void>
SSEStreamingApi,
(parameter) stream: SSEStreamingApi
cb:
class SSEStreamingApi
(stream:
(parameter) cb: (stream: SSEStreamingApi) => Promise<void>
SSEStreamingApi) =>
(parameter) stream: SSEStreamingApi
Promise
class SSEStreamingApi
, onError?:
interface Promise<T>
Represents the completion of an asynchronous operation(e:
(parameter) onError: ((e: Error, stream: SSEStreamingApi) => Promise<void>) | undefined
Error,
(parameter) e: Error
stream:
interface Error
SSEStreamingApi) =>
(parameter) stream: SSEStreamingApi
Promise
class SSEStreamingApi
): Promise
interface Promise<T>
Represents the completion of an asynchronous operation=> { try { await cb
interface Promise<T>
Represents the completion of an asynchronous operation(stream)
(parameter) cb: (stream: SSEStreamingApi) => Promise<void>
} catch (e) {
(parameter) stream: SSEStreamingApi
if (e instanceof
(local var) e: unknown
Error &&
(local var) e: unknown
onError) {
var Error: ErrorConstructor
await onError
(parameter) onError: ((e: Error, stream: SSEStreamingApi) => Promise<void>) | undefined
(e,
(parameter) onError: (e: Error, stream: SSEStreamingApi) => Promise<void>
stream)
(local var) e: Error
await stream
(parameter) stream: SSEStreamingApi
.writeSSE({
(parameter) stream: SSEStreamingApi
event: 'error',
(method) SSEStreamingApi.writeSSE(message: SSEMessage): Promise<void>
data:
(property) SSEMessage.event?: string | undefined
e
(property) SSEMessage.data: string | Promise<string>
.message,
(local var) e: Error
}) } else { console
(property) Error.message: string
.error
var console: Console
(e)
(method) Console.error(...data: any[]): void
MDN Reference} } finally { stream
(local var) e: unknown
.close()
(parameter) stream: SSEStreamingApi
} } const contextStash:
(method) StreamingApi.close(): Promise<void>
WeakMap
const contextStash: WeakMap<ReadableStream<any>, Context<any, any, {}>>
<ReadableStream,
interface WeakMap<K extends WeakKey, V>
Context> = new
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.WeakMap
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
<ReadableStream,
var WeakMap: WeakMapConstructor new <ReadableStream<any>, Context<any, any, {}>>(entries?: readonly (readonly [ReadableStream<any>, Context<any, any, {}>])[] | null | undefined) => WeakMap<...> (+1 overload)
Context>()
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.export const streamSSE = (
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
c:
const streamSSE: (c: Context, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>) => Response
Context,
(parameter) c: Context<any, any, {}>
cb:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(stream:
(parameter) cb: (stream: SSEStreamingApi) => Promise<void>
SSEStreamingApi) =>
(parameter) stream: SSEStreamingApi
Promise
class SSEStreamingApi
, onError?:
interface Promise<T>
Represents the completion of an asynchronous operation(e:
(parameter) onError: ((e: Error, stream: SSEStreamingApi) => Promise<void>) | undefined
Error,
(parameter) e: Error
stream:
interface Error
SSEStreamingApi) =>
(parameter) stream: SSEStreamingApi
Promise
class SSEStreamingApi
): Response => {
interface Promise<T>
Represents the completion of an asynchronous operationconst { readable,
interface Response
This Fetch API interface represents the response to a request.writable } = new
const readable: ReadableStream<any>
MDN ReferenceTransformStream()
const writable: WritableStream<any>
MDN Referenceconst stream = new
var TransformStream: new <any, any>(transformer?: Transformer<any, any> | undefined, writableStrategy?: QueuingStrategy<any> | undefined, readableStrategy?: QueuingStrategy<any> | undefined) => TransformStream<...>
MDN ReferenceSSEStreamingApi
const stream: SSEStreamingApi
(writable,
constructor SSEStreamingApi(writable: WritableStream, readable: ReadableStream): SSEStreamingApi
readable)
const writable: WritableStream<any>
MDN Reference// bun does not cancel response stream when request is canceled, so detect abort by signal c
const readable: ReadableStream<any>
MDN Reference.req
(parameter) c: Context<any, any, {}>
.raw
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.signal
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.addEventListener('abort', () => {
(property) Request.signal: AbortSignal
Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
(method) AbortSignal.addEventListener<"abort">(type: "abort", listener: (this: AbortSignal, ev: Event) => any, options?: boolean | AddEventListenerOptions): void (+1 overload)
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
if (!stream.closed) {
const stream: SSEStreamingApi
stream
(property) StreamingApi.closed: boolean
Whether the stream has been closed normally..abort()
const stream: SSEStreamingApi
} }) // in bun, `c` is destroyed when the request is returned, so hold it until the end of streaming contextStash
(method) StreamingApi.abort(): void
Abort the stream. You can call this method when stream is aborted by external event..set
const contextStash: WeakMap<ReadableStream<any>, Context<any, any, {}>>
(method) WeakMap<ReadableStream<any>, Context<any, any, {}>>.set(key: ReadableStream<any>, value: Context<any, any, {}>): WeakMap<ReadableStream<any>, Context<any, any, {}>>
Adds a new element with a specified key and value.@param
(streamkey
— Must be an object or symbol..responseReadable,
const stream: SSEStreamingApi
c)
(property) StreamingApi.responseReadable: ReadableStream<any>
c
(parameter) c: Context<any, any, {}>
.header('Transfer-Encoding', 'chunked')
(parameter) c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('Content-Type', 'text/event-stream')
(parameter) c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('Cache-Control', 'no-cache')
(parameter) c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('Connection', 'keep-alive')
(parameter) c: Context<any, any, {}>
run
(property) Context<any, any, {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
(stream,
const run: (stream: SSEStreamingApi, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>) => Promise<void>
cb,
const stream: SSEStreamingApi
onError)
(parameter) cb: (stream: SSEStreamingApi) => Promise<void>
return c
(parameter) onError: ((e: Error, stream: SSEStreamingApi) => Promise<void>) | undefined
.newResponse
(parameter) c: Context<any, any, {}>
(stream
(property) Context<any, any, {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.responseReadable)
const stream: SSEStreamingApi
}
(property) StreamingApi.responseReadable: ReadableStream<any>
import { Context } from '../../context' import { stream } from '.' describe('Basic Streaming Helper', () => { const req = newRequest('http://localhost/')
const req: Request
let c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context
let c: Context<any, any, {}>
beforeEach(() => { c = new
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Context
let c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.}) it('Check stream Response', async () => { const res =
const req: Request
stream
const res: Response
(c, async
(alias) stream(c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>): Response import stream
(stream) => {
let c: Context<any, any, {}>
for (let i = 0;
(parameter) stream: StreamingApi
i < 3;
let i: number
i++) {
let i: number
await stream
let i: number
.write(new
(parameter) stream: StreamingApi
Uint8Array(
(method) StreamingApi.write(input: Uint8Array | string): Promise<StreamingApi>
[i]))
var Uint8Array: Uint8ArrayConstructor new (elements: Iterable<number>) => Uint8Array (+4 overloads)
await stream
let i: number
.sleep(1)
(parameter) stream: StreamingApi
} }) if (!res
(method) StreamingApi.sleep(ms: number): Promise<unknown>
.body) {
const res: Response
throw new Error('Body is null')
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference} const reader =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
res
const reader: ReadableStreamDefaultReader<Uint8Array>
.body
const res: Response
.getReader()
(property) Body.body: ReadableStream<Uint8Array>
MDN Referencefor (let i = 0;
(method) ReadableStream<Uint8Array>.getReader(): ReadableStreamDefaultReader<Uint8Array> (+2 overloads)
MDN Referencei < 3;
let i: number
i++) {
let i: number
const { value } = await
let i: number
reader
const value: Uint8Array | undefined
.read()
const reader: ReadableStreamDefaultReader<Uint8Array>
expect(value).toEqual(new
(method) ReadableStreamDefaultReader<Uint8Array>.read(): Promise<ReadableStreamReadResult<Uint8Array>>
MDN ReferenceUint8Array(
const value: Uint8Array | undefined
[i]))
var Uint8Array: Uint8ArrayConstructor new (elements: Iterable<number>) => Uint8Array (+4 overloads)
} }) it('Check stream Response if aborted by client', async () => { let aborted = false
let i: number
const res =
let aborted: boolean
stream
const res: Response
(c, async
(alias) stream(c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>): Response import stream
(stream) => {
let c: Context<any, any, {}>
stream
(parameter) stream: StreamingApi
.onAbort(() => {
(parameter) stream: StreamingApi
aborted = true
(method) StreamingApi.onAbort(listener: () => void | Promise<void>): void
}) for (let i = 0;
let aborted: boolean
i < 3;
let i: number
i++) {
let i: number
await stream
let i: number
.write(new
(parameter) stream: StreamingApi
Uint8Array(
(method) StreamingApi.write(input: Uint8Array | string): Promise<StreamingApi>
[i]))
var Uint8Array: Uint8ArrayConstructor new (elements: Iterable<number>) => Uint8Array (+4 overloads)
await stream
let i: number
.sleep(1)
(parameter) stream: StreamingApi
} }) if (!res
(method) StreamingApi.sleep(ms: number): Promise<unknown>
.body) {
const res: Response
throw new Error('Body is null')
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference} const reader =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
res
const reader: ReadableStreamDefaultReader<Uint8Array>
.body
const res: Response
.getReader()
(property) Body.body: ReadableStream<Uint8Array>
MDN Referenceconst { value } = await
(method) ReadableStream<Uint8Array>.getReader(): ReadableStreamDefaultReader<Uint8Array> (+2 overloads)
MDN Referencereader
const value: Uint8Array | undefined
.read()
const reader: ReadableStreamDefaultReader<Uint8Array>
expect(value).toEqual(new
(method) ReadableStreamDefaultReader<Uint8Array>.read(): Promise<ReadableStreamReadResult<Uint8Array>>
MDN ReferenceUint8Array([0]))
const value: Uint8Array | undefined
reader
var Uint8Array: Uint8ArrayConstructor new (elements: Iterable<number>) => Uint8Array (+4 overloads)
.cancel()
const reader: ReadableStreamDefaultReader<Uint8Array>
expect(aborted).toBeTruthy()
(method) ReadableStreamGenericReader.cancel(reason?: any): Promise<void>
MDN Reference}) it('Check stream Response if aborted by abort signal', async () => { const ac = new
let aborted: false
AbortController()
const ac: AbortController
const req = new
var AbortController: new () => AbortController
A controller object that allows you to abort one or more DOM requests as and when desired.Request('http://localhost/', {
const req: Request
signal:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.ac
(property) RequestInit.signal?: AbortSignal | null | undefined
An AbortSignal to set request's signal..signal })
const ac: AbortController
const c = new
(property) AbortController.signal: AbortSignal
Returns the AbortSignal object associated with this object.Context
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.let aborted = false
const req: Request
const res =
let aborted: boolean
stream
const res: Response
(c, async
(alias) stream(c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>): Response import stream
(stream) => {
const c: Context<any, any, {}>
stream
(parameter) stream: StreamingApi
.onAbort(() => {
(parameter) stream: StreamingApi
aborted = true
(method) StreamingApi.onAbort(listener: () => void | Promise<void>): void
}) for (let i = 0;
let aborted: boolean
i < 3;
let i: number
i++) {
let i: number
await stream
let i: number
.write(new
(parameter) stream: StreamingApi
Uint8Array(
(method) StreamingApi.write(input: Uint8Array | string): Promise<StreamingApi>
[i]))
var Uint8Array: Uint8ArrayConstructor new (elements: Iterable<number>) => Uint8Array (+4 overloads)
await stream
let i: number
.sleep(1)
(parameter) stream: StreamingApi
} }) if (!res
(method) StreamingApi.sleep(ms: number): Promise<unknown>
.body) {
const res: Response
throw new Error('Body is null')
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference} const reader =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
res
const reader: ReadableStreamDefaultReader<Uint8Array>
.body
const res: Response
.getReader()
(property) Body.body: ReadableStream<Uint8Array>
MDN Referenceconst { value } = await
(method) ReadableStream<Uint8Array>.getReader(): ReadableStreamDefaultReader<Uint8Array> (+2 overloads)
MDN Referencereader
const value: Uint8Array | undefined
.read()
const reader: ReadableStreamDefaultReader<Uint8Array>
expect(value).toEqual(new
(method) ReadableStreamDefaultReader<Uint8Array>.read(): Promise<ReadableStreamReadResult<Uint8Array>>
MDN ReferenceUint8Array([0]))
const value: Uint8Array | undefined
ac
var Uint8Array: Uint8ArrayConstructor new (elements: Iterable<number>) => Uint8Array (+4 overloads)
.abort()
const ac: AbortController
expect(aborted).toBeTruthy()
(method) AbortController.abort(reason?: any): void
Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.}) it('Check stream Response if error occurred', async () => { const onError = vi.fn()
let aborted: false
const res =
const onError: any
stream(
const res: Response
c,
(alias) stream(c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>): Response import stream
async () => { throw new Error('error')
let c: Context<any, any, {}>
}, onError
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
) if (!res
const onError: any
.body) {
const res: Response
throw new Error('Body is null')
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference} const reader =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
res
const reader: ReadableStreamDefaultReader<Uint8Array>
.body
const res: Response
.getReader()
(property) Body.body: ReadableStream<Uint8Array>
MDN Referenceconst { value } = await
(method) ReadableStream<Uint8Array>.getReader(): ReadableStreamDefaultReader<Uint8Array> (+2 overloads)
MDN Referencereader
const value: Uint8Array | undefined
.read()
const reader: ReadableStreamDefaultReader<Uint8Array>
expect(value).toBeUndefined()
(method) ReadableStreamDefaultReader<Uint8Array>.read(): Promise<ReadableStreamReadResult<Uint8Array>>
MDN Referenceexpect(onError).toBeCalledTimes(1)
const value: Uint8Array | undefined
expect(onError).toBeCalledWith(new
const onError: any
Error('error'), expect.anything()) // 2nd argument is StreamingApi instance
const onError: any
}) })
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
import type { Context } from '../../context' import { StreamingApi } from '../../utils/stream' const contextStash:WeakMap
const contextStash: WeakMap<ReadableStream<any>, Context<any, any, {}>>
<ReadableStream,
interface WeakMap<K extends WeakKey, V>
Context> = new
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.WeakMap
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
<ReadableStream,
var WeakMap: WeakMapConstructor new <ReadableStream<any>, Context<any, any, {}>>(entries?: readonly (readonly [ReadableStream<any>, Context<any, any, {}>])[] | null | undefined) => WeakMap<...> (+1 overload)
Context>()
interface ReadableStream<R = any>
This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.export const stream = (
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
c:
const stream: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response
Context,
(parameter) c: Context<any, any, {}>
cb:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(stream:
(parameter) cb: (stream: StreamingApi) => Promise<void>
StreamingApi) =>
(parameter) stream: StreamingApi
(alias) class StreamingApi import StreamingApi
@module — Stream utility.
Promise, onError?:
interface Promise<T>
Represents the completion of an asynchronous operation(e:
(parameter) onError: ((e: Error, stream: StreamingApi) => Promise<void>) | undefined
Error,
(parameter) e: Error
stream:
interface Error
StreamingApi) =>
(parameter) stream: StreamingApi
(alias) class StreamingApi import StreamingApi
@module — Stream utility.
Promise): Response => {
interface Promise<T>
Represents the completion of an asynchronous operationconst { readable,
interface Response
This Fetch API interface represents the response to a request.writable } = new
const readable: ReadableStream<any>
MDN ReferenceTransformStream()
const writable: WritableStream<any>
MDN Referenceconst stream = new
var TransformStream: new <any, any>(transformer?: Transformer<any, any> | undefined, writableStrategy?: QueuingStrategy<any> | undefined, readableStrategy?: QueuingStrategy<any> | undefined) => TransformStream<...>
MDN ReferenceStreamingApi
const stream: StreamingApi
(alias) new StreamingApi(writable: WritableStream, _readable: ReadableStream): StreamingApi import StreamingApi
@module — Stream utility.
(writable,readable)
const writable: WritableStream<any>
MDN Reference// bun does not cancel response stream when request is canceled, so detect abort by signal c
const readable: ReadableStream<any>
MDN Reference.req
(parameter) c: Context<any, any, {}>
.raw
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.signal
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.addEventListener('abort', () => {
(property) Request.signal: AbortSignal
Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
(method) AbortSignal.addEventListener<"abort">(type: "abort", listener: (this: AbortSignal, ev: Event) => any, options?: boolean | AddEventListenerOptions): void (+1 overload)
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
if (!stream.closed) {
const stream: StreamingApi
stream
(property) StreamingApi.closed: boolean
Whether the stream has been closed normally..abort()
const stream: StreamingApi
} }) // in bun, `c` is destroyed when the request is returned, so hold it until the end of streaming contextStash
(method) StreamingApi.abort(): void
Abort the stream. You can call this method when stream is aborted by external event..set
const contextStash: WeakMap<ReadableStream<any>, Context<any, any, {}>>
(method) WeakMap<ReadableStream<any>, Context<any, any, {}>>.set(key: ReadableStream<any>, value: Context<any, any, {}>): WeakMap<ReadableStream<any>, Context<any, any, {}>>
Adds a new element with a specified key and value.@param
(streamkey
— Must be an object or symbol..responseReadable,
const stream: StreamingApi
c)
(property) StreamingApi.responseReadable: ReadableStream<any>
;(async () => { try { await cb
(parameter) c: Context<any, any, {}>
(stream)
(parameter) cb: (stream: StreamingApi) => Promise<void>
} catch (e) {
const stream: StreamingApi
if (e instanceof
(local var) e: unknown
Error &&
(local var) e: unknown
onError) {
var Error: ErrorConstructor
await onError
(parameter) onError: ((e: Error, stream: StreamingApi) => Promise<void>) | undefined
(e,
(parameter) onError: (e: Error, stream: StreamingApi) => Promise<void>
stream)
(local var) e: Error
} else { console
const stream: StreamingApi
.error
var console: Console
(e)
(method) Console.error(...data: any[]): void
MDN Reference} } finally { stream
(local var) e: unknown
.close()
const stream: StreamingApi
} })() return c
(method) StreamingApi.close(): Promise<void>
.newResponse
(parameter) c: Context<any, any, {}>
(stream
(property) Context<any, any, {}>.newResponse: NewResponse (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.responseReadable)
const stream: StreamingApi
}
(property) StreamingApi.responseReadable: ReadableStream<any>
import { Context } from '../../context' import { streamText } from '.' describe('Text Streaming Helper', () => { const req = newRequest('http://localhost/')
const req: Request
let c:
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Context
let c: Context<any, any, {}>
beforeEach(() => { c = new
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Context
let c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(req)options
— Optional configuration options for the context.}) it('Check streamText Response', async () => { const res =
const req: Request
streamText
const res: Response
(c, async
(alias) streamText(c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>): Response import streamText
(stream) => {
let c: Context<any, any, {}>
for (let i = 0;
(parameter) stream: StreamingApi
i < 3;
let i: number
i++) {
let i: number
await stream
let i: number
.write(`$
(parameter) stream: StreamingApi
{i}`)
(method) StreamingApi.write(input: Uint8Array | string): Promise<StreamingApi>
await stream
let i: number
.sleep(1)
(parameter) stream: StreamingApi
} }) expect(res
(method) StreamingApi.sleep(ms: number): Promise<unknown>
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('content-type')).toMatch(/^text\/plain/)
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-content-type-options')).toBe('nosniff')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('transfer-encoding')).toBe('chunked')
(property) Response.headers: Headers
MDN Referenceif (!res
(method) Headers.get(name: string): string | null
MDN Reference.body) {
const res: Response
throw new Error('Body is null')
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference} const reader =
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
res
const reader: ReadableStreamDefaultReader<Uint8Array>
.body
const res: Response
.getReader()
(property) Body.body: ReadableStream<Uint8Array>
MDN Referenceconst decoder = new
(method) ReadableStream<Uint8Array>.getReader(): ReadableStreamDefaultReader<Uint8Array> (+2 overloads)
MDN ReferenceTextDecoder()
const decoder: TextDecoder
for (let i = 0;
var TextDecoder: new (label?: string, options?: TextDecoderOptions) => TextDecoder
A decoder for a specific method, that is a specific character encoding, like utf-8, iso-8859-2, koi8, cp1261, gbk, etc. A decoder takes a stream of bytes as input and emits a stream of code points. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays.i < 3;
let i: number
i++) {
let i: number
const { value } = await
let i: number
reader
const value: Uint8Array | undefined
.read()
const reader: ReadableStreamDefaultReader<Uint8Array>
expect(decoder
(method) ReadableStreamDefaultReader<Uint8Array>.read(): Promise<ReadableStreamReadResult<Uint8Array>>
MDN Reference.decode
const decoder: TextDecoder
(method) TextDecoder.decode(input?: AllowSharedBufferSource, options?: TextDecodeOptions): string
Returns the result of running encoding's decoder. The method can be invoked zero or more times with options's stream set to true, and then once without options's stream (or set to false), to process a fragmented input. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments.
var string = "", decoder = new TextDecoder(encoding), buffer; while(buffer = next_chunk()) { string += decoder.decode(buffer, {stream:true}); } string += decoder.decode(); // end-of-queue
If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError.
(value)).toEqual(`${i}`)
const value: Uint8Array | undefined
} }) })
let i: number
import type { Context } from '../../context' import { TEXT_PLAIN } from '../../context' import type { StreamingApi } from '../../utils/stream' import { stream } from './' export const streamText = (c:
const streamText: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response
Context,
(parameter) c: Context<any, any, {}>
cb:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(stream:
(parameter) cb: (stream: StreamingApi) => Promise<void>
StreamingApi) =>
(parameter) stream: StreamingApi
(alias) class StreamingApi import StreamingApi
@module — Stream utility.
Promise, onError?:
interface Promise<T>
Represents the completion of an asynchronous operation(e:
(parameter) onError: ((e: Error, stream: StreamingApi) => Promise<void>) | undefined
Error,
(parameter) e: Error
stream:
interface Error
StreamingApi) =>
(parameter) stream: StreamingApi
(alias) class StreamingApi import StreamingApi
@module — Stream utility.
Promise): Response => {
interface Promise<T>
Represents the completion of an asynchronous operationc
interface Response
This Fetch API interface represents the response to a request..header('Content-Type',
(parameter) c: Context<any, any, {}>
TEXT_PLAIN)
(property) Context<any, any, {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
(alias) const TEXT_PLAIN: "text/plain; charset=UTF-8" import TEXT_PLAIN
.header('X-Content-Type-Options', 'nosniff')
(parameter) c: Context<any, any, {}>
c
(property) Context<any, any, {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('Transfer-Encoding', 'chunked')
(parameter) c: Context<any, any, {}>
return stream
(property) Context<any, any, {}>.header: SetHeaders (name: ResponseHeader, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
(c,
(alias) stream(c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>): Response import stream
cb,
(parameter) c: Context<any, any, {}>
onError)
(parameter) cb: (stream: StreamingApi) => Promise<void>
}
(parameter) onError: ((e: Error, stream: StreamingApi) => Promise<void>) | undefined
import { Hono } from '../../hono' import { testClient } from '.' describe('hono testClient', () => { it('Should return the correct search result', async () => { const app = newHono()
const app: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { hello: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/search',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", JSONRespondReturn<{ hello: string; }, StatusCode>, BlankInput, BlankEnv>(path: "/search", handler: H<BlankEnv, "/search", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/search", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/search", BlankInput>
hello: 'world' }))
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ hello: string; }, StatusCode>(object: { hello: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ hello: string; }, StatusCode> (+1 overload)
const res = await
(property) hello: string
testClient
const res: ClientResponse<{ hello: string; }, StatusCode, "json">
(app).search.$get()
(alias) testClient<Hono<BlankEnv, { "/search": { $get: { input: {}; output: { hello: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(app: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { hello: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">, Env?: unknown, executionCtx?: ExecutionContext): { ...; } import testClient
expect(await res
const app: Hono<BlankEnv, { "/search": { $get: { input: {}; output: { hello: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
.json()).toEqual({
const res: ClientResponse<{ hello: string; }, StatusCode, "json">
hello: 'world' })
(method) ClientResponse<{ hello: string; }, StatusCode, "json">.json(): Promise<{ hello: string; }>
MDN Reference}) it('Should return the correct environment variables value', async () => { type Bindings = {
(property) hello: string
hello: string }
type Bindings = { hello: string; }
const app = new
(property) hello: string
Hono<{
const app: Hono<{ Bindings: Bindings; }, { "/search": { $get: { input: {}; output: { hello: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<{ Bindings: Bindings; }, BlankSchema, "/">(options?: HonoOptions<{ Bindings: Bindings; }>): Hono<{ Bindings: Bindings; }, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
Bindings:options
— Optional configuration options for the Hono instance.Bindings }>()
(property) Bindings: Bindings
.get('/search',
type Bindings = { hello: string; }
(c) => {
(property) Hono<{ Bindings: Bindings; }, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", JSONRespondReturn<{ hello: string; }, StatusCode>, BlankInput, { Bindings: Bindings; }>(path: "/search", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<{ Bindings: Bindings; }, "/search", BlankInput>
.json({
(parameter) c: Context<{ Bindings: Bindings; }, "/search", BlankInput>
hello:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ hello: string; }, StatusCode>(object: { hello: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ hello: string; }, StatusCode> (+1 overload)
c
(property) hello: string
.env
(parameter) c: Context<{ Bindings: Bindings; }, "/search", BlankInput>
(property) Context<{ Bindings: Bindings; }, "/search", BlankInput>.env: Bindings
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
.hello })
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
}) const res = await
(property) hello: string
testClient
const res: ClientResponse<{ hello: string; }, StatusCode, "json">
(app, {
(alias) testClient<Hono<{ Bindings: Bindings; }, { "/search": { $get: { input: {}; output: { hello: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(app: Hono<{ Bindings: Bindings; }, { ...; }, "/">, Env?: {} | ... 1 more ... | undefined, executionCtx?: ExecutionContext): { ...; } import testClient
hello: 'world' }).search.$get()
const app: Hono<{ Bindings: Bindings; }, { "/search": { $get: { input: {}; output: { hello: string; }; outputFormat: "json"; status: StatusCode; }; }; }, "/">
expect(await res
(property) hello: string
.json()).toEqual({
const res: ClientResponse<{ hello: string; }, StatusCode, "json">
hello: 'world' })
(method) ClientResponse<{ hello: string; }, StatusCode, "json">.json(): Promise<{ hello: string; }>
MDN Reference}) it('Should return a correct URL with out throwing an error', async () => { const app = new
(property) hello: string
Hono()
const app: Hono<BlankEnv, { "/abc": { $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/abc',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/abc", "/abc", JSONRespondReturn<0, StatusCode>, BlankInput, BlankEnv>(path: "/abc", handler: H<BlankEnv, "/abc", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/abc", BlankInput>
.json(0))
(parameter) c: Context<BlankEnv, "/abc", BlankInput>
const url =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <0, StatusCode>(object: 0, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<0, StatusCode> (+1 overload)
testClient
const url: URL
(app).abc
(alias) testClient<Hono<BlankEnv, { "/abc": { $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(app: Hono<BlankEnv, { "/abc": { $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }; }, "/">, Env?: unknown, executionCtx?: ExecutionContext): { ...; } import testClient
.$url()
const app: Hono<BlankEnv, { "/abc": { $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }; }, "/">
expect(url
(property) $url: (arg?: {} | undefined) => URL
.pathname).toBe('/abc')
const url: URL
}) it('Should not throw an error with $ws()', async () => { vi.stubGlobal('WebSocket', class {}) const app = new
(property) URL.pathname: string
MDN ReferenceHono()
const app: Hono<BlankEnv, { "/ws": { $get: { input: {}; output: "Fake response of a WebSocket"; outputFormat: "text"; status: StatusCode; }; }; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.get('/ws',options
— Optional configuration options for the Hono instance.(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/ws", "/ws", Response & TypedResponse<"Fake response of a WebSocket", StatusCode, "text">, BlankInput, BlankEnv>(path: "/ws", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/ws", BlankInput>
.text('Fake response of a WebSocket'))
(parameter) c: Context<BlankEnv, "/ws", BlankInput>
// @ts-expect-error $ws is not typed correctly expect(() => testClient
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Fake response of a WebSocket", StatusCode>(text: "Fake response of a WebSocket", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
(app).ws.$ws()).not.toThrowError()
(alias) testClient<Hono<BlankEnv, { "/ws": { $get: { input: {}; output: "Fake response of a WebSocket"; outputFormat: "text"; status: StatusCode; }; }; }, "/">>(app: Hono<BlankEnv, { ...; }, "/">, Env?: unknown, executionCtx?: ExecutionContext): { ...; } import testClient
}) })
const app: Hono<BlankEnv, { "/ws": { $get: { input: {}; output: "Fake response of a WebSocket"; outputFormat: "text"; status: StatusCode; }; }; }, "/">
/** * @module * Testing Helper for Hono. */ import { hc } from '../../client' 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> =
type ExtractEnv<T> = T extends Hono<infer E extends Env, Schema, string> ? E : never
T extends
(type parameter) T in type ExtractEnv<T>
Hono
(type parameter) T in type ExtractEnv<T>
E,
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.Schema, string> ?
(type parameter) E
E : never
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
// eslint-disable-next-line @typescript-eslint/no-explicit-any export const testClient =
(type parameter) E
<T extends
const testClient: <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext) => UnionToIntersection<Client<T>>
Hono
(type parameter) T in <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext): UnionToIntersection<Client<T>>
Schema, string>>(
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.app:
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
T,
(parameter) app: T extends Hono<any, Schema, string>
Env?:
(type parameter) T in <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext): UnionToIntersection<Client<T>>
ExtractEnv
(parameter) Env: {} | ExtractEnv<T>["Bindings"] | undefined
<T>['Bindings'] | {},
type ExtractEnv<T> = T extends Hono<infer E extends Env, Schema, string> ? E : never
executionCtx?:
(type parameter) T in <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext): UnionToIntersection<Client<T>>
ExecutionContext
(parameter) executionCtx: ExecutionContext | undefined
): UnionToIntersection
(alias) interface ExecutionContext import ExecutionContext
Interface for the execution context in a web worker or similar environment.<Client
(alias) type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never import UnionToIntersection
<T>> => {
(alias) type Client<T> = T extends Hono<any, infer S extends Schema, any> ? S extends Record<infer K extends string | number | symbol, Schema> ? K extends string ? PathToChain<...> : never : never : never import Client
const customFetch =
(type parameter) T in <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext): UnionToIntersection<Client<T>>
(input:
const customFetch: (input: RequestInfo | URL, init?: RequestInit) => Response | Promise<Response>
RequestInfo |
(parameter) input: RequestInfo | URL
URL,
type RequestInfo = string | Request
init?:
interface URL
The URL interface represents an object providing static methods used for creating object URLs.RequestInit) => {
(parameter) init: RequestInit | undefined
return app
interface RequestInit
.request
(parameter) app: T extends Hono<any, Schema, string>
(property) Hono<any, Schema, string>.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, 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
(input,init,
(parameter) input: RequestInfo | URL
Env,
(parameter) init: RequestInit | undefined
executionCtx)
(parameter) Env: {} | ExtractEnv<T>["Bindings"] | undefined
} return hc
(parameter) executionCtx: ExecutionContext | undefined
app>('http://localhost', {
(alias) hc<T>(baseUrl: string, options?: ClientRequestOptions): UnionToIntersection<Client<T>> import hc
fetch:
(parameter) app: T extends Hono<any, Schema, string>
customFetch })
(property) fetch?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) | ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>) | undefined
}
const customFetch: (input: RequestInfo | URL, init?: RequestInit) => Response | Promise<Response>
import { createWSMessageEvent } from '.' describe('`createWSMessageEvent`', () => { it('Should `createWSMessageEvent` is working for string', () => { const randomString =Math
const randomString: string
.random()
var Math: Math
An intrinsic object that provides basic mathematics functionality and constants..toString()
(method) Math.random(): number
Returns a pseudorandom number between 0 and 1.
(method) Number.toString(radix?: number): string
Returns a string representation of an object.@param
const event =radix
— Specifies a radix for converting numeric values to strings. This value is only used for numbers.createWSMessageEvent
const event: MessageEvent<WSMessageReceive>
(randomString)
(alias) createWSMessageEvent(source: WSMessageReceive): MessageEvent<WSMessageReceive> import createWSMessageEvent
expect(event
const randomString: string
.data).toBe
const event: MessageEvent<WSMessageReceive>
(randomString)
(property) MessageEvent<WSMessageReceive>.data: WSMessageReceive
Returns the data of the message.}) it('Should `createWSMessageEvent` type is `message`', () => { const event =
const randomString: string
createWSMessageEvent('')
const event: MessageEvent<WSMessageReceive>
expect(event
(alias) createWSMessageEvent(source: WSMessageReceive): MessageEvent<WSMessageReceive> import createWSMessageEvent
.type).toBe('message')
const event: MessageEvent<WSMessageReceive>
}) })
(property) Event.type: string
Returns the type of event, e.g. "click", "hashchange", or "submit".
/** * @module * WebSocket Helper for Hono. */ /* eslint-disable @typescript-eslint/no-explicit-any */ import type { Context } from '../../context' import type { MiddlewareHandler } from '../../types' /** * WebSocket Event Listeners type */ export interface WSEvents<T = unknown> {
interface WSEvents<T = unknown>
WebSocket Event Listeners typeonOpen?:
(type parameter) T in WSEvents<T = unknown>
(evt:
(property) WSEvents<T = unknown>.onOpen?: ((evt: Event, ws: WSContext<T>) => void) | undefined
Event,
(parameter) evt: Event
ws:
interface Event
An event which takes place in the DOM.WSContext
(parameter) ws: WSContext<T>
<T>) => void
type WSContext<T = unknown> = { send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void; raw?: T; binaryType: BinaryType; readyState: WSReadyState; url: URL | null; protocol: string | null; close(code?: number, reason?: string): void; }
onMessage?:
(type parameter) T in WSEvents<T = unknown>
(evt:
(property) WSEvents<T = unknown>.onMessage?: ((evt: MessageEvent<WSMessageReceive>, ws: WSContext<T>) => void) | undefined
MessageEvent
(parameter) evt: MessageEvent<WSMessageReceive>
<WSMessageReceive>,
interface MessageEvent<T = any>
A message received by a target object.ws:
type WSMessageReceive = string | Blob | ArrayBufferLike
WSContext
(parameter) ws: WSContext<T>
<T>) => void
type WSContext<T = unknown> = { send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void; raw?: T; binaryType: BinaryType; readyState: WSReadyState; url: URL | null; protocol: string | null; close(code?: number, reason?: string): void; }
onClose?:
(type parameter) T in WSEvents<T = unknown>
(evt:
(property) WSEvents<T = unknown>.onClose?: ((evt: CloseEvent, ws: WSContext<T>) => void) | undefined
CloseEvent,
(parameter) evt: CloseEvent
ws:
interface CloseEvent
A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute.WSContext
(parameter) ws: WSContext<T>
<T>) => void
type WSContext<T = unknown> = { send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void; raw?: T; binaryType: BinaryType; readyState: WSReadyState; url: URL | null; protocol: string | null; close(code?: number, reason?: string): void; }
onError?:
(type parameter) T in WSEvents<T = unknown>
(evt:
(property) WSEvents<T = unknown>.onError?: ((evt: Event, ws: WSContext<T>) => void) | undefined
Event,
(parameter) evt: Event
ws:
interface Event
An event which takes place in the DOM.WSContext
(parameter) ws: WSContext<T>
<T>) => void
type WSContext<T = unknown> = { send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void; raw?: T; binaryType: BinaryType; readyState: WSReadyState; url: URL | null; protocol: string | null; close(code?: number, reason?: string): void; }
} /** * Upgrade WebSocket Type */ export type UpgradeWebSocket
(type parameter) T in WSEvents<T = unknown>
<T = unknown,
type UpgradeWebSocket<T = unknown, U = any> = (createEvents: (c: Context) => WSEvents<T> | Promise<WSEvents<T>>, options?: U) => MiddlewareHandler<any, string, { outputFormat: "ws"; }>
Upgrade WebSocket TypeU = any> = (
(type parameter) T in type UpgradeWebSocket<T = unknown, U = any>
createEvents:
(type parameter) U in type UpgradeWebSocket<T = unknown, U = any>
(c:
(parameter) createEvents: (c: Context) => WSEvents<T> | Promise<WSEvents<T>>
Context) =>
(parameter) c: Context<any, any, {}>
WSEvents
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
<T> |
interface WSEvents<T = unknown>
WebSocket Event Listeners typePromise
(type parameter) T in type UpgradeWebSocket<T = unknown, U = any>
<WSEvents
interface Promise<T>
Represents the completion of an asynchronous operation<T>>,
interface WSEvents<T = unknown>
WebSocket Event Listeners typeoptions?:
(type parameter) T in type UpgradeWebSocket<T = unknown, U = any>
U
(parameter) options: U | undefined
) => MiddlewareHandler<
(type parameter) U in type UpgradeWebSocket<T = unknown, U = any>
any, string, { outputFormat: 'ws'
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
} > export type WSReadyState = 0 | 1 | 2 | 3
(property) outputFormat: "ws"
export type WSContext
type WSReadyState = 0 | 2 | 1 | 3
<T = unknown> = {
type WSContext<T = unknown> = { send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void; raw?: T; binaryType: BinaryType; readyState: WSReadyState; url: URL | null; protocol: string | null; close(code?: number, reason?: string): void; }
send(
(type parameter) T in type WSContext<T = unknown>
source: string |
(method) send(source: string | ArrayBuffer | Uint8Array, options?: { compress: boolean; }): void
ArrayBuffer |
(parameter) source: string | ArrayBuffer | Uint8Array
Uint8Array,
interface ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the different typed arrays. ArrayBuffers cannot be read from or written to directly, but can be passed to a typed array or DataView Object to interpret the raw buffer as needed.options?: {
interface Uint8Array
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.compress: boolean
(parameter) options: { compress: boolean; } | undefined
} ): void raw?:
(property) compress: boolean
T
(property) raw?: T | undefined
binaryType:
(type parameter) T in type WSContext<T = unknown>
BinaryType
(property) binaryType: BinaryType
readyState:
type BinaryType = "blob" | "arraybuffer"
WSReadyState
(property) readyState: WSReadyState
url:
type WSReadyState = 0 | 2 | 1 | 3
URL | null
(property) url: URL | null
protocol: string | null
interface URL
The URL interface represents an object providing static methods used for creating object URLs.close
(property) protocol: string | null
(code?: number,
(method) close(code?: number, reason?: string): void
reason?: string): void
(parameter) code: number | undefined
} export type WSMessageReceive = string |
(parameter) reason: string | undefined
Blob |
type WSMessageReceive = string | Blob | ArrayBufferLike
ArrayBufferLike
interface Blob
A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.export const createWSMessageEvent =
type ArrayBufferLike = ArrayBuffer | SharedArrayBuffer
(source:
const createWSMessageEvent: (source: WSMessageReceive) => MessageEvent<WSMessageReceive>
WSMessageReceive):
(parameter) source: WSMessageReceive
MessageEvent
type WSMessageReceive = string | Blob | ArrayBufferLike
<WSMessageReceive> => {
interface MessageEvent<T = any>
A message received by a target object.return new MessageEvent
type WSMessageReceive = string | Blob | ArrayBufferLike
<WSMessageReceive>('message', {
var MessageEvent: new <WSMessageReceive>(type: string, eventInitDict?: MessageEventInit<WSMessageReceive> | undefined) => MessageEvent<WSMessageReceive>
A message received by a target object.data:
type WSMessageReceive = string | Blob | ArrayBufferLike
source,
(property) MessageEventInit<WSMessageReceive>.data?: WSMessageReceive | undefined
}) }
(parameter) source: WSMessageReceive
/** * @module * This module is the base module for the Hono object. */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { compose } from './compose' import { Context } from './context' import type { ExecutionContext } from './context' import type { Router } from './router' import { METHODS, METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE } from './router' import type { Env, ErrorHandler, FetchEventLike, H, HTTPResponseError, HandlerInterface, MergePath, MergeSchemaPath, MiddlewareHandler, MiddlewareHandlerInterface, Next, NotFoundHandler, OnHandlerInterface, RouterRoute, Schema, } from './types' import { getPath, getPathNoStrict, mergePath } from './utils/url' /** * Symbol used to mark a composed handler. */ export const COMPOSED_HANDLER =Symbol('composedHandler')
const COMPOSED_HANDLER: typeof COMPOSED_HANDLER
Symbol used to mark a composed handler.
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
const notFoundHandler =description
— Description of the new Symbol object.(c:
const notFoundHandler: (c: Context) => Response & TypedResponse<"404 Not Found", 404, "text">
Context) => {
(parameter) c: Context<any, any, {}>
return c
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.text('404 Not Found', 404)
(parameter) c: Context<any, any, {}>
} const errorHandler =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"404 Not Found", 404>(text: "404 Not Found", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"404 Not Found", 404, "text"> (+1 overload)
(err:
const errorHandler: (err: Error | HTTPResponseError, c: Context) => Response
Error |
(parameter) err: Error | HTTPResponseError
HTTPResponseError,
interface Error
c:
(alias) interface HTTPResponseError import HTTPResponseError
Context) => {
(parameter) c: Context<any, any, {}>
if ('getResponse' in err) {
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
return err
(parameter) err: Error | HTTPResponseError
.getResponse()
(parameter) err: HTTPResponseError
} console
(property) HTTPResponseError.getResponse: () => Response
.error
var console: Console
(err)
(method) Console.error(...data: any[]): void
MDN Referencereturn c
(parameter) err: Error
.text('Internal Server Error', 500)
(parameter) c: Context<any, any, {}>
} type GetPath
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Internal Server Error", 500>(text: "Internal Server Error", status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Internal Server Error", 500, "text"> (+1 overload)
<E extends
type GetPath<E extends Env> = (request: Request, options?: { env?: E["Bindings"]; }) => string
Env> =
(type parameter) E in type GetPath<E extends Env>
(request:
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Request,
(parameter) request: Request
options?: {
interface Request
This Fetch API interface represents a resource request.env?:
(parameter) options: { env?: E["Bindings"]; } | undefined
E['Bindings'] }) => string
(property) env?: E["Bindings"] | undefined
export type HonoOptions
(type parameter) E in type GetPath<E extends Env>
<E extends
type HonoOptions<E extends Env> = { strict?: boolean; router?: Router<[H, RouterRoute]>; getPath?: GetPath<E>; }
Env> = {
(type parameter) E in 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
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
(property) strict?: boolean | undefined
strict
option specifies whether to distinguish whether the last path is a directory or not.@see — https://hono.dev/docs/api/hono#strict-mode
@default
/** * `router` option specifices which router to use. * * @see {@link https://hono.dev/docs/api/hono#router-option} * * @example * ```ts * const app = new Hono({ router: new RegExpRouter() }) * ``` */ router?:
true
(property) router?: Router<[H, RouterRoute]> | undefined
router
option specifices which router to use.@see — https://hono.dev/docs/api/hono#router-option
@example
Router<
ts const app = new Hono({ router: new RegExpRouter() })
(alias) interface Router<T> import Router
Interface representing a router.@template
[H,T
— The type of the handler.RouterRoute]>
(alias) 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> import H
/** * `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?:
(alias) interface RouterRoute import RouterRoute
(property) getPath?: GetPath<E> | undefined
getPath
can handle the host header value.@see — 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<E>
type GetPath<E extends Env> = (request: Request, options?: { env?: E["Bindings"]; }) => string
} type MountOptionHandler =
(type parameter) E in type HonoOptions<E extends Env>
(c:
type MountOptionHandler = (c: Context) => unknown
Context) => unknown
(parameter) c: Context<any, any, {}>
type MountReplaceRequest =
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(originalRequest:
type MountReplaceRequest = (originalRequest: Request) => Request
Request) =>
(parameter) originalRequest: Request
Request
interface Request
This Fetch API interface represents a resource request.type MountOptions =
interface Request
This Fetch API interface represents a resource request.| MountOptionHandler
type MountOptions = MountOptionHandler | { optionHandler?: MountOptionHandler; replaceRequest?: MountReplaceRequest; }
| { optionHandler?:
type MountOptionHandler = (c: Context) => unknown
MountOptionHandler
(property) optionHandler?: MountOptionHandler | undefined
replaceRequest?:
type MountOptionHandler = (c: Context) => unknown
MountReplaceRequest
(property) replaceRequest?: MountReplaceRequest | undefined
} class Hono
type MountReplaceRequest = (originalRequest: Request) => Request
<E extends
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
Env =
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
Env,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
S extends
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Schema = {},
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath extends string = '/'> {
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
get!:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
HandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.get: HandlerInterface<E, "get", S, BasePath>
<E, 'get',
(alias) interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> import HandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
post!:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
HandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.post: HandlerInterface<E, "post", S, BasePath>
<E, 'post',
(alias) interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> import HandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
put!:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
HandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.put: HandlerInterface<E, "put", S, BasePath>
<E, 'put',
(alias) interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> import HandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
delete!:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
HandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.delete: HandlerInterface<E, "delete", S, BasePath>
<E, 'delete',
(alias) interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> import HandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
options!:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
HandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.options: HandlerInterface<E, "options", S, BasePath>
<E, 'options',
(alias) interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> import HandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
patch!:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
HandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.patch: HandlerInterface<E, "patch", S, BasePath>
<E, 'patch',
(alias) interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> import HandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
all!:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
HandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.all: HandlerInterface<E, "all", S, BasePath>
<E, 'all',
(alias) interface HandlerInterface<E extends Env = Env, M extends string = string, S extends Schema = BlankSchema, BasePath extends string = "/"> import HandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
on:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
OnHandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.on: OnHandlerInterface<E, S, BasePath>
<E,
(alias) interface OnHandlerInterface<E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/"> import OnHandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
use:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
MiddlewareHandlerInterface
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.use: MiddlewareHandlerInterface<E, S, BasePath>
<E,
(alias) interface MiddlewareHandlerInterface<E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/"> import MiddlewareHandlerInterface
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
/* This class is like an abstract class and does not have a router. To use it, inherit the class and implement router in the constructor. */ router!:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
Router<
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.router: Router<[H, RouterRoute]>
(alias) interface Router<T> import Router
Interface representing a router.@template
[H,T
— The type of the handler.RouterRoute]>
(alias) 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> import H
readonly getPath:
(alias) interface RouterRoute import RouterRoute
GetPath
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.getPath: GetPath<E>
<E>
type GetPath<E extends Env> = (request: Request, options?: { env?: E["Bindings"]; }) => string
// Cannot use `#` because it requires visibility at JavaScript runtime. private _basePath: string = '/'
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
#path: string = '/' routes:
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">._basePath: string
RouterRoute[] = []
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.routes: RouterRoute[]
constructor(options:
(alias) interface RouterRoute import RouterRoute
HonoOptions
(parameter) options: HonoOptions<E>
<E> = {}) {
type HonoOptions<E extends Env> = { strict?: boolean; router?: Router<[H, RouterRoute]>; getPath?: GetPath<E>; }
// Implementation of app.get(...handlers[]) or app.get(path, ...handlers[]) const allMethods = [..
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
.METHODS,
const allMethods: ("delete" | "all" | "get" | "post" | "put" | "options" | "patch")[]
METHOD_NAME_ALL_LOWERCASE]
(alias) const METHODS: readonly ["get", "post", "put", "delete", "options", "patch"] import METHODS
Array of supported HTTP methods.allMethods
(alias) const METHOD_NAME_ALL_LOWERCASE: "all" import METHOD_NAME_ALL_LOWERCASE
Constant representing all HTTP methods in lowercase..forEach(
const allMethods: ("delete" | "all" | "get" | "post" | "put" | "options" | "patch")[]
(method) Array<"delete" | "all" | "get" | "post" | "put" | "options" | "patch">.forEach(callbackfn: (value: "delete" | "all" | "get" | "post" | "put" | "options" | "patch", index: number, array: ("delete" | "all" | "get" | "post" | "put" | "options" | "patch")[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(method) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.this[method] =
(parameter) method: "delete" | "all" | "get" | "post" | "put" | "options" | "patch"
(args1: string |
(parameter) method: "delete" | "all" | "get" | "post" | "put" | "options" | "patch"
H, ..
(parameter) args1: string | H
.args:
(alias) 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> import H
H[]) => {
(parameter) args: H[]
if (typeof args1 === 'string') {
(alias) 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> import H
this.#path = args1
(parameter) args1: string | H
} else { this.addRoute
(parameter) args1: string
(method, this.#path,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.addRoute(method: string, path: string, handler: H): void
args1)
(parameter) method: "delete" | "all" | "get" | "post" | "put" | "options" | "patch"
} args
(parameter) args1: H
.forEach(
(parameter) args: H[]
(method) Array<H>.forEach(callbackfn: (value: H, index: number, array: H[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(handler) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.if (typeof handler !== 'string') {
(parameter) handler: H
this.addRoute
(parameter) handler: H
(method, this.#path,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.addRoute(method: string, path: string, handler: H): void
handler)
(parameter) method: "delete" | "all" | "get" | "post" | "put" | "options" | "patch"
} }) return this as any } }) // Implementation of app.on(method, path, ...handlers[]) this.on =
(parameter) handler: H
(method: string | string[],
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.on: OnHandlerInterface<E, S, BasePath>
path: string | string[], ..
(parameter) method: string | string[]
.handlers:
(parameter) path: string | string[]
H[]) => {
(parameter) handlers: H[]
for (const p of
(alias) 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> import H
[path]
const p: string
.flat()) {
(parameter) path: string | string[]
(method) Array<string | string[]>.flat<(string | string[])[], 1>(this: (string | string[])[], depth?: 1 | undefined): string[]
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.@param
this.#path = pdepth
— The maximum recursion depthfor (const m of
const p: string
[method]
const m: string
.flat()) {
(parameter) method: string | string[]
(method) Array<string | string[]>.flat<(string | string[])[], 1>(this: (string | string[])[], depth?: 1 | undefined): string[]
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.@param
handlersdepth
— The maximum recursion depth.map(
(parameter) handlers: H[]
(method) Array<H>.map<void>(callbackfn: (value: H, index: number, array: H[]) => void, thisArg?: any): void[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(handler) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.this.addRoute
(parameter) handler: H
(m
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.addRoute(method: string, path: string, handler: H): void
.toUpperCase(), this.#path,
const m: string
handler)
(method) String.toUpperCase(): string
Converts all the alphabetic characters in a string to uppercase.}) } } return this as any } // Implementation of app.use(...handlers[]) or app.use(path, ...handlers[]) this.use =
(parameter) handler: H
(arg1: string |
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.use: MiddlewareHandlerInterface<E, S, BasePath>
MiddlewareHandler
(parameter) arg1: string | MiddlewareHandler<any>
, .. .handlers:
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
MiddlewareHandler
(parameter) handlers: MiddlewareHandler<any>[]
[]) => { if (typeof arg1 === 'string') {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
this.#path = arg1
(parameter) arg1: string | MiddlewareHandler<any>
} else { this.#path = '*' handlers
(parameter) arg1: string
.unshift
(parameter) handlers: MiddlewareHandler<any>[]
(method) Array<MiddlewareHandler<any>>.unshift(...items: MiddlewareHandler<any>[]): number
Inserts new elements at the start of an array, and returns the new length of the array.@param
(arg1)items
— Elements to insert at the start of the array.} handlers
(parameter) arg1: MiddlewareHandler<any>
.forEach(
(parameter) handlers: MiddlewareHandler<any>[]
(method) Array<MiddlewareHandler<any>>.forEach(callbackfn: (value: MiddlewareHandler<any>, index: number, array: MiddlewareHandler<any>[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(handler) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.this.addRoute
(parameter) handler: MiddlewareHandler<any>
(METHOD_NAME_ALL, this.#path,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.addRoute(method: string, path: string, handler: H): void
handler)
(alias) const METHOD_NAME_ALL: "ALL" import METHOD_NAME_ALL
Constant representing all HTTP methods in uppercase.}) return this as any } const strict =
(parameter) handler: MiddlewareHandler<any>
options
const strict: boolean
.strict ?? true
(parameter) options: HonoOptions<E>
(property) strict?: boolean | undefined
strict
option specifies whether to distinguish whether the last path is a directory or not.@see — https://hono.dev/docs/api/hono#strict-mode
@default
delete options
true
.strict
(parameter) options: HonoOptions<E>
(property) strict?: boolean | undefined
strict
option specifies whether to distinguish whether the last path is a directory or not.@see — https://hono.dev/docs/api/hono#strict-mode
@default
Object
true
.assign(this,
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.assign<this, HonoOptions<E>>(target: this, source: HonoOptions<E>): this & HonoOptions<E> (+3 overloads)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.@param
target
— The target object to copy to.@param
options)source
— The source object from which to copy properties.this.getPath =
(parameter) options: HonoOptions<E>
strict ?
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.getPath: GetPath<E>
options
const strict: boolean
.getPath ??
(parameter) options: HonoOptions<E>
(property) getPath?: GetPath<E> | undefined
getPath
can handle the host header value.@see — 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 :getPathNoStrict
(alias) const getPath: (request: Request) => string import getPath
} private clone():
(alias) const getPathNoStrict: (request: Request) => string import getPathNoStrict
Hono
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.clone(): Hono<E, S, BasePath>
<E,
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath> {
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
const clone = new
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
Hono
const clone: Hono<E, S, BasePath>
<E,
constructor Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(options?: HonoOptions<E>): Hono<E, S, BasePath>
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath>({
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
router: this
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
(property) router?: Router<[H, RouterRoute]> | undefined
router
option specifices which router to use.@see — https://hono.dev/docs/api/hono#router-option
@example
.router,
ts const app = new Hono({ router: new RegExpRouter() })
getPath: this
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.router: Router<[H, RouterRoute]>
(property) getPath?: GetPath<E> | undefined
getPath
can handle the host header value.@see — 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,}) clone
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.getPath: GetPath<E>
.routes = this
const clone: Hono<E, S, BasePath>
.routes
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.routes: RouterRoute[]
return clone
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.routes: RouterRoute[]
} private notFoundHandler:
const clone: Hono<E, S, BasePath>
NotFoundHandler =
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.notFoundHandler: NotFoundHandler
notFoundHandler
(alias) type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response> import NotFoundHandler
private errorHandler:
const notFoundHandler: (c: Context) => Response & TypedResponse<"404 Not Found", 404, "text">
ErrorHandler =
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.errorHandler: ErrorHandler
errorHandler
(alias) type ErrorHandler<E extends Env = any> = (err: Error | HTTPResponseError, c: Context<E>) => Response | Promise<Response> import ErrorHandler
/** * `.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<
const errorHandler: (err: Error | HTTPResponseError, c: Context) => Response
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
SubPath extends string,SubEnv extends
(type parameter) SubPath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
Env,
(type parameter) SubEnv in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
SubSchema extends
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
Schema,
(type parameter) SubSchema in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
SubBasePath extends string
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
>( path:
(type parameter) SubBasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
(parameter) path: SubPath extends string
- base Path@param
SubPath,path
— base Pathapp:
(type parameter) SubPath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
(parameter) app: Hono<SubEnv, SubSchema, SubBasePath>
- other Hono instance@param
Honoapp
— other Hono instance<SubEnv,
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
SubSchema,
(type parameter) SubEnv in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
SubBasePath>
(type parameter) SubSchema in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
): Hono
(type parameter) SubBasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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>
<E,
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
MergeSchemaPath
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
<SubSchema,
(alias) type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> = { [KeyType in keyof { [P in keyof OrigSchema as MergePath<SubPath, P & string>]: { [M in keyof OrigSchema[P]]: MergeEndpointParamsWithPath<OrigSchema[P][M], SubPath>; }; }]: { [P in keyof OrigSchema as MergePath<SubPath, P & string>]: { [M in keyof OrigSchema[P]]: MergeEndpointParamsWithPath<OrigSchema[P][M], SubPath>; }; }[KeyType]; } import MergeSchemaPath
MergePath
(type parameter) SubSchema in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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,
(alias) type MergePath<A extends string, B extends string> = B extends "" ? A extends "" ? "/" : A extends "/" ? "/" : A extends `${infer P}/` ? `${P}/` : 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}` import MergePath
SubPath>> &
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
S,
(type parameter) SubPath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.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> {
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
const subApp = this
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
.basePath
const subApp: Hono<E, S, MergePath<BasePath, SubPath>>
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.basePath<SubPath>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>>
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
(path)
ts const api = new Hono().basePath('/api')
(parameter) path: SubPath extends string
- base Path@param
apppath
— base Path
(parameter) app: Hono<SubEnv, SubSchema, SubBasePath>
- other Hono instance@param
.routesapp
— other Hono instance.map(
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.routes: RouterRoute[]
(method) Array<RouterRoute>.map<void>(callbackfn: (value: RouterRoute, index: number, array: RouterRoute[]) => void, thisArg?: any): void[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(r) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.let handler
(parameter) r: RouterRoute
if (app
let handler: any
(parameter) app: Hono<SubEnv, SubSchema, SubBasePath>
- other Hono instance@param
.errorHandler ===app
— other Hono instanceerrorHandler) {
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.errorHandler: ErrorHandler
handler =
const errorHandler: (err: Error | HTTPResponseError, c: Context) => Response
r
let handler: any
.handler
(parameter) r: RouterRoute
} else { handler = async
(property) RouterRoute.handler: H<any, any, BlankInput, any>
(c:
let handler: any
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Next) =>
(parameter) next: Next
(await compose
(alias) type Next = () => Promise<void> import Next
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>([],app
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
(parameter) app: Hono<SubEnv, SubSchema, SubBasePath>
- other Hono instance@param
.errorHandler)app
— other Hono instance(c, () =>
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.errorHandler: ErrorHandler
r
(parameter) c: Context<any, any, {}>
.handler
(parameter) r: RouterRoute
(c,
(property) RouterRoute.handler: (c: Context<any, any, BlankInput>, next: Next) => any
next)))
(parameter) c: Context<any, any, {}>
.res
(parameter) next: Next
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
;(handler as any)_res
— The Response object to set.[COMPOSED_HANDLER] =
let handler: (c: Context, next: Next) => Promise<Response>
r
const COMPOSED_HANDLER: typeof COMPOSED_HANDLER
Symbol used to mark a composed handler..handler
(parameter) r: RouterRoute
} subApp
(property) RouterRoute.handler: H<any, any, BlankInput, any>
.addRoute
const subApp: Hono<E, S, MergePath<BasePath, SubPath>>
(r
(method) Hono<E, S, MergePath<BasePath, SubPath>>.addRoute(method: string, path: string, handler: H): void
.method,
(parameter) r: RouterRoute
r
(property) RouterRoute.method: string
.path,
(parameter) r: RouterRoute
handler)
(property) RouterRoute.path: string
}) return this } /** * `.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
let handler: H<any, any, BlankInput, any>
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>>
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
<SubPath extends string>
ts const api = new Hono().basePath('/api')
(path:
(type parameter) SubPath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>>
(parameter) path: SubPath extends string
- base Path@param
SubPath):path
— base PathHono
(type parameter) SubPath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>>
<E,
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
MergePath
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
<BasePath,
(alias) type MergePath<A extends string, B extends string> = B extends "" ? A extends "" ? "/" : A extends "/" ? "/" : A extends `${infer P}/` ? `${P}/` : 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}` import MergePath
SubPath>> {
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
const subApp = this
(type parameter) SubPath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>>
.clone()
const subApp: Hono<E, S, BasePath>
subApp
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.clone(): Hono<E, S, BasePath>
._basePath =
const subApp: Hono<E, S, BasePath>
mergePath(this
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">._basePath: string
._basePath,
(alias) mergePath(...paths: string[]): string import mergePath
path)
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">._basePath: string
(parameter) path: SubPath extends string
- base Path@param
return subApppath
— base Path} /** * `.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 =
const subApp: Hono<E, S, BasePath>
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.onError: (handler: ErrorHandler<E>) => Hono<E, S, BasePath>
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(handler:
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
(parameter) handler: ErrorHandler<E>
- request Handler for error@param
ErrorHandlerhandler
— request Handler for error<E>):
(alias) type ErrorHandler<E extends Env = any> = (err: Error | HTTPResponseError, c: Context<E>) => Response | Promise<Response> import ErrorHandler
Hono
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
<E,
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath> => {
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
this.errorHandler =
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
handler
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.errorHandler: ErrorHandler
(parameter) handler: ErrorHandler<E>
- request Handler for error@param
return this } /** * `.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
— request Handler for error
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.notFound: (handler: NotFoundHandler<E>) => Hono<E, S, BasePath>
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
(handler:
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
(parameter) handler: NotFoundHandler<E>
- request handler for not-found@param
NotFoundHandlerhandler
— request handler for not-found<E>):
(alias) type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response> import NotFoundHandler
Hono
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
<E,
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath> => {
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
this.notFoundHandler =
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
handler
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.notFoundHandler: NotFoundHandler
(parameter) handler: NotFoundHandler<E>
- request handler for not-found@param
return this } /** * `.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(handler
— request handler for not-found
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<E, S, BasePath>
.mount()
allows you to mount applications built with other frameworks into your Hono application.@see — https://hono.dev/docs/api/hono#mount
@param
path
— base Path@param
applicationHandler
— other Request Handler@param
options
— options of.mount()
@returns — 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
path: string,
ts const app = new Hono() // Send the request to another application without modification. app.mount('/app', anotherApp, { replaceRequest: (req) => req, })
(parameter) path: string
- base Path@param
applicationHandler:path
— base Path
(parameter) applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>
- other Request Handler@param
(request:applicationHandler
— other Request HandlerRequest, ..
(parameter) request: Request
.args: any) =>
interface Request
This Fetch API interface represents a resource request.Response |
(parameter) args: any
Promise
interface Response
This Fetch API interface represents the response to a request.<Response>,
interface Promise<T>
Represents the completion of an asynchronous operationoptions?:
interface Response
This Fetch API interface represents the response to a request.
(parameter) options: MountOptions | undefined
- options of.mount()
@param
MountOptionsoptions
— options of.mount()
): Hono
type MountOptions = MountOptionHandler | { optionHandler?: MountOptionHandler; replaceRequest?: MountReplaceRequest; }
<E,
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
S,
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
BasePath> {
(type parameter) S in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
// handle options let replaceRequest:
(type parameter) BasePath in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
MountReplaceRequest | undefined
let replaceRequest: MountReplaceRequest | undefined
let optionHandler:
type MountReplaceRequest = (originalRequest: Request) => Request
MountOptionHandler | undefined
let optionHandler: MountOptionHandler | undefined
if (options) {
type MountOptionHandler = (c: Context) => unknown
(parameter) options: MountOptions | undefined
- options of.mount()
@param
if (typeof options === 'function') {options
— options of.mount()
(parameter) options: MountOptions
- options of.mount()
@param
optionHandler =options
— options of.mount()
options
let optionHandler: MountOptionHandler | undefined
(parameter) options: MountOptionHandler
- options of.mount()
@param
} else { optionHandler =options
— options of.mount()
options
let optionHandler: MountOptionHandler | undefined
(parameter) options: { optionHandler?: MountOptionHandler; replaceRequest?: MountReplaceRequest; }
- options of.mount()
@param
.optionHandleroptions
— options of.mount()
replaceRequest =
(property) optionHandler?: MountOptionHandler | undefined
options
let replaceRequest: MountReplaceRequest | undefined
(parameter) options: { optionHandler?: MountOptionHandler; replaceRequest?: MountReplaceRequest; }
- options of.mount()
@param
.replaceRequestoptions
— options of.mount()
} } // prepare handlers for request const getOptions:
(property) replaceRequest?: MountReplaceRequest | undefined
(c:
const getOptions: (c: Context) => unknown[]
Context) => unknown[] =
(parameter) c: Context<any, any, {}>
optionHandler
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
? (c) => {
let optionHandler: MountOptionHandler | undefined
const options =
(parameter) c: Context<any, any, {}>
optionHandler!
const options: unknown
(c)
let optionHandler: MountOptionHandler
return Array
(parameter) c: Context<any, any, {}>
.isArray
var Array: ArrayConstructor
(options) ?
(method) ArrayConstructor.isArray(arg: any): arg is any[]
options :
const options: unknown
[options]
const options: any[]
} : (c) => {
const options: unknown
let executionContext:
(parameter) c: Context<any, any, {}>
ExecutionContext | undefined = undefined
let executionContext: ExecutionContext | undefined
try { executionContext =
(alias) interface ExecutionContext import ExecutionContext
Interface for the execution context in a web worker or similar environment.c
let executionContext: ExecutionContext | undefined
.executionCtx
(parameter) c: Context<any, any, {}>
(property) Context<any, any, {}>.executionCtx: ExecutionContext
@see — https://hono.dev/docs/api/context#executionctxThe ExecutionContext associated with the current request.
@throws — Will throw an error if the context does not have an ExecutionContext.
} catch {} // Do nothing return [c.env,
(parameter) c: Context<any, any, {}>
(property) Context<any, any, {}>.env: any
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
executionContext]
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
} replaceRequest ||= (() => {
let executionContext: ExecutionContext | undefined
const mergedPath =
let replaceRequest: MountReplaceRequest | undefined
mergePath(this
const mergedPath: string
._basePath,
(alias) mergePath(...paths: string[]): string import mergePath
path)
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">._basePath: string
(parameter) path: string
- base Path@param
const pathPrefixLength =path
— base PathmergedPath === '/' ? 0 :
const pathPrefixLength: number
mergedPath
const mergedPath: string
.length
const mergedPath: string
return (request) => {
(property) String.length: number
Returns the length of a String object.const url = new
(parameter) request: Request
URL
const url: URL
(request
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs..url)
(parameter) request: Request
url
(property) Request.url: string
Returns the URL of request as a string..pathname =
const url: URL
url
(property) URL.pathname: string
MDN Reference.pathname
const url: URL
.slice
(property) URL.pathname: string
MDN Reference
(method) String.slice(start?: number, end?: number): string
Returns a section of a string.@param
start
— The index to the beginning of the specified portion of stringObj.@param
(pathPrefixLength) || '/'end
The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of stringObj.return new Request
const pathPrefixLength: number
(url,
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.request)
const url: URL
} })() const handler:
(parameter) request: Request
MiddlewareHandler = async
const handler: MiddlewareHandler
(c,
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
next) => {
(parameter) c: Context<any, string, {}>
const res = await
(parameter) next: Next
applicationHandler
const res: Response
(parameter) applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>
- other Request Handler@param
(replaceRequest!applicationHandler
— other Request Handler(c
let replaceRequest: MountReplaceRequest
.req
(parameter) c: Context<any, string, {}>
.raw), ..
(property) Context<any, string, {}>.req: HonoRequest<string, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.getOptions
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
(c))
const getOptions: (c: Context) => unknown[]
if (res) {
(parameter) c: Context<any, string, {}>
return res
const res: Response
} await next()
const res: Response
} this.addRoute
(parameter) next: () => Promise<void>
(METHOD_NAME_ALL,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.addRoute(method: string, path: string, handler: H): void
mergePath
(alias) const METHOD_NAME_ALL: "ALL" import METHOD_NAME_ALL
Constant representing all HTTP methods in uppercase.(path, '*'),
(alias) mergePath(...paths: string[]): string import mergePath
(parameter) path: string
- base Path@param
handler)path
— base Pathreturn this } private addRoute
const handler: MiddlewareHandler
(method: string,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.addRoute(method: string, path: string, handler: H): void
path: string,
(parameter) method: string
handler:
(parameter) path: string
H) {
(parameter) handler: H
method =
(alias) 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> import H
method
(parameter) method: string
.toUpperCase()
(parameter) method: string
path =
(method) String.toUpperCase(): string
Converts all the alphabetic characters in a string to uppercase.mergePath(this
(parameter) path: string
._basePath,
(alias) mergePath(...paths: string[]): string import mergePath
path)
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">._basePath: string
const r:
(parameter) path: string
RouterRoute = {
const r: RouterRoute
path:
(alias) interface RouterRoute import RouterRoute
path,
(property) RouterRoute.path: string
method:
(parameter) path: string
method,
(property) RouterRoute.method: string
handler:
(parameter) method: string
handler }
(property) RouterRoute.handler: H<any, any, BlankInput, any>
this.router
(parameter) handler: H
.add
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.router: Router<[H, RouterRoute]>
(method) Router<[H, RouterRoute]>.add(method: string, path: string, handler: [H, RouterRoute]): void
Adds a route to the router.@param
method
— The HTTP method (e.g., 'get', 'post').@param
path
— The path for the route.@param
(method,handler
— The handler for the route.path,
(parameter) method: string
[handler,
(parameter) path: string
r])
(parameter) handler: H
this.routes
const r: RouterRoute
.push
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.routes: RouterRoute[]
(method) Array<RouterRoute>.push(...items: RouterRoute[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(r)items
— New elements to add to the array.} private matchRoute
const r: RouterRoute
(method: string,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.matchRoute(method: string, path: string): Result<[H, RouterRoute]>
path: string) {
(parameter) method: string
return this.router
(parameter) path: string
.match
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.router: Router<[H, RouterRoute]>
(method) Router<[H, RouterRoute]>.match(method: string, path: string): Result<[H, RouterRoute]>
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.
(method,path)
(parameter) method: string
} private handleError
(parameter) path: string
(err: unknown,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.handleError(err: unknown, c: Context<E>): Response | Promise<Response>
c:
(parameter) err: unknown
Context
(parameter) c: Context<E, any, {}>
<E>) {
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
if (err instanceof
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
Error) {
(parameter) err: unknown
return this.errorHandler
var Error: ErrorConstructor
(err,
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.errorHandler: (err: Error | HTTPResponseError, c: Context<any, any, {}>) => Response | Promise<Response>
c)
(parameter) err: Error
} throw err
(parameter) c: Context<E, any, {}>
} private dispatch(
(parameter) err: unknown
request:
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.dispatch(request: Request, executionCtx: ExecutionContext | FetchEventLike | undefined, env: E["Bindings"], method: string): Response | Promise<Response>
Request,
(parameter) request: Request
executionCtx:
interface Request
This Fetch API interface represents a resource request.ExecutionContext |
(parameter) executionCtx: FetchEventLike | ExecutionContext | undefined
FetchEventLike | undefined,
(alias) interface ExecutionContext import ExecutionContext
Interface for the execution context in a web worker or similar environment.env:
(alias) class FetchEventLike import FetchEventLike
E['Bindings'],
(parameter) env: E["Bindings"]
method: string
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
): Response |
(parameter) method: string
Promise
interface Response
This Fetch API interface represents the response to a request.<Response> {
interface Promise<T>
Represents the completion of an asynchronous operation// Handle HEAD method if (method === 'HEAD') {
interface Response
This Fetch API interface represents the response to a request.return (async () => new Response(null, await this
(parameter) method: string
.dispatch
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.(request,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.dispatch(request: Request, executionCtx: ExecutionContext | FetchEventLike | undefined, env: E["Bindings"], method: string): Response | Promise<Response>
executionCtx,
(parameter) request: Request
env, 'GET')))()
(parameter) executionCtx: FetchEventLike | ExecutionContext | undefined
} const path = this
(parameter) env: E["Bindings"]
.getPath
const path: string
(request, {
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.getPath: (request: Request, options?: { env?: E["Bindings"] | undefined; } | undefined) => string
env })
(parameter) request: Request
const matchResult = this
(property) env?: E["Bindings"] | undefined
.matchRoute
const matchResult: Result<[H, RouterRoute]>
(method,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.matchRoute(method: string, path: string): Result<[H, RouterRoute]>
path)
(parameter) method: string
const c = new
const path: string
Context
const c: Context<any, any, {}>
(alias) new Context<any, any, {}>(req: Request, options?: ContextOptions<any> | undefined): Context<any, any, {}> import Context
Creates an instance of the Context class.@param
req
— The Request object.@param
(request, {options
— Optional configuration options for the context.path,
(parameter) request: Request
matchResult,
(property) path?: string | undefined
env,
(property) matchResult?: Result<[H, RouterRoute]> | undefined
executionCtx,
(property) env: any
Bindings for the environment.notFoundHandler: this
(property) executionCtx?: FetchEventLike | ExecutionContext | undefined
Execution context for the request..notFoundHandler,
(property) notFoundHandler?: NotFoundHandler<any> | undefined
Handler for not found responses.}) // Do not `compose` if it has only one handler if (matchResult[0]
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.notFoundHandler: NotFoundHandler
.length === 1) {
const matchResult: Result<[H, RouterRoute]>
let res:
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.ReturnType
let res: any
<H>
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any
Obtain the return type of a function typetry { res =
(alias) 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> import H
matchResult[0][0][0][0]
let res: any
(c, async () => {
const matchResult: Result<[H, RouterRoute]>
c
const c: Context<any, any, {}>
.res = await this
const c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.notFoundHandler_res
— The Response object to set.(c)
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.notFoundHandler: (c: Context<any, any, {}>) => Response | Promise<Response>
}) } catch (err) {
const c: Context<any, any, {}>
return this.handleError
(local var) err: unknown
(err,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.handleError(err: unknown, c: Context<E>): Response | Promise<Response>
c)
(local var) err: unknown
} return res instanceof
const c: Context<any, any, {}>
Promise
let res: any
? res
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.then(
let res: Promise<any>
(method) Promise<any>.then<Response, never>(onfulfilled?: ((value: any) => Response | PromiseLike<Response>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<never>) | null | undefined): Promise<...>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(resolved:Response | undefined) =>
(parameter) resolved: Response | undefined
resolved ||
interface Response
This Fetch API interface represents the response to a request.(c
(parameter) resolved: Response | undefined
.finalized ?
const c: Context<any, any, {}>
c
(property) Context<any, any, {}>.finalized: boolean
.res : this
const c: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.notFoundHandler_res
— The Response object to set.(c))
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.notFoundHandler: (c: Context<any, any, {}>) => Response | Promise<Response>
) .catch(
const c: Context<any, any, {}>
(method) Promise<Response>.catch<Response>(onrejected?: ((reason: any) => Response | PromiseLike<Response>) | null | undefined): Promise<Response>
Attaches a callback for only the rejection of the Promise.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of the callback.
(err:Error) => this
(parameter) err: Error
.handleError
interface Error
(err,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.handleError(err: unknown, c: Context<E>): Response | Promise<Response>
c))
(parameter) err: Error
: res ?? this
const c: Context<any, any, {}>
.notFoundHandler
let res: any
(c)
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.notFoundHandler: (c: Context<any, any, {}>) => Response | Promise<Response>
} const composed =
const c: Context<any, any, {}>
compose
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
(alias) compose<Context<any, any, {}>, Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<Env> | undefined, onNotFound?: NotFoundHandler<...> | undefined): (context: Context<...>, next?: Function) => Promise<...> import compose
Compose middleware functions into a single function based onkoa-compose
package.@template
C
— The context type.@template
E
— The environment type.@param
middleware
— An array of middleware functions and their corresponding parameters.@param
onError
— An optional error handler function.@param
onNotFound
— An optional not-found handler function.@returns — - A composed middleware function.
<Context>(matchResult[0], this
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
.errorHandler, this
const matchResult: Result<[H, RouterRoute]>
.notFoundHandler)
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.errorHandler: ErrorHandler
return (async () => { try { const context = await
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.notFoundHandler: NotFoundHandler
composed
const context: Context<any, any, {}>
(c)
const composed: (context: Context<any, any, {}>, next?: Function) => Promise<Context<any, any, {}>>
if (!context
const c: Context<any, any, {}>
.finalized) {
const context: Context<any, any, {}>
throw new Error(
(property) Context<any, any, {}>.finalized: boolean
'Context is not finalized. Did you forget to return a Response object or `await next()`?' ) } return context
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.res
const context: Context<any, any, {}>
(property) Context<any, any, {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
} catch (err) {_res
— The Response object to set.return this.handleError
(local var) err: unknown
(err,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.handleError(err: unknown, c: Context<E>): Response | Promise<Response>
c)
(local var) err: unknown
} })() } /** * `.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
const c: Context<any, any, {}>
} response of request * */ fetch: (
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.fetch: (request: Request, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
request:
(parameter) request: Request
- request Object of request@param
Request,request
— request Object of requestEnv?:
interface Request
This Fetch API interface represents a resource request.
(parameter) Env: {} | E["Bindings"] | undefined
- env Object@param
E['Bindings'] | {},Env
— env ObjectexecutionCtx?:
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
ExecutionContext
(parameter) executionCtx: ExecutionContext | undefined
) => Response |
(alias) interface ExecutionContext import ExecutionContext
Interface for the execution context in a web worker or similar environment.Promise
interface Response
This Fetch API interface represents the response to a request.<Response> =
interface Promise<T>
Represents the completion of an asynchronous operation(request, ..
interface Response
This Fetch API interface represents the response to a request.
(parameter) request: Request
- request Object of request@param
.rest) => {request
— request Object of requestreturn this.dispatch
(parameter) rest: [Env?: {} | E["Bindings"] | undefined, executionCtx?: ExecutionContext | undefined]
(request,
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.dispatch(request: Request, executionCtx: ExecutionContext | FetchEventLike | undefined, env: E["Bindings"], method: string): Response | Promise<Response>
(parameter) request: Request
- request Object of request@param
rest[1],request
— request Object of requestrest[0],
(parameter) rest: [Env?: {} | E["Bindings"] | undefined, executionCtx?: ExecutionContext | undefined]
request
(parameter) rest: [Env?: {} | E["Bindings"] | undefined, executionCtx?: ExecutionContext | undefined]
(parameter) request: Request
- request Object of request@param
.method)request
— request Object of request} /** * `.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 = (
(property) Request.method: string
Returns request's HTTP method, which is "GET" by default.
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, 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
input:RequestInfo |
(parameter) input: RequestInfo | URL
URL,
type RequestInfo = string | Request
requestInit?:
interface URL
The URL interface represents an object providing static methods used for creating object URLs.RequestInit,
(parameter) requestInit: RequestInit | undefined
Env?:
interface RequestInit
E['Bindings'] | {},
(parameter) Env: {} | E["Bindings"] | undefined
executionCtx?:
(type parameter) E in Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
ExecutionContext
(parameter) executionCtx: ExecutionContext | undefined
): Response |
(alias) interface ExecutionContext import ExecutionContext
Interface for the execution context in a web worker or similar environment.Promise
interface Response
This Fetch API interface represents the response to a request.<Response> => {
interface Promise<T>
Represents the completion of an asynchronous operationif (input instanceof
interface Response
This Fetch API interface represents the response to a request.Request) {
(parameter) input: RequestInfo | URL
if (requestInit !== undefined) {
var Request: { new (input: RequestInfo | URL, init?: RequestInit): Request; prototype: Request; }
This Fetch API interface represents a resource request.input = new
(parameter) requestInit: RequestInit | undefined
Request
(parameter) input: RequestInfo | URL
(input,
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.requestInit)
(parameter) input: Request
} return this.fetch
(parameter) requestInit: RequestInit
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.fetch: (request: Request, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(input,Env,
(parameter) input: Request
executionCtx)
(parameter) Env: {} | E["Bindings"] | undefined
} input =
(parameter) executionCtx: ExecutionContext | undefined
input
(parameter) input: RequestInfo | URL
.toString()
(parameter) input: string | URL
const path = /^https?:\/\//
(method) toString(): string
Returns a string representation of a string..test
const path: string
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
(input) ?string
— String on which to perform the search.input : `http://localhost$
(parameter) input: string
{mergePath('/',
(parameter) input: string
input)}`
(alias) mergePath(...paths: string[]): string import mergePath
const req = new
(parameter) input: string
Request
const req: Request
(path,
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.requestInit)
const path: string
return this.fetch
(parameter) requestInit: RequestInit | undefined
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.fetch: (request: Request, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(req,Env,
const req: Request
executionCtx)
(parameter) Env: {} | E["Bindings"] | undefined
} /** * `.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 => {
(parameter) executionCtx: ExecutionContext | undefined
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.fire: () => void
.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/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore addEventListener('fetch',(event:
function addEventListener<keyof WindowEventMap>(type: keyof WindowEventMap, listener: (this: Window, ev: ErrorEvent | Event | DeviceMotionEvent | ... 25 more ... | StorageEvent) => any, options?: boolean | AddEventListenerOptions): void (+1 overload)
FetchEventLike): void => {
(parameter) event: FetchEventLike
event
(alias) class FetchEventLike import FetchEventLike
.respondWith(this
(parameter) event: FetchEventLike
.dispatch
(method) FetchEventLike.respondWith(promise: Response | Promise<Response>): void
(event
(method) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.dispatch(request: Request, executionCtx: ExecutionContext | FetchEventLike | undefined, env: E["Bindings"], method: string): Response | Promise<Response>
.request,
(parameter) event: FetchEventLike
event, undefined,
(property) FetchEventLike.request: Request
event
(parameter) event: FetchEventLike
.request
(parameter) event: FetchEventLike
.method))
(property) FetchEventLike.request: Request
}) } } export { Hono as
(property) Request.method: string
Returns request's HTTP method, which is "GET" by default.HonoBase }
class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">
(alias) class HonoBase<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/"> export HonoBase
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { expectTypeOf } from 'vitest' import { hc } from './client' import type { Context, ExecutionContext } from './context' import { Hono } from './hono' import { HTTPException } from './http-exception' import { logger } from './middleware/logger' import { poweredBy } from './middleware/powered-by' import { RegExpRouter } from './router/reg-exp-router' import { SmartRouter } from './router/smart-router' import { TrieRouter } from './router/trie-router' import type { Handler, MiddlewareHandler, Next } from './types' import type { Equal, Expect } from './utils/types' import { getPath } from './utils/url' // https://stackoverflow.com/a/65666402 function throwExpression(errorMessage: string): never {
function throwExpression(errorMessage: string): never
throw new Error
(parameter) errorMessage: string
(errorMessage)
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
} type Env = {
(parameter) errorMessage: string
Bindings: {
type Env = { Bindings: { _: string; }; }
_: string
(property) Bindings: { _: string; }
} } describe('GET Request', () => { describe('without middleware', () => { // In other words, this is a test for cases that do not use `compose()` const app = new
(property) _: string
Hono
const app: Hono<Env, BlankSchema, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance.app
type Env = { Bindings: { _: string; }; }
.get('/hello', async () => {
const app: Hono<Env, BlankSchema, "/">
return new Response('hello', {
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Promise<Response>, BlankInput, Env>(path: "/hello", handler: H<Env, "/hello", BlankInput, Promise<Response>>) => Hono<...> (+22 overloads)
status: 200,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.statusText: 'Hono is OK',
(property) ResponseInit.status?: number | undefined
}) }) app
(property) ResponseInit.statusText?: string | undefined
.get('/hello-with-shortcuts',
const app: Hono<Env, BlankSchema, "/">
(c) => {
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/hello-with-shortcuts", "/hello-with-shortcuts", Response, BlankInput, Env>(path: "/hello-with-shortcuts", handler: H<Env, "/hello-with-shortcuts", BlankInput, Response>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<Env, "/hello-with-shortcuts", BlankInput>
.header('X-Custom', 'This is Hono')
(parameter) c: Context<Env, "/hello-with-shortcuts", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.status(201)
(parameter) c: Context<Env, "/hello-with-shortcuts", BlankInput>
return c
(property) Context<Env, "/hello-with-shortcuts", BlankInput>.status: (status: StatusCode) => void
.html('
(parameter) c: Context<Env, "/hello-with-shortcuts", BlankInput>
Hono!!!
')}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.html: HTMLRespond <"<h1>Hono!!!</h1>">(html: "<h1>Hono!!!</h1>", status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.get('/hello-env',
const app: Hono<Env, BlankSchema, "/">
(c) => {
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/hello-env", "/hello-env", JSONRespondReturn<{ _: string; }, StatusCode>, BlankInput, Env>(path: "/hello-env", handler: H<Env, "/hello-env", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<Env, "/hello-env", BlankInput>
.json
(parameter) c: Context<Env, "/hello-env", BlankInput>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ _: string; }, StatusCode>(object: { _: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ _: string; }, StatusCode> (+1 overload)
.env)
(parameter) c: Context<Env, "/hello-env", BlankInput>
(property) Context<Env, "/hello-env", BlankInput>.env: { _: string; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
}) app
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
.get(
const app: Hono<Env, BlankSchema, "/">
'/proxy-object', () => new Proxy(new
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/proxy-object", "/proxy-object", Response, BlankInput, Env>(path: "/proxy-object", handler: H<Env, "/proxy-object", BlankInput, Response>) => Hono<...> (+22 overloads)
var Proxy: ProxyConstructor new <Response>(target: Response, handler: ProxyHandler<Response>) => Response
Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the original object, but which may redefine fundamental Object operations like getting, setting, and defining properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.@param
target
— A target object to wrap with Proxy.@param
Response('proxy'), {handler
— An object whose properties define the behavior of Proxy when an operation is attempted on it.get
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.
(method) ProxyHandler<Response>.get?(target: Response, p: string | symbol, receiver: any): any
A trap for getting a property value.@param
target
— The original object which is being proxied.@param
p
— The name orSymbol
of the property to get.@param
(target,receiver
— The proxy or an object that inherits from the proxy.prop: keyof
(parameter) target: Response
Response) {
(parameter) prop: keyof Response
return target
interface Response
This Fetch API interface represents the response to a request.[prop]
(parameter) target: Response
}, }) ) app
(parameter) prop: keyof Response
.get(
const app: Hono<Env, BlankSchema, "/">
'/async-proxy-object', async () => new Proxy(new
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/async-proxy-object", "/async-proxy-object", Promise<Response>, BlankInput, Env>(path: "/async-proxy-object", handler: H<Env, "/async-proxy-object", BlankInput, Promise<...>>) => Hono<...> (+22 overloads)
var Proxy: ProxyConstructor new <Response>(target: Response, handler: ProxyHandler<Response>) => Response
Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the original object, but which may redefine fundamental Object operations like getting, setting, and defining properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.@param
target
— A target object to wrap with Proxy.@param
Response('proxy'), {handler
— An object whose properties define the behavior of Proxy when an operation is attempted on it.get
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.
(method) ProxyHandler<Response>.get?(target: Response, p: string | symbol, receiver: any): any
A trap for getting a property value.@param
target
— The original object which is being proxied.@param
p
— The name orSymbol
of the property to get.@param
(target,receiver
— The proxy or an object that inherits from the proxy.prop: keyof
(parameter) target: Response
Response) {
(parameter) prop: keyof Response
return target
interface Response
This Fetch API interface represents the response to a request.[prop]
(parameter) target: Response
}, }) ) it('GET http://localhost/hello is ok', async () => { const res = await
(parameter) prop: keyof Response
app
const res: Response
.request('http://localhost/hello')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.statusText).toBe('Hono is OK')
const res: Response
expect(await res
(property) Response.statusText: string
MDN Reference.text()).toBe('hello')
const res: Response
}) it('GET httphello is ng', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('httphello')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res.status).toBe(404)
const res: Response
}) it('GET /hello is ok', async () => { const res = await
(property) Response.status: number
MDN Referenceapp
const res: Response
.request('/hello')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.statusText).toBe('Hono is OK')
const res: Response
expect(await res
(property) Response.statusText: string
MDN Reference.text()).toBe('hello')
const res: Response
}) it('GET hello is ok', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('hello')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.statusText).toBe('Hono is OK')
const res: Response
expect(await res
(property) Response.statusText: string
MDN Reference.text()).toBe('hello')
const res: Response
}) it('GET /hello-with-shortcuts is ok', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/hello-with-shortcuts')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(201)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('X-Custom')).toBe('This is Hono')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('Content-Type')).toMatch(/text\/html/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('
const res: Response
Hono!!!
')}) it('GET / is not found', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(404)
const res: Response
}) it('GET /hello-env is ok', async () => { const res = await
(property) Response.status: number
MDN Referenceapp
const res: Response
.request('/hello-env', undefined, {
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
HELLO: 'world' })expect(res
(property) HELLO: string
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
HELLO: 'world' })
(method) Body.json(): Promise<any>
MDN Reference}) it('GET /proxy-object is ok', async () => { const res = await
(property) HELLO: string
app
const res: Response
.request('/proxy-object')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('proxy')
const res: Response
}) it('GET /async-proxy-object is ok', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/proxy-object')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('proxy')
const res: Response
}) }) describe('with middleware', () => { // when using `compose()` const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono
const app: Hono<Env, BlankSchema, "/">
(alias) new Hono<Env, BlankSchema, "/">(options?: HonoOptions<Env>): Hono<Env, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
<Env>()options
— Optional configuration options for the Hono instance.app
type Env = { Bindings: { _: string; }; }
.use('*', async
const app: Hono<Env, BlankSchema, "/">
(ctx,
(property) Hono<Env, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", Env>(path: "*", handler: MiddlewareHandler<Env, "*", {}>) => Hono<Env, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) ctx: Context<Env, "*", {}>
await next()
(parameter) next: Next
}) app
(parameter) next: () => Promise<void>
.get('/hello', async () => {
const app: Hono<Env, BlankSchema, "/">
return new Response('hello', {
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Promise<Response>, BlankInput, Env>(path: "/hello", handler: H<Env, "/hello", BlankInput, Promise<Response>>) => Hono<...> (+22 overloads)
status: 200,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.statusText: 'Hono is OK',
(property) ResponseInit.status?: number | undefined
}) }) app
(property) ResponseInit.statusText?: string | undefined
.get('/hello-with-shortcuts',
const app: Hono<Env, BlankSchema, "/">
(c) => {
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/hello-with-shortcuts", "/hello-with-shortcuts", Response, BlankInput, Env>(path: "/hello-with-shortcuts", handler: H<Env, "/hello-with-shortcuts", BlankInput, Response>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<Env, "/hello-with-shortcuts", BlankInput>
.header('X-Custom', 'This is Hono')
(parameter) c: Context<Env, "/hello-with-shortcuts", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.status(201)
(parameter) c: Context<Env, "/hello-with-shortcuts", BlankInput>
return c
(property) Context<Env, "/hello-with-shortcuts", BlankInput>.status: (status: StatusCode) => void
.html('
(parameter) c: Context<Env, "/hello-with-shortcuts", BlankInput>
Hono!!!
')}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.html: HTMLRespond <"<h1>Hono!!!</h1>">(html: "<h1>Hono!!!</h1>", status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.get('/hello-env',
const app: Hono<Env, BlankSchema, "/">
(c) => {
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/hello-env", "/hello-env", JSONRespondReturn<{ _: string; }, StatusCode>, BlankInput, Env>(path: "/hello-env", handler: H<Env, "/hello-env", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<Env, "/hello-env", BlankInput>
.json
(parameter) c: Context<Env, "/hello-env", BlankInput>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ _: string; }, StatusCode>(object: { _: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ _: string; }, StatusCode> (+1 overload)
.env)
(parameter) c: Context<Env, "/hello-env", BlankInput>
(property) Context<Env, "/hello-env", BlankInput>.env: { _: string; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
}) app
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
.get(
const app: Hono<Env, BlankSchema, "/">
'/proxy-object', () => new Proxy(new
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/proxy-object", "/proxy-object", Response, BlankInput, Env>(path: "/proxy-object", handler: H<Env, "/proxy-object", BlankInput, Response>) => Hono<...> (+22 overloads)
var Proxy: ProxyConstructor new <Response>(target: Response, handler: ProxyHandler<Response>) => Response
Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the original object, but which may redefine fundamental Object operations like getting, setting, and defining properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.@param
target
— A target object to wrap with Proxy.@param
Response('proxy'), {handler
— An object whose properties define the behavior of Proxy when an operation is attempted on it.get
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.
(method) ProxyHandler<Response>.get?(target: Response, p: string | symbol, receiver: any): any
A trap for getting a property value.@param
target
— The original object which is being proxied.@param
p
— The name orSymbol
of the property to get.@param
(target,receiver
— The proxy or an object that inherits from the proxy.prop: keyof
(parameter) target: Response
Response) {
(parameter) prop: keyof Response
return target
interface Response
This Fetch API interface represents the response to a request.[prop]
(parameter) target: Response
}, }) ) app
(parameter) prop: keyof Response
.get(
const app: Hono<Env, BlankSchema, "/">
'/async-proxy-object', async () => new Proxy(new
(property) Hono<Env, BlankSchema, "/">.get: HandlerInterface <"/async-proxy-object", "/async-proxy-object", Promise<Response>, BlankInput, Env>(path: "/async-proxy-object", handler: H<Env, "/async-proxy-object", BlankInput, Promise<...>>) => Hono<...> (+22 overloads)
var Proxy: ProxyConstructor new <Response>(target: Response, handler: ProxyHandler<Response>) => Response
Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the original object, but which may redefine fundamental Object operations like getting, setting, and defining properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.@param
target
— A target object to wrap with Proxy.@param
Response('proxy'), {handler
— An object whose properties define the behavior of Proxy when an operation is attempted on it.get
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.
(method) ProxyHandler<Response>.get?(target: Response, p: string | symbol, receiver: any): any
A trap for getting a property value.@param
target
— The original object which is being proxied.@param
p
— The name orSymbol
of the property to get.@param
(target,receiver
— The proxy or an object that inherits from the proxy.prop: keyof
(parameter) target: Response
Response) {
(parameter) prop: keyof Response
return target
interface Response
This Fetch API interface represents the response to a request.[prop]
(parameter) target: Response
}, }) ) it('GET http://localhost/hello is ok', async () => { const res = await
(parameter) prop: keyof Response
app
const res: Response
.request('http://localhost/hello')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.statusText).toBe('Hono is OK')
const res: Response
expect(await res
(property) Response.statusText: string
MDN Reference.text()).toBe('hello')
const res: Response
}) it('GET httphello is ng', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('httphello')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res.status).toBe(404)
const res: Response
}) it('GET /hello is ok', async () => { const res = await
(property) Response.status: number
MDN Referenceapp
const res: Response
.request('/hello')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.statusText).toBe('Hono is OK')
const res: Response
expect(await res
(property) Response.statusText: string
MDN Reference.text()).toBe('hello')
const res: Response
}) it('GET hello is ok', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('hello')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.statusText).toBe('Hono is OK')
const res: Response
expect(await res
(property) Response.statusText: string
MDN Reference.text()).toBe('hello')
const res: Response
}) it('GET /hello-with-shortcuts is ok', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/hello-with-shortcuts')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(201)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('X-Custom')).toBe('This is Hono')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('Content-Type')).toMatch(/text\/html/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('
const res: Response
Hono!!!
')}) it('GET / is not found', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(404)
const res: Response
}) it('GET /hello-env is ok', async () => { const res = await
(property) Response.status: number
MDN Referenceapp
const res: Response
.request('/hello-env', undefined, {
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
HELLO: 'world' })expect(res
(property) HELLO: string
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
HELLO: 'world' })
(method) Body.json(): Promise<any>
MDN Reference}) it('GET /proxy-object is ok', async () => { const res = await
(property) HELLO: string
app
const res: Response
.request('/proxy-object')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('proxy')
const res: Response
}) it('GET /async-proxy-object is ok', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/proxy-object')
const app: Hono<Env, BlankSchema, "/">
(property) Hono<Env, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { _: string; } | undefined, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('proxy')
const res: Response
}) }) }) describe('Register handlers without a path', () => { describe('No basePath', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get(
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", BlankInput, Response & TypedResponse<"Hello", StatusCode, "text">, BlankEnv>(handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('Hello')
(parameter) c: Context<BlankEnv, "/", BlankInput>
}) it('GET http://localhost/ is ok', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Hello", StatusCode>(text: "Hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Hello')
const res: Response
}) it('GET http://localhost/anything is ok', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Hello')
const res: Response
}) }) describe('With specifying basePath', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/about">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.basePath('/about')options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/about">(path: "/about"): Hono<BlankEnv, BlankSchema, "/about">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
app
ts const api = new Hono().basePath('/api')
.get(
const app: Hono<BlankEnv, BlankSchema, "/about">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/about">.get: HandlerInterface <"/about", BlankInput, Response & TypedResponse<"About", StatusCode, "text">, BlankEnv>(handler: H<BlankEnv, "/about", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/about", BlankInput>
.text('About')
(parameter) c: Context<BlankEnv, "/about", BlankInput>
}) it('GET http://localhost/about is ok', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"About", StatusCode>(text: "About", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('/about')
const app: Hono<BlankEnv, BlankSchema, "/about">
(property) Hono<BlankEnv, BlankSchema, "/about">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('About')
const res: Response
}) it('GET http://localhost/ is not found', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/')
const app: Hono<BlankEnv, BlankSchema, "/about">
(property) Hono<BlankEnv, BlankSchema, "/about">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
}) }) describe('With chaining', () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..post('/books')
const app: Hono<BlankEnv, BlankSchema, "/">
.get(
(property) Hono<BlankEnv, BlankSchema, "/">.post: HandlerInterface <"/books", BlankInput, any>(path: "/books", ...handlers: H<BlankEnv, "/books", BlankInput, any>[]) => Hono<BlankEnv, { "/books": { $post: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; }, "/"> (+22 overloads)
(c) => {
(property) Hono<BlankEnv, { "/books": { $post: { input: {}; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; }, "/">.get: HandlerInterface <"/books", BlankInput, Response & TypedResponse<"Books", StatusCode, "text">, BlankEnv>(handler: H<BlankEnv, "/books", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/books", BlankInput>
.text('Books')
(parameter) c: Context<BlankEnv, "/books", BlankInput>
}) it('GET http://localhost/books is ok', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Books", StatusCode>(text: "Books", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('/books')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Books')
const res: Response
}) it('GET http://localhost/ is not found', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
}) }) }) describe('router option', () => { it('Should be SmartRouter', () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
expect(appoptions
— Optional configuration options for the Hono instance..router instanceof
const app: Hono<BlankEnv, BlankSchema, "/">
SmartRouter).toBe(true)
(property) Hono<BlankEnv, BlankSchema, "/">.router: Router<[H, RouterRoute]>
}) it('Should be RegExpRouter', () => { const app = new
(alias) class SmartRouter<T> import SmartRouter
Hono({
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
router: newoptions
— Optional configuration options for the Hono instance.
(property) router?: Router<[H, RouterRoute]> | undefined
router
option specifices which router to use.@see — https://hono.dev/docs/api/hono#router-option
@example
RegExpRouter(),
ts const app = new Hono({ router: new RegExpRouter() })
}) expect(app
(alias) new RegExpRouter<[H, RouterRoute]>(): RegExpRouter<[H, RouterRoute]> import RegExpRouter
.router instanceof
const app: Hono<BlankEnv, BlankSchema, "/">
RegExpRouter).toBe(true)
(property) Hono<BlankEnv, BlankSchema, "/">.router: Router<[H, RouterRoute]>
}) }) describe('strict parameter', () => { describe('strict is true with not slash', () => { const app = new
(alias) class RegExpRouter<T> import RegExpRouter
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/hello',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Response & TypedResponse<"/hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
.text('/hello')
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
}) it('/hello/ is not found', async () => { let res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"/hello", StatusCode>(text: "/hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
let res: Response
.request('http://localhost/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
res = await
(property) Response.status: number
MDN Referenceapp
let res: Response
.request('http://localhost/hello/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(404)
let res: Response
}) }) describe('strict is true with slash', () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/hello/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello/", "/hello/", Response & TypedResponse<"/hello/", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello/", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/hello/", BlankInput>
.text('/hello/')
(parameter) c: Context<BlankEnv, "/hello/", BlankInput>
}) it('/hello is not found', async () => { let res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"/hello/", StatusCode>(text: "/hello/", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
let res: Response
.request('http://localhost/hello/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
res = await
(property) Response.status: number
MDN Referenceapp
let res: Response
.request('http://localhost/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(404)
let res: Response
}) }) describe('strict is false', () => { const app = new
(property) Response.status: number
MDN ReferenceHono({
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
strict: false })options
— Optional configuration options for the Hono instance.
(property) strict?: boolean | undefined
strict
option specifies whether to distinguish whether the last path is a directory or not.@see — https://hono.dev/docs/api/hono#strict-mode
@default
app
true
.get('/hello',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Response & TypedResponse<"/hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
.text('/hello')
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
}) it('/hello and /hello/ are treated as the same', async () => { let res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"/hello", StatusCode>(text: "/hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
let res: Response
.request('http://localhost/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
res = await
(property) Response.status: number
MDN Referenceapp
let res: Response
.request('http://localhost/hello/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
}) }) describe('strict is false with `getPath` option', () => { const app = new
(property) Response.status: number
MDN ReferenceHono({
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
strict: false,options
— Optional configuration options for the Hono instance.
(property) strict?: boolean | undefined
strict
option specifies whether to distinguish whether the last path is a directory or not.@see — https://hono.dev/docs/api/hono#strict-mode
@default
getPath:
true
(property) getPath?: GetPath<BlankEnv> | undefined
getPath
can handle the host header value.@see — 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,}) app
(alias) const getPath: (request: Request) => string import getPath
.get('/hello',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Response & TypedResponse<"/hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
.text('/hello')
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
}) it('/hello and /hello/ are treated as the same', async () => { let res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"/hello", StatusCode>(text: "/hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
let res: Response
.request('http://localhost/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
res = await
(property) Response.status: number
MDN Referenceapp
let res: Response
.request('http://localhost/hello/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
}) }) }) describe('Destruct functions in context', () => { it('Should return 200 response - text', async () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/text', ({
const app: Hono<BlankEnv, BlankSchema, "/">
text }) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/text", "/text", Response & TypedResponse<"foo", StatusCode, "text">, BlankInput, BlankEnv>(path: "/text", handler: H<BlankEnv, "/text", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
text('foo'))
(parameter) text: TextRespond
.text()
can render text asContent-Type:text/plain
.const res = await
(parameter) text: TextRespond <"foo", StatusCode>(text: "foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
.text()
can render text asContent-Type:text/plain
.app
const res: Response
.request('http://localhost/text')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
}) it('Should return 200 response - json', async () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/json', ({
const app: Hono<BlankEnv, BlankSchema, "/">
json }) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/json", "/json", JSONRespondReturn<{ foo: string; }, StatusCode>, BlankInput, BlankEnv>(path: "/json", handler: H<BlankEnv, "/json", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
json({
(parameter) json: JSONRespond
.json()
can render JSON asContent-Type:application/json
.foo: 'bar' }))
(parameter) json: JSONRespond <{ foo: string; }, StatusCode>(object: { foo: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ foo: string; }, StatusCode> (+1 overload)
.json()
can render JSON asContent-Type:application/json
.const res = await
(property) foo: string
app
const res: Response
.request('http://localhost/json')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
}) }) describe('Routing', () => { it('Return it self', async () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const app2 =options
— Optional configuration options for the Hono instance.app
const app2: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: string; status: StatusCode; }; }; }, "/">
.get('/', () => new
const app: Hono<BlankEnv, BlankSchema, "/">
Response('get /'))
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response>) => Hono<BlankEnv, { ...; }, "/"> (+22 overloads)
expect(app2).not.toBeUndefined()
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.app2
const app2: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: string; status: StatusCode; }; }; }, "/">
.delete('/', () => new
const app2: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: string; status: StatusCode; }; }; }, "/">
Response('delete /'))
(property) Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: string; status: StatusCode; }; }; }, "/">.delete: HandlerInterface <"/", "/", Response, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response>) => Hono<BlankEnv, { ...; } & { ...; }, "/"> (+22 overloads)
let res = await
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.app2
let res: Response
.request('http://localhost/', {
const app2: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: string; status: StatusCode; }; }; }, "/">
(property) Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: string; status: StatusCode; }; }; }, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res).not.toBeNull()
(property) RequestInit.method?: string | undefined
A string to set request's method.expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp2
let res: Response
.request('http://localhost/', {
const app2: Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: string; status: StatusCode; }; }; }, "/">
(property) Hono<BlankEnv, { "/": { $get: { input: {}; output: {}; outputFormat: string; status: StatusCode; }; }; }, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'DELETE' })expect(res).not.toBeNull()
(property) RequestInit.method?: string | undefined
A string to set request's method.expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('delete /')
let res: Response
}) it('Nested route', async () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const book =options
— Optional configuration options for the Hono instance.app
const book: Hono<BlankEnv, BlankSchema, "/book">
.basePath('/book')
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/book">(path: "/book"): Hono<BlankEnv, BlankSchema, "/book">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
book
ts const api = new Hono().basePath('/api')
.get('/',
const book: Hono<BlankEnv, BlankSchema, "/book">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/book">.get: HandlerInterface <"/", "/book", Response & TypedResponse<"get /book", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/book", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/book", BlankInput>
.text('get /book'))
(parameter) c: Context<BlankEnv, "/book", BlankInput>
book
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"get /book", StatusCode>(text: "get /book", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/:id',
const book: Hono<BlankEnv, BlankSchema, "/book">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/book">.get: HandlerInterface <"/:id", "/book/:id", Response & TypedResponse<string, StatusCode, "text">, BlankInput, BlankEnv>(path: "/:id", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/book/:id", BlankInput>
.text('get /book/' +
(parameter) c: Context<BlankEnv, "/book/:id", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/book/:id", BlankInput>
.param('id'))
(property) Context<BlankEnv, "/book/:id", BlankInput>.req: HonoRequest<"/book/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/book/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) book
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.post('/',
const book: Hono<BlankEnv, BlankSchema, "/book">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/book">.post: HandlerInterface <"/", "/book", Response & TypedResponse<"post /book", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/book", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/book", BlankInput>
.text('post /book'))
(parameter) c: Context<BlankEnv, "/book", BlankInput>
const user =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"post /book", StatusCode>(text: "post /book", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const user: Hono<BlankEnv, BlankSchema, "/user">
.basePath('/user')
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/user">(path: "/user"): Hono<BlankEnv, BlankSchema, "/user">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
user
ts const api = new Hono().basePath('/api')
.get('/login',
const user: Hono<BlankEnv, BlankSchema, "/user">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/user">.get: HandlerInterface <"/login", "/user/login", Response & TypedResponse<"get /user/login", StatusCode, "text">, BlankInput, BlankEnv>(path: "/login", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/user/login", BlankInput>
.text('get /user/login'))
(parameter) c: Context<BlankEnv, "/user/login", BlankInput>
user
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"get /user/login", StatusCode>(text: "get /user/login", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.post('/register',
const user: Hono<BlankEnv, BlankSchema, "/user">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/user">.post: HandlerInterface <"/register", "/user/register", Response & TypedResponse<"post /user/register", StatusCode, "text">, BlankInput, BlankEnv>(path: "/register", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/user/register", BlankInput>
.text('post /user/register'))
(parameter) c: Context<BlankEnv, "/user/register", BlankInput>
const appForEachUser =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"post /user/register", StatusCode>(text: "post /user/register", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
user
const appForEachUser: Hono<BlankEnv, BlankSchema, "/user/:id">
.basePath(':id')
const user: Hono<BlankEnv, BlankSchema, "/user">
(method) Hono<BlankEnv, BlankSchema, "/user">.basePath<":id">(path: ":id"): Hono<BlankEnv, BlankSchema, "/user/:id">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
appForEachUser
ts const api = new Hono().basePath('/api')
.get('/profile',
const appForEachUser: Hono<BlankEnv, BlankSchema, "/user/:id">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/user/:id">.get: HandlerInterface <"/profile", "/user/:id/profile", Response & TypedResponse<string, StatusCode, "text">, BlankInput, BlankEnv>(path: "/profile", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/user/:id/profile", BlankInput>
.text('get /user/' +
(parameter) c: Context<BlankEnv, "/user/:id/profile", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/user/:id/profile", BlankInput>
.param('id') + '/profile'))
(property) Context<BlankEnv, "/user/:id/profile", BlankInput>.req: HonoRequest<"/user/:id/profile", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/user/:id/profile", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
app
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.get('/add-path-after-route-call',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/add-path-after-route-call", "/add-path-after-route-call", Response & TypedResponse<"get /add-path-after-route-call", StatusCode, "text">, BlankInput, BlankEnv>(path: "/add-path-after-route-call", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/add-path-after-route-call", BlankInput>
.text('get /add-path-after-route-call'))
(parameter) c: Context<BlankEnv, "/add-path-after-route-call", BlankInput>
let res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"get /add-path-after-route-call", StatusCode>(text: "get /add-path-after-route-call", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
let res: Response
.request('http://localhost/book', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /book')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/book/123', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /book/123')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/book', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'POST' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('post /book')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/book/', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(404)
let res: Response
res = await
(property) Response.status: number
MDN Referenceapp
let res: Response
.request('http://localhost/user/login', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /user/login')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/user/register', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'POST' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('post /user/register')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/user/123/profile', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /user/123/profile')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/add-path-after-route-call', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /add-path-after-route-call')
let res: Response
}) it('Nested route - subApp with basePath', async () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const book = newoptions
— Optional configuration options for the Hono instance.Hono()
const book: Hono<BlankEnv, BlankSchema, "/book">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.basePath('/book')options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/book">(path: "/book"): Hono<BlankEnv, BlankSchema, "/book">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
book
ts const api = new Hono().basePath('/api')
.get('/',
const book: Hono<BlankEnv, BlankSchema, "/book">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/book">.get: HandlerInterface <"/", "/book", Response & TypedResponse<"get /book", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/book", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/book", BlankInput>
.text('get /book'))
(parameter) c: Context<BlankEnv, "/book", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"get /book", StatusCode>(text: "get /book", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.route('/api',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", BlankEnv, BlankSchema, "/book">(path: "/api", app: Hono<BlankEnv, BlankSchema, "/book">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
book)const res = await
const book: Hono<BlankEnv, BlankSchema, "/book">
app
const res: Response
.request('http://localhost/api/book', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /book')
const res: Response
}) it('Multiple route', async () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const book = newoptions
— Optional configuration options for the Hono instance.Hono()
const book: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
bookoptions
— Optional configuration options for the Hono instance..get('/hello',
const book: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Response & TypedResponse<"get /book/hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
.text('get /book/hello'))
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
const user = new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"get /book/hello", StatusCode>(text: "get /book/hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
Hono()
const user: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
useroptions
— Optional configuration options for the Hono instance..get('/hello',
const user: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Response & TypedResponse<"get /user/hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
.text('get /user/hello'))
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"get /user/hello", StatusCode>(text: "get /user/hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.route('/book',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/book", BlankEnv, BlankSchema, "/">(path: "/book", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
book).route('/user',
const book: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, {}, "/">.route<"/user", BlankEnv, BlankSchema, "/">(path: "/user", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {} & {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
user)let res = await
const user: Hono<BlankEnv, BlankSchema, "/">
app
let res: Response
.request('http://localhost/book/hello', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /book/hello')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/user/hello', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('get /user/hello')
let res: Response
}) describe('Nested route with middleware', () => { const api = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const api: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const api2 =options
— Optional configuration options for the Hono instance.api
const api2: Hono<{}, { "*": {}; }, "/">
.use('*', async
const api: Hono<BlankEnv, BlankSchema, "/">
(_c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => await
(parameter) _c: Context<BlankEnv, "*", {}>
next())
(parameter) next: Next
it('Should mount routes with no type errors', () => { const app = new
(parameter) next: () => Promise<void>
Hono()
const app: Hono<BlankEnv, { "/api/*": {}; }, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.route('/api',options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", {}, { "*": {}; }, "/">(path: "/api", app: Hono<{}, { "*": {}; }, "/">): Hono<BlankEnv, { "/api/*": {}; }, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api2)}) }) describe('Grouped route', () => { let one:
const api2: Hono<{}, { "*": {}; }, "/">
Hono,
let one: Hono<BlankEnv, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
two:BasePath
— The base path type.Hono,
let two: Hono<BlankEnv, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
three:BasePath
— The base path type.Hono
let three: Hono<BlankEnv, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
beforeEach(() => { one = newBasePath
— The base path type.Hono()
let one: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
two = newoptions
— Optional configuration options for the Hono instance.Hono()
let two: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
three = newoptions
— Optional configuration options for the Hono instance.Hono()
let three: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
}) it('only works with correct order', async () => { threeoptions
— Optional configuration options for the Hono instance..get('/hi',
let three: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hi", "/hi", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hi", handler: H<BlankEnv, "/hi", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
.text('hi'))
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
two
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
.route('/three',
let two: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/three", BlankEnv, BlankSchema, "/">(path: "/three", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
three)one
let three: Hono<BlankEnv, BlankSchema, "/">
.route('/two',
let one: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/two", BlankEnv, BlankSchema, "/">(path: "/two", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
two)const { status } = await
let two: Hono<BlankEnv, BlankSchema, "/">
one
const status: number
MDN Reference.request('http://localhost/two/three/hi', {
let one: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(status).toBe(200)
(property) RequestInit.method?: string | undefined
A string to set request's method.}) it('fails with incorrect order 1', async () => { three
const status: number
MDN Reference.get('/hi',
let three: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hi", "/hi", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hi", handler: H<BlankEnv, "/hi", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
.text('hi'))
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
one
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
.route('/two',
let one: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/two", BlankEnv, BlankSchema, "/">(path: "/two", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
two)two
let two: Hono<BlankEnv, BlankSchema, "/">
.route('/three',
let two: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/three", BlankEnv, BlankSchema, "/">(path: "/three", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
three)const { status } = await
let three: Hono<BlankEnv, BlankSchema, "/">
one
const status: number
MDN Reference.request('http://localhost/two/three/hi', {
let one: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(status).toBe(404)
(property) RequestInit.method?: string | undefined
A string to set request's method.}) it('fails with incorrect order 2', async () => { two
const status: number
MDN Reference.route('/three',
let two: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/three", BlankEnv, BlankSchema, "/">(path: "/three", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
three)three
let three: Hono<BlankEnv, BlankSchema, "/">
.get('/hi',
let three: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hi", "/hi", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hi", handler: H<BlankEnv, "/hi", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
.text('hi'))
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
one
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
.route('/two',
let one: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/two", BlankEnv, BlankSchema, "/">(path: "/two", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
two)const { status } = await
let two: Hono<BlankEnv, BlankSchema, "/">
one
const status: number
MDN Reference.request('http://localhost/two/three/hi', {
let one: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(status).toBe(404)
(property) RequestInit.method?: string | undefined
A string to set request's method.}) it('fails with incorrect order 3', async () => { two
const status: number
MDN Reference.route('/three',
let two: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/three", BlankEnv, BlankSchema, "/">(path: "/three", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
three)one
let three: Hono<BlankEnv, BlankSchema, "/">
.route('/two',
let one: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/two", BlankEnv, BlankSchema, "/">(path: "/two", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
two)three
let two: Hono<BlankEnv, BlankSchema, "/">
.get('/hi',
let three: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hi", "/hi", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hi", handler: H<BlankEnv, "/hi", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
.text('hi'))
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
const { status } = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
one
const status: number
MDN Reference.request('http://localhost/two/three/hi', {
let one: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(status).toBe(404)
(property) RequestInit.method?: string | undefined
A string to set request's method.}) it('fails with incorrect order 4', async () => { one
const status: number
MDN Reference.route('/two',
let one: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/two", BlankEnv, BlankSchema, "/">(path: "/two", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
two)three
let two: Hono<BlankEnv, BlankSchema, "/">
.get('/hi',
let three: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hi", "/hi", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hi", handler: H<BlankEnv, "/hi", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
.text('hi'))
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
two
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
.route('/three',
let two: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/three", BlankEnv, BlankSchema, "/">(path: "/three", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
three)const { status } = await
let three: Hono<BlankEnv, BlankSchema, "/">
one
const status: number
MDN Reference.request('http://localhost/two/three/hi', {
let one: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(status).toBe(404)
(property) RequestInit.method?: string | undefined
A string to set request's method.}) it('fails with incorrect order 5', async () => { one
const status: number
MDN Reference.route('/two',
let one: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/two", BlankEnv, BlankSchema, "/">(path: "/two", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
two)two
let two: Hono<BlankEnv, BlankSchema, "/">
.route('/three',
let two: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/three", BlankEnv, BlankSchema, "/">(path: "/three", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
three)three
let three: Hono<BlankEnv, BlankSchema, "/">
.get('/hi',
let three: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hi", "/hi", Response & TypedResponse<"hi", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hi", handler: H<BlankEnv, "/hi", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
.text('hi'))
(parameter) c: Context<BlankEnv, "/hi", BlankInput>
const { status } = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hi", StatusCode>(text: "hi", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"hi", StatusCode, "text"> (+1 overload)
one
const status: number
MDN Reference.request('http://localhost/two/three/hi', {
let one: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(status).toBe(404)
(property) RequestInit.method?: string | undefined
A string to set request's method.}) }) it('routing with hostname', async () => { const app = new
const status: number
MDN ReferenceHono({
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
getPath:options
— Optional configuration options for the Hono instance.
(property) getPath?: GetPath<BlankEnv> | undefined
getPath
can handle the host header value.@see — 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' }, // }) ```
(req) =>req
(parameter) req: Request
.url
(parameter) req: Request
.replace(/^https?:\/(.+?)$/, '$1'),
(property) Request.url: string
Returns the URL of request as a string.
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
}) const sub = newreplaceValue
— The replacement text.Hono()
const sub: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
suboptions
— Optional configuration options for the Hono instance..get('/',
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"hello sub", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('hello sub'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
sub
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello sub", StatusCode>(text: "hello sub", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/foo',
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo", "/foo", Response & TypedResponse<"hello sub foo", StatusCode, "text">, BlankInput, BlankEnv>(path: "/foo", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.text('hello sub foo'))
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello sub foo", StatusCode>(text: "hello sub foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/www1.example.com/hello', () => new
const app: Hono<BlankEnv, BlankSchema, "/">
Response('hello www1'))
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/www1.example.com/hello", "/www1.example.com/hello", Response, BlankInput, BlankEnv>(path: "/www1.example.com/hello", handler: H<BlankEnv, "/www1.example.com/hello", BlankInput, Response>) => Hono<...> (+22 overloads)
app
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..get('/www2.example.com/hello', () => new
const app: Hono<BlankEnv, BlankSchema, "/">
Response('hello www2'))
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/www2.example.com/hello", "/www2.example.com/hello", Response, BlankInput, BlankEnv>(path: "/www2.example.com/hello", handler: H<BlankEnv, "/www2.example.com/hello", BlankInput, Response>) => Hono<...> (+22 overloads)
app
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..get('/www1.example.com/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/www1.example.com/", "/www1.example.com/", Response & TypedResponse<"hello www1 root", StatusCode, "text">, BlankInput, BlankEnv>(path: "/www1.example.com/", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/www1.example.com/", BlankInput>
.text('hello www1 root'))
(parameter) c: Context<BlankEnv, "/www1.example.com/", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello www1 root", StatusCode>(text: "hello www1 root", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.route('/www1.example.com/sub',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/www1.example.com/sub", BlankEnv, BlankSchema, "/">(path: "/www1.example.com/sub", app: Hono<BlankEnv, BlankSchema, "/">): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
sub)let res = await
const sub: Hono<BlankEnv, BlankSchema, "/">
app
let res: Response
.request('http://www1.example.com/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello www1')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://www2.example.com/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello www2')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://www1.example.com/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello www1 root')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://www1.example.com/sub')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello sub')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://www1.example.com/sub/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello sub foo')
let res: Response
}) it('routing with request header', async () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono({
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
getPath:options
— Optional configuration options for the Hono instance.
(property) getPath?: GetPath<BlankEnv> | undefined
getPath
can handle the host header value.@see — 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' }, // }) ```
(req) =>'/' + req
(parameter) req: Request
.headers
(parameter) req: Request
.get('host') +
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.req
(method) Headers.get(name: string): string | null
MDN Reference.url
(parameter) req: Request
.replace(/^https?:\/\/[^/]+(\/[^?]*)/, '$1'),
(property) Request.url: string
Returns the URL of request as a string.
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
}) const sub = newreplaceValue
— The replacement text.Hono()
const sub: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
suboptions
— Optional configuration options for the Hono instance..get('/',
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"hello sub", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('hello sub'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
sub
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello sub", StatusCode>(text: "hello sub", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/foo',
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo", "/foo", Response & TypedResponse<"hello sub foo", StatusCode, "text">, BlankInput, BlankEnv>(path: "/foo", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.text('hello sub foo'))
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello sub foo", StatusCode>(text: "hello sub foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/www1.example.com/hello', () => new
const app: Hono<BlankEnv, BlankSchema, "/">
Response('hello www1'))
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/www1.example.com/hello", "/www1.example.com/hello", Response, BlankInput, BlankEnv>(path: "/www1.example.com/hello", handler: H<BlankEnv, "/www1.example.com/hello", BlankInput, Response>) => Hono<...> (+22 overloads)
app
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..get('/www2.example.com/hello', () => new
const app: Hono<BlankEnv, BlankSchema, "/">
Response('hello www2'))
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/www2.example.com/hello", "/www2.example.com/hello", Response, BlankInput, BlankEnv>(path: "/www2.example.com/hello", handler: H<BlankEnv, "/www2.example.com/hello", BlankInput, Response>) => Hono<...> (+22 overloads)
app
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..get('/www1.example.com/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/www1.example.com/", "/www1.example.com/", Response & TypedResponse<"hello www1 root", StatusCode, "text">, BlankInput, BlankEnv>(path: "/www1.example.com/", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/www1.example.com/", BlankInput>
.text('hello www1 root'))
(parameter) c: Context<BlankEnv, "/www1.example.com/", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello www1 root", StatusCode>(text: "hello www1 root", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.route('/www1.example.com/sub',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/www1.example.com/sub", BlankEnv, BlankSchema, "/">(path: "/www1.example.com/sub", app: Hono<BlankEnv, BlankSchema, "/">): Hono<...>
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
sub)let res = await
const sub: Hono<BlankEnv, BlankSchema, "/">
app
let res: Response
.request('http://www1.example.com/hello', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {host: 'www1.example.com',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) expect(res).not.toBeNull()
(property) host: string
expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello www1')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://www2.example.com/hello', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {host: 'www2.example.com',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) expect(res).not.toBeNull()
(property) host: string
expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello www2')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://www1.example.com/', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {host: 'www1.example.com',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) expect(res).not.toBeNull()
(property) host: string
expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello www1 root')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://www1.example.com/sub', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {host: 'www1.example.com',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) expect(res).not.toBeNull()
(property) host: string
expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello sub')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://www1.example.com/sub/foo', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
headers: {host: 'www1.example.com',
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}, }) expect(res).not.toBeNull()
(property) host: string
expect(res
let res: Response
.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello sub foo')
let res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.status).toBe(200)
let res: Response
}) describe('routing with the bindings value', () => { const app = new
(property) Response.status: number
MDN ReferenceHono<{
const app: Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">
(alias) new Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">(options?: HonoOptions<{ Bindings: { host: string; }; }>): Hono<{ Bindings: { host: string; }; }, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
Bindings: {options
— Optional configuration options for the Hono instance.host: string } }>({
(property) Bindings: { host: string; }
getPath:
(property) host: string
(property) getPath?: GetPath<{ Bindings: { host: string; }; }> | undefined
getPath
can handle the host header value.@see — 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' }, // }) ```
(req,options) => {
(parameter) req: Request
const url = new
(parameter) options: { env?: { host: string; } | undefined; } | undefined
URL
const url: URL
(req
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs..url)
(parameter) req: Request
const host =
(property) Request.url: string
Returns the URL of request as a string.options?
const host: string | undefined
.env?
(parameter) options: { env?: { host: string; } | undefined; } | undefined
.host
(property) env?: { host: string; } | undefined
const prefix =
(property) host: string | undefined
url
const prefix: "" | "/FOO"
.host ===
const url: URL
host ? '/FOO' : ''
(property) URL.host: string
MDN Referencereturn url
const host: string | undefined
.pathname === '/' ?
const url: URL
prefix : `$
(property) URL.pathname: string
MDN Reference{prefix}$
const prefix: "" | "/FOO"
{url
const prefix: "" | "/FOO"
.pathname}`
const url: URL
}, }) app
(property) URL.pathname: string
MDN Reference.get('/about',
const app: Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">
(c) =>
(property) Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/about", "/about", Response & TypedResponse<"About root", StatusCode, "text">, BlankInput, { Bindings: { host: string; }; }>(path: "/about", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<{ Bindings: { host: string; }; }, "/about", BlankInput>
.text('About root'))
(parameter) c: Context<{ Bindings: { host: string; }; }, "/about", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"About root", StatusCode>(text: "About root", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/FOO/about',
const app: Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">
(c) =>
(property) Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/FOO/about", "/FOO/about", Response & TypedResponse<"About FOO", StatusCode, "text">, BlankInput, { Bindings: { host: string; }; }>(path: "/FOO/about", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<{ Bindings: { host: string; }; }, "/FOO/about", BlankInput>
.text('About FOO'))
(parameter) c: Context<{ Bindings: { host: string; }; }, "/FOO/about", BlankInput>
it('Should return 200 without specifying a hostname', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"About FOO", StatusCode>(text: "About FOO", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('/about')
const app: Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { host: string; } | undefined, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('About root')
const res: Response
}) it('Should return 200 with specifying the hostname in env', async () => { const req = new
(method) Body.text(): Promise<string>
MDN ReferenceRequest('http://foo.localhost/about')
const req: Request
const res = await
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.app
const res: Response
.fetch
const app: Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { host: string; }; }, BlankSchema, "/">.fetch: (request: Request, Env?: {} | { host: string; } | undefined, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
(req, {host: 'foo.localhost' })
const req: Request
expect(res
(property) host: string
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('About FOO')
const res: Response
}) }) describe('Chained route', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/chained/:abc',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/chained/:abc", "/chained/:abc", Response & TypedResponse<`GET for ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/chained/:abc", handler: H<...>) => Hono<...> (+22 overloads)
const abc =
(parameter) c: Context<BlankEnv, "/chained/:abc", BlankInput>
c
const abc: string
.req
(parameter) c: Context<BlankEnv, "/chained/:abc", BlankInput>
.param('abc')
(property) Context<BlankEnv, "/chained/:abc", BlankInput>.req: HonoRequest<"/chained/:abc", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/chained/:abc", unknown>.param<"abc">(key: "abc"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`GET for $
(parameter) c: Context<BlankEnv, "/chained/:abc", BlankInput>
{abc}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`GET for ${string}`, StatusCode>(text: `GET for ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) .post(
const abc: string
(c) => {
(property) Hono<BlankEnv, { "/chained/:abc": { $get: { input: { param: { abc: string; }; }; output: `GET for ${string}`; outputFormat: "text"; status: StatusCode; }; }; }, "/">.post: HandlerInterface <"/chained/:abc", BlankInput, Response & TypedResponse<`POST for ${string}`, StatusCode, "text">, BlankEnv>(handler: H<BlankEnv, "/chained/:abc", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
const abc =
(parameter) c: Context<BlankEnv, "/chained/:abc", BlankInput>
c
const abc: string
.req
(parameter) c: Context<BlankEnv, "/chained/:abc", BlankInput>
.param('abc')
(property) Context<BlankEnv, "/chained/:abc", BlankInput>.req: HonoRequest<"/chained/:abc", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/chained/:abc", unknown>.param<"abc">(key: "abc"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`POST for $
(parameter) c: Context<BlankEnv, "/chained/:abc", BlankInput>
{abc}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`POST for ${string}`, StatusCode>(text: `POST for ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) it('Should return 200 response from GET request', async () => { const res = await
const abc: string
app
const res: Response
.request('http://localhost/chained/abc', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'GET' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('GET for abc')
const res: Response
}) it('Should return 200 response from POST request', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/chained/abc', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'POST' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('POST for abc')
const res: Response
}) it('Should return 404 response from PUT request', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/chained/abc', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'PUT' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(404)
const res: Response
}) }) describe('Encoded path', () => { let app:
(property) Response.status: number
MDN ReferenceHono
let app: Hono<BlankEnv, BlankSchema, "/">
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
beforeEach(() => { app = newBasePath
— The base path type.Hono()
let app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
}) it('should decode path parameter', async () => { appoptions
— Optional configuration options for the Hono instance..get('/users/:id',
let app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/users/:id", "/users/:id", Response & TypedResponse<`id is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/users/:id", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
.text(`id is $
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id is ${string}`, StatusCode>(text: `id is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
.param('id')}`))
(property) Context<BlankEnv, "/users/:id", BlankInput>.req: HonoRequest<"/users/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/users/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
const res = await
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
app
const res: Response
.request('http://localhost/users/%C3%A7awa%20y%C3%AE%3F')
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id is çawa yî?')
const res: Response
}) it('should decode "/"', async () => { app
(method) Body.text(): Promise<string>
MDN Reference.get('/users/:id',
let app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/users/:id", "/users/:id", Response & TypedResponse<`id is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/users/:id", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
.text(`id is $
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id is ${string}`, StatusCode>(text: `id is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
.param('id')}`))
(property) Context<BlankEnv, "/users/:id", BlankInput>.req: HonoRequest<"/users/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/users/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
const res = await
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
app
const res: Response
.request('http://localhost/users/hono%2Fposts') // %2F is '/'
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id is hono/posts')
const res: Response
}) it('should decode alphabets', async () => { app
(method) Body.text(): Promise<string>
MDN Reference.get('/users/static',
let app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/users/static", "/users/static", Response & TypedResponse<"static", StatusCode, "text">, BlankInput, BlankEnv>(path: "/users/static", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/users/static", BlankInput>
.text('static'))
(parameter) c: Context<BlankEnv, "/users/static", BlankInput>
const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"static", StatusCode>(text: "static", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/users/%73tatic') // %73 is 's'
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('static')
const res: Response
}) it('should decode alphabets with invalid UTF-8 sequence', async () => { app
(method) Body.text(): Promise<string>
MDN Reference.get('/static/:path',
let app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/static/:path", "/static/:path", (Response & TypedResponse<`by c.req.param: ${string}`, StatusCode, "text">) | (Response & TypedResponse<`by c.req.url: ${string}`, StatusCode, "text">), BlankInput, BlankEnv>(path: "/static/:path", handler: H<...>) => Hono<...> (+22 overloads)
try { return c
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
.text(`by c.req.param: $
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`by c.req.param: ${string}`, StatusCode>(text: `by c.req.param: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
.param('path')}`) // this should throw an error
(property) Context<BlankEnv, "/static/:path", BlankInput>.req: HonoRequest<"/static/:path", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/static/:path", unknown>.param<"path">(key: "path"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
} catch (e) {
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
return c
(local var) e: unknown
.text(`by c.req.url: $
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`by c.req.url: ${string}`, StatusCode>(text: `by c.req.url: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
.url
(property) Context<BlankEnv, "/static/:path", BlankInput>.req: HonoRequest<"/static/:path", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.url: string
.url()
can get the request url strings.@see — https://hono.dev/docs/api/request#url
@example
.replace(/.*\//, '')}`)
ts app.get('/about/me', (c) => { const url = c.req.url // `http://localhost:8787/about/me` ... })
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
} }) const res = awaitreplaceValue
— The replacement text.app
const res: Response
.request('http://localhost/%73tatic/%A4%A2') // %73 is 's', %A4%A2 is invalid UTF-8 sequence
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('by c.req.url: %A4%A2')
const res: Response
}) it('should decode alphabets with invalid percent encoding', async () => { app
(method) Body.text(): Promise<string>
MDN Reference.get('/static/:path',
let app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/static/:path", "/static/:path", (Response & TypedResponse<`by c.req.param: ${string}`, StatusCode, "text">) | (Response & TypedResponse<`by c.req.url: ${string}`, StatusCode, "text">), BlankInput, BlankEnv>(path: "/static/:path", handler: H<...>) => Hono<...> (+22 overloads)
try { return c
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
.text(`by c.req.param: $
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`by c.req.param: ${string}`, StatusCode>(text: `by c.req.param: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
.param('path')}`) // this should throw an error
(property) Context<BlankEnv, "/static/:path", BlankInput>.req: HonoRequest<"/static/:path", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/static/:path", unknown>.param<"path">(key: "path"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
} catch (e) {
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
return c
(local var) e: unknown
.text(`by c.req.url: $
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`by c.req.url: ${string}`, StatusCode>(text: `by c.req.url: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
.url
(property) Context<BlankEnv, "/static/:path", BlankInput>.req: HonoRequest<"/static/:path", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.url: string
.url()
can get the request url strings.@see — https://hono.dev/docs/api/request#url
@example
.replace(/.*\//, '')}`)
ts app.get('/about/me', (c) => { const url = c.req.url // `http://localhost:8787/about/me` ... })
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
} }) const res = awaitreplaceValue
— The replacement text.app
const res: Response
.request('http://localhost/%73tatic/%a') // %73 is 's', %a is invalid percent encoding
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('by c.req.url: %a')
const res: Response
}) it('should be able to catch URIError', async () => { app
(method) Body.text(): Promise<string>
MDN Reference.onError(
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
if (err instanceof
(parameter) c: Context<BlankEnv, any, {}>
URIError) {
(parameter) err: Error | HTTPResponseError
return c
var URIError: URIErrorConstructor
.text
(parameter) c: Context<BlankEnv, any, {}>
(err
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, 400>(text: string, status?: 400 | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, 400, "text"> (+1 overload)
.message, 400)
(parameter) err: URIError
} throw err
(property) Error.message: string
}) app
(parameter) err: Error | HTTPResponseError
.get('/static/:path',
let app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/static/:path", "/static/:path", Response & TypedResponse<`by c.req.param: ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/static/:path", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
.text(`by c.req.param: $
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`by c.req.param: ${string}`, StatusCode>(text: `by c.req.param: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/static/:path", BlankInput>
.param('path')}`) // this should throw an error
(property) Context<BlankEnv, "/static/:path", BlankInput>.req: HonoRequest<"/static/:path", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/static/:path", unknown>.param<"path">(key: "path"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) const res = await
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
app
const res: Response
.request('http://localhost/%73tatic/%a') // %73 is 's', %a is invalid percent encoding
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(400)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('URI malformed')
const res: Response
}) it('should not double decode', async () => { app
(method) Body.text(): Promise<string>
MDN Reference.get('/users/:id',
let app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/users/:id", "/users/:id", Response & TypedResponse<`posts of ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/users/:id", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
.text(`posts of $
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`posts of ${string}`, StatusCode>(text: `posts of ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/users/:id", BlankInput>
.param('id')}`))
(property) Context<BlankEnv, "/users/:id", BlankInput>.req: HonoRequest<"/users/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/users/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
const res = await
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
app
const res: Response
.request('http://localhost/users/%2525') // %25 is '%'
let app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('posts of %25')
const res: Response
}) }) }) describe('param and query', () => { const apps:
(method) Body.text(): Promise<string>
MDN ReferenceRecord
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
Hono> = {}
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
apps['get by name'] = (() => {BasePath
— The base path type.const app = new
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/entry/:id',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/entry/:id", "/entry/:id", Response & TypedResponse<`id is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/entry/:id", handler: H<...>) => Hono<...> (+22 overloads)
const id =
(parameter) c: Context<BlankEnv, "/entry/:id", BlankInput>
c
const id: string
.req
(parameter) c: Context<BlankEnv, "/entry/:id", BlankInput>
.param('id')
(property) Context<BlankEnv, "/entry/:id", BlankInput>.req: HonoRequest<"/entry/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/entry/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`id is $
(parameter) c: Context<BlankEnv, "/entry/:id", BlankInput>
{id}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id is ${string}`, StatusCode>(text: `id is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) app
const id: string
.get('/date/:date{[0-9]+}',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/date/:date{[0-9]+}", "/date/:date{[0-9]+}", Response & TypedResponse<`date is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/date/:date{[0-9]+}", handler: H<...>) => Hono<...> (+22 overloads)
const date =
(parameter) c: Context<BlankEnv, "/date/:date{[0-9]+}", BlankInput>
c
const date: string
.req
(parameter) c: Context<BlankEnv, "/date/:date{[0-9]+}", BlankInput>
.param('date')
(property) Context<BlankEnv, "/date/:date{[0-9]+}", BlankInput>.req: HonoRequest<"/date/:date{[0-9]+}", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/date/:date{[0-9]+}", unknown>.param<"date">(key: "date"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`date is $
(parameter) c: Context<BlankEnv, "/date/:date{[0-9]+}", BlankInput>
{date}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`date is ${string}`, StatusCode>(text: `date is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) app
const date: string
.get('/search',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", Response & TypedResponse<`name is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/search", handler: H<...>) => Hono<...> (+22 overloads)
const name =
(parameter) c: Context<BlankEnv, "/search", BlankInput>
c
const name: string | undefined
.req
(parameter) c: Context<BlankEnv, "/search", BlankInput>
.query('name')
(property) Context<BlankEnv, "/search", BlankInput>.req: HonoRequest<"/search", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/search", unknown>.query(key: string): string | undefined (+1 overload)
.query()
can get querystring parameters.@see — 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() }) ```
return c.text(`name is $
(parameter) c: Context<BlankEnv, "/search", BlankInput>
{name}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`name is ${string}`, StatusCode>(text: `name is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) app
const name: string | undefined
.get('/multiple-values',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/multiple-values", "/multiple-values", Response & TypedResponse<`q is ${string} and ${string}, limit is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/multiple-values", handler: H<...>) => Hono<...> (+22 overloads)
const queries =
(parameter) c: Context<BlankEnv, "/multiple-values", BlankInput>
c
const queries: string[]
.req
(parameter) c: Context<BlankEnv, "/multiple-values", BlankInput>
.queries('q') ??
(property) Context<BlankEnv, "/multiple-values", BlankInput>.req: HonoRequest<"/multiple-values", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/multiple-values", unknown>.queries(key: string): string[] | undefined (+1 overload)
.queries()
can get multiple querystring parameter values, e.g. /search?tags=A&tags=B@see — https://hono.dev/docs/api/request#queries
@example
throwExpression('missing query values')
ts app.get('/search', (c) => { // tags will be string[] const tags = c.req.queries('tags') })
const limit =
function throwExpression(errorMessage: string): never
c
const limit: string[]
.req
(parameter) c: Context<BlankEnv, "/multiple-values", BlankInput>
.queries('limit') ??
(property) Context<BlankEnv, "/multiple-values", BlankInput>.req: HonoRequest<"/multiple-values", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/multiple-values", unknown>.queries(key: string): string[] | undefined (+1 overload)
.queries()
can get multiple querystring parameter values, e.g. /search?tags=A&tags=B@see — https://hono.dev/docs/api/request#queries
@example
throwExpression('missing query values')
ts app.get('/search', (c) => { // tags will be string[] const tags = c.req.queries('tags') })
return c
function throwExpression(errorMessage: string): never
.text(`q is $
(parameter) c: Context<BlankEnv, "/multiple-values", BlankInput>
{queries[0]} and $
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`q is ${string} and ${string}, limit is ${string}`, StatusCode>(text: `q is ${string} and ${string}, limit is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
{queries[1]}, limit is $
const queries: string[]
{limit[0]}`)
const queries: string[]
}) app
const limit: string[]
.get('/add-header',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/add-header", "/add-header", Response & TypedResponse<`foo is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/add-header", handler: H<...>) => Hono<...> (+22 overloads)
const bar =
(parameter) c: Context<BlankEnv, "/add-header", BlankInput>
c
const bar: string | undefined
.req
(parameter) c: Context<BlankEnv, "/add-header", BlankInput>
.header('X-Foo')
(property) Context<BlankEnv, "/add-header", BlankInput>.req: HonoRequest<"/add-header", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/add-header", unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
return c
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
.text(`foo is $
(parameter) c: Context<BlankEnv, "/add-header", BlankInput>
{bar}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`foo is ${string}`, StatusCode>(text: `foo is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) return app
const bar: string | undefined
})() apps['get all as an object'] = (() => {
const app: Hono<BlankEnv, BlankSchema, "/">
const app = new
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/entry/:id',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/entry/:id", "/entry/:id", Response & TypedResponse<`id is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/entry/:id", handler: H<...>) => Hono<...> (+22 overloads)
const { id } =
(parameter) c: Context<BlankEnv, "/entry/:id", BlankInput>
c
const id: string
.req
(parameter) c: Context<BlankEnv, "/entry/:id", BlankInput>
.param()
(property) Context<BlankEnv, "/entry/:id", BlankInput>.req: HonoRequest<"/entry/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/entry/:id", unknown>.param<"/entry/:id">(): { id: string; } (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`id is $
(parameter) c: Context<BlankEnv, "/entry/:id", BlankInput>
{id}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id is ${string}`, StatusCode>(text: `id is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) app
const id: string
.get('/date/:date{[0-9]+}',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/date/:date{[0-9]+}", "/date/:date{[0-9]+}", Response & TypedResponse<`date is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/date/:date{[0-9]+}", handler: H<...>) => Hono<...> (+22 overloads)
const { date } =
(parameter) c: Context<BlankEnv, "/date/:date{[0-9]+}", BlankInput>
c
const date: string
.req
(parameter) c: Context<BlankEnv, "/date/:date{[0-9]+}", BlankInput>
.param()
(property) Context<BlankEnv, "/date/:date{[0-9]+}", BlankInput>.req: HonoRequest<"/date/:date{[0-9]+}", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/date/:date{[0-9]+}", unknown>.param<"/date/:date{[0-9]+}">(): { date: string; } (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`date is $
(parameter) c: Context<BlankEnv, "/date/:date{[0-9]+}", BlankInput>
{date}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`date is ${string}`, StatusCode>(text: `date is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) app
const date: string
.get('/search',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", Response & TypedResponse<`name is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/search", handler: H<...>) => Hono<...> (+22 overloads)
const { name } =
(parameter) c: Context<BlankEnv, "/search", BlankInput>
c
const name: string
.req
(parameter) c: Context<BlankEnv, "/search", BlankInput>
.query()
(property) Context<BlankEnv, "/search", BlankInput>.req: HonoRequest<"/search", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/search", unknown>.query(): Record<string, string> (+1 overload)
.query()
can get querystring parameters.@see — 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() }) ```
return c.text(`name is $
(parameter) c: Context<BlankEnv, "/search", BlankInput>
{name}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`name is ${string}`, StatusCode>(text: `name is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) app
const name: string
.get('/multiple-values',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/multiple-values", "/multiple-values", Response & TypedResponse<`q is ${string} and ${string}, limit is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/multiple-values", handler: H<...>) => Hono<...> (+22 overloads)
const { q,
(parameter) c: Context<BlankEnv, "/multiple-values", BlankInput>
limit } =
const q: string[]
c
const limit: string[]
.req
(parameter) c: Context<BlankEnv, "/multiple-values", BlankInput>
.queries()
(property) Context<BlankEnv, "/multiple-values", BlankInput>.req: HonoRequest<"/multiple-values", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/multiple-values", unknown>.queries(): Record<string, string[]> (+1 overload)
.queries()
can get multiple querystring parameter values, e.g. /search?tags=A&tags=B@see — https://hono.dev/docs/api/request#queries
@example
return c
ts app.get('/search', (c) => { // tags will be string[] const tags = c.req.queries('tags') })
.text(`q is $
(parameter) c: Context<BlankEnv, "/multiple-values", BlankInput>
{q[0]} and $
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`q is ${string} and ${string}, limit is ${string}`, StatusCode>(text: `q is ${string} and ${string}, limit is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
{q[1]}, limit is $
const q: string[]
{limit[0]}`)
const q: string[]
}) app
const limit: string[]
.get('/add-header',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/add-header", "/add-header", Response & TypedResponse<`foo is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/add-header", handler: H<...>) => Hono<...> (+22 overloads)
const { 'x-foo': bar } =
(parameter) c: Context<BlankEnv, "/add-header", BlankInput>
c
const bar: string
.req
(parameter) c: Context<BlankEnv, "/add-header", BlankInput>
.header()
(property) Context<BlankEnv, "/add-header", BlankInput>.req: HonoRequest<"/add-header", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/add-header", unknown>.header(): Record<string, string> (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
return c
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
.text(`foo is $
(parameter) c: Context<BlankEnv, "/add-header", BlankInput>
{bar}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`foo is ${string}`, StatusCode>(text: `foo is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) return app
const bar: string
})() describe.each(Object
const app: Hono<BlankEnv, BlankSchema, "/">
.keys
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.keys(o: {}): string[] (+1 overload)
Returns the names of the enumerable string properties and methods of an object.@param
(apps))('%s',o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.(name) => {
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
const app =
(parameter) name: any
apps
const app: Hono<BlankEnv, BlankSchema, "/">
[name]
const apps: Record<string, Hono<BlankEnv, BlankSchema, "/">>
it('param of /entry/:id is found', async () => { const res = await
(parameter) name: any
app
const res: Response
.request('http://localhost/entry/123')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id is 123')
const res: Response
}) it('param of /entry/:id is found, even for Array object method names', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/entry/key')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id is key')
const res: Response
}) it('param of /entry/:id is decoded', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/entry/%C3%A7awa%20y%C3%AE%3F')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id is çawa yî?')
const res: Response
}) it('param of /date/:date is found', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/date/0401')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('date is 0401')
const res: Response
}) it('query of /search?name=sam is found', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/search?name=sam')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('name is sam')
const res: Response
}) it('query of /search?name=sam&name=tom is found', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/search?name=sam&name=tom')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('name is sam')
const res: Response
}) it('query of /multiple-values?q=foo&q=bar&limit=10 is found', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/multiple-values?q=foo&q=bar&limit=10')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('q is foo and bar, limit is 10')
const res: Response
}) it('/add-header header - X-Foo is Bar', async () => { const req = new
(method) Body.text(): Promise<string>
MDN ReferenceRequest('http://localhost/add-header')
const req: Request
req
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request..headers
const req: Request
.append('X-Foo', 'Bar')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.const res = await
(method) Headers.append(name: string, value: string): void
MDN Referenceapp
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('foo is Bar')
const res: Response
}) }) describe('param with undefined', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/foo/:foo',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo/:foo", "/foo/:foo", JSONRespondReturn<{ foo: string | undefined; }, StatusCode>, BlankInput, BlankEnv>(path: "/foo/:foo", handler: H<...>) => Hono<...> (+22 overloads)
const bar =
(parameter) c: Context<BlankEnv, "/foo/:foo", BlankInput>
c
const bar: string | undefined
.req
(parameter) c: Context<BlankEnv, "/foo/:foo", BlankInput>
.param('bar')
(property) Context<BlankEnv, "/foo/:foo", BlankInput>.req: HonoRequest<"/foo/:foo", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/foo/:foo", unknown>.param(key: string): string | undefined (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.json({
(parameter) c: Context<BlankEnv, "/foo/:foo", BlankInput>
foo:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ foo: string | undefined; }, StatusCode>(object: { foo: string | undefined; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
bar })
(property) foo: string | undefined
}) it('param of /foo/foo should return undefined not "undefined"', async () => { const res = await
const bar: string | undefined
app
const res: Response
.request('http://localhost/foo/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
foo: undefined })
(method) Body.json(): Promise<any>
MDN Reference}) }) }) describe('c.req.path', () => { const app = new
(property) foo: undefined
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<string, StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text
(parameter) c: Context<BlankEnv, "/", BlankInput>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/", BlankInput>
.path))
(property) Context<BlankEnv, "/", BlankInput>.req: HonoRequest<"/", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.path: string
.path
can get the pathname of the request.@see — https://hono.dev/docs/api/request#path
@example
app
ts app.get('/about/me', (c) => { const pathname = c.req.path // `/about/me` })
.get('/search',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/search", "/search", Response & TypedResponse<string, StatusCode, "text">, BlankInput, BlankEnv>(path: "/search", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/search", BlankInput>
.text
(parameter) c: Context<BlankEnv, "/search", BlankInput>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/search", BlankInput>
.path))
(property) Context<BlankEnv, "/search", BlankInput>.req: HonoRequest<"/search", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.path: string
.path
can get the pathname of the request.@see — https://hono.dev/docs/api/request#path
@example
it('Should get the path `/` correctly', async () => { const res = await
ts app.get('/about/me', (c) => { const pathname = c.req.path // `/about/me` })
app
const res: Response
.request('/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('/')
const res: Response
}) it('Should get the path `/search` correctly with a query', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/search?query=hono')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('/search')
const res: Response
}) }) describe('Header', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/text',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/text", "/text", Response & TypedResponse<"Hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/text", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/text", BlankInput>
.text('Hello')
(parameter) c: Context<BlankEnv, "/text", BlankInput>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Hello", StatusCode>(text: "Hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/text-with-custom-header',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/text-with-custom-header", "/text-with-custom-header", Response & TypedResponse<"Hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/text-with-custom-header", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/text-with-custom-header", BlankInput>
.header('X-Custom', 'Message')
(parameter) c: Context<BlankEnv, "/text-with-custom-header", BlankInput>
return c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.text('Hello')
(parameter) c: Context<BlankEnv, "/text-with-custom-header", BlankInput>
}) it('Should return correct headers - /text', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Hello", StatusCode>(text: "Hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('/text')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('content-type')).toMatch(/^text\/plain/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('Hello')
const res: Response
}) it('Should return correct headers - /text-with-custom-header', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/text-with-custom-header')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('x-custom')).toBe('Message')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('content-type')).toMatch(/^text\/plain/)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('Hello')
const res: Response
}) }) describe('Middleware', () => { describe('Basic', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
// Custom Logger appoptions
— Optional configuration options for the Hono instance..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
console
(parameter) next: Next
.log(`$
var console: Console
{c
(method) Console.log(...data: any[]): void
MDN Reference.req
(parameter) c: Context<BlankEnv, "*", {}>
.method} : $
(property) Context<BlankEnv, "*", {}>.req: HonoRequest<"*", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.method: string
.method()
can get the method name of the request.@see — https://hono.dev/docs/api/request#method
@example
{c
ts app.get('/about/me', (c) => { const method = c.req.method // `GET` })
.req
(parameter) c: Context<BlankEnv, "*", {}>
.url}`)
(property) Context<BlankEnv, "*", {}>.req: HonoRequest<"*", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.url: string
.url()
can get the request url strings.@see — https://hono.dev/docs/api/request#url
@example
await next()
ts app.get('/about/me', (c) => { const url = c.req.url // `http://localhost:8787/about/me` ... })
}) // Append Custom Header app
(parameter) next: () => Promise<void>
.use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('x-custom', 'root')
(property) Response.headers: Headers
MDN Reference}) app
(method) Headers.append(name: string, value: string): void
MDN Reference.use('/hello', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/hello", "/hello", BlankEnv>(path: "/hello", handler: MiddlewareHandler<BlankEnv, "/hello", {}>) => Hono<{}, { "/hello": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/hello", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res
(parameter) c: Context<BlankEnv, "/hello", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('x-message', 'custom-header')
(property) Response.headers: Headers
MDN Reference}) app
(method) Headers.append(name: string, value: string): void
MDN Reference.use('/hello/*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/hello/*", "/hello/*", BlankEnv>(path: "/hello/*", handler: MiddlewareHandler<BlankEnv, "/hello/*", {}>) => Hono<{}, { "/hello/*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/hello/*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res
(parameter) c: Context<BlankEnv, "/hello/*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('x-message-2', 'custom-header-2')
(property) Response.headers: Headers
MDN Reference}) app
(method) Headers.append(name: string, value: string): void
MDN Reference.get('/hello',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Response & TypedResponse<"hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
.text('hello')
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello", StatusCode>(text: "hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.use('/json/*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/json/*", "/json/*", BlankEnv>(path: "/json/*", handler: MiddlewareHandler<BlankEnv, "/json/*", {}>) => Hono<{}, { "/json/*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/json/*", {}>
c
(parameter) next: Next
.res
(parameter) c: Context<BlankEnv, "/json/*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('foo', 'bar')
(property) Response.headers: Headers
MDN Referenceawait next()
(method) Headers.append(name: string, value: string): void
MDN Reference}) app
(parameter) next: () => Promise<void>
.get('/json',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/json", "/json", Response, BlankInput, BlankEnv>(path: "/json", handler: H<BlankEnv, "/json", BlankInput, Response>) => Hono<...> (+22 overloads)
// With a raw response return new Response(
(parameter) c: Context<BlankEnv, "/json", BlankInput>
JSON
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..stringify({
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
message: 'hello',space
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.}), { headers: {
(property) message: string
'content-type': 'application/json', }, } ) }) app
(property) ResponseInit.headers?: HeadersInit | undefined
.get('/hello/:message',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello/:message", "/hello/:message", Response & TypedResponse<string, StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello/:message", handler: H<...>) => Hono<...> (+22 overloads)
const message =
(parameter) c: Context<BlankEnv, "/hello/:message", BlankInput>
c
const message: string
.req
(parameter) c: Context<BlankEnv, "/hello/:message", BlankInput>
.param('message')
(property) Context<BlankEnv, "/hello/:message", BlankInput>.req: HonoRequest<"/hello/:message", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/hello/:message", unknown>.param<"message">(key: "message"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`$
(parameter) c: Context<BlankEnv, "/hello/:message", BlankInput>
{message}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
}) app
const message: string
.get('/error', () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new Error('Error!')
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/error", "/error", never, BlankInput, BlankEnv>(path: "/error", handler: H<BlankEnv, "/error", BlankInput, never>) => Hono<BlankEnv, { ...; }, "/"> (+22 overloads)
}) app
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.notFound(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.notFound: (handler: NotFoundHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
(c) => {
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('Not Found Foo', 404)
(parameter) c: Context<BlankEnv, any, {}>
}) it('logging and custom header', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Not Found Foo", 404>(text: "Not Found Foo", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Not Found Foo", 404, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('x-custom')).toBe('root')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-message')).toBe('custom-header')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-message-2')).toBe('custom-header-2')
(property) Response.headers: Headers
MDN Reference}) it('logging and custom header with named param', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/hello/message')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('message')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('x-custom')).toBe('root')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-message-2')).toBe('custom-header-2')
(property) Response.headers: Headers
MDN Reference}) it('should return correct the content-type header', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/json')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('content-type')).toMatch(/^application\/json/)
(property) Response.headers: Headers
MDN Reference}) it('not found', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Not Found Foo')
const res: Response
}) it('internal server error', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/error')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
const res: Response
console
(property) Response.status: number
MDN Reference.log(await
var console: Console
res
(method) Console.log(...data: any[]): void
MDN Reference.text())
const res: Response
}) }) describe('Chained route', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('/chained/*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/chained/*", "/chained/*", BlankEnv>(path: "/chained/*", handler: MiddlewareHandler<BlankEnv, "/chained/*", {}>) => Hono<{}, { "/chained/*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/chained/*", {}>
c
(parameter) next: Next
.req
(parameter) c: Context<BlankEnv, "/chained/*", {}>
.raw
(property) Context<BlankEnv, "/chained/*", {}>.req: HonoRequest<"/chained/*", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.headers
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.append('x-before', 'abc')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.await next()
(method) Headers.append(name: string, value: string): void
MDN Reference}) .use(async
(parameter) next: () => Promise<void>
(c,
(property) Hono<{}, { "/chained/*": {}; }, "/">.use: MiddlewareHandlerInterface <{}>(...handlers: MiddlewareHandler<{}, "/chained/*", {}>[]) => Hono<{}, { "/chained/*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<{}, "/chained/*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.header(
(parameter) c: Context<{}, "/chained/*", {}>
'x-after', c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.req
(parameter) c: Context<{}, "/chained/*", {}>
.header('x-before') ??
(property) Context<{}, "/chained/*", {}>.req: HonoRequest<"/chained/*", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/chained/*", unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
throwExpression('missing `x-before` header')
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
) }) .get('/chained/abc',
function throwExpression(errorMessage: string): never
(c) => {
(property) Hono<{}, { "/chained/*": {}; }, "/">.get: HandlerInterface <"/chained/abc", "/chained/abc", Response & TypedResponse<"GET chained", StatusCode, "text">, BlankInput, {}>(path: "/chained/abc", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<{}, "/chained/abc", BlankInput>
.text('GET chained')
(parameter) c: Context<{}, "/chained/abc", BlankInput>
}) it('GET /chained/abc', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"GET chained", StatusCode>(text: "GET chained", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/chained/abc')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('GET chained')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('x-after')).toBe('abc')
(property) Response.headers: Headers
MDN Reference}) }) describe('Multiple handler', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use(
const app: Hono<BlankEnv, BlankSchema, "/">
'/multiple/*', async (c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/multiple/*", "/multiple/*", BlankEnv, {}>(path: "/multiple/*", handlers_0: MiddlewareHandler<BlankEnv, "/multiple/*", {}>, handlers_1: MiddlewareHandler<{}, "/multiple/*", {}>) => Hono<...> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/multiple/*", {}>
c
(parameter) next: Next
.req
(parameter) c: Context<BlankEnv, "/multiple/*", {}>
.raw
(property) Context<BlankEnv, "/multiple/*", {}>.req: HonoRequest<"/multiple/*", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.headers
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.append('x-before', 'abc')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.await next()
(method) Headers.append(name: string, value: string): void
MDN Reference}, async (c,
(parameter) next: () => Promise<void>
next) => {
(parameter) c: Context<{}, "/multiple/*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.header(
(parameter) c: Context<{}, "/multiple/*", {}>
'x-after', c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.req
(parameter) c: Context<{}, "/multiple/*", {}>
.header('x-before') ??
(property) Context<{}, "/multiple/*", {}>.req: HonoRequest<"/multiple/*", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/multiple/*", unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
throwExpression('missing `x-before` header')
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
) } ) .get('/multiple/abc',
function throwExpression(errorMessage: string): never
(c) => {
(property) Hono<{}, { "/multiple/*": {}; }, "/">.get: HandlerInterface <"/multiple/abc", "/multiple/abc", Response & TypedResponse<"GET multiple", StatusCode, "text">, BlankInput, {}>(path: "/multiple/abc", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<{}, "/multiple/abc", BlankInput>
.text('GET multiple')
(parameter) c: Context<{}, "/multiple/abc", BlankInput>
}) it('GET /multiple/abc', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"GET multiple", StatusCode>(text: "GET multiple", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/multiple/abc')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('GET multiple')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('x-after')).toBe('abc')
(property) Response.headers: Headers
MDN Reference}) }) describe('Overwrite the response from middleware after next()', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('/normal', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/normal", "/normal", BlankEnv>(path: "/normal", handler: MiddlewareHandler<BlankEnv, "/normal", {}>) => Hono<{}, { "/normal": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/normal", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res = new
(parameter) c: Context<BlankEnv, "/normal", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response('Middleware')_res
— The Response object to set.}) app
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..use('/overwrite', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/overwrite", "/overwrite", BlankEnv>(path: "/overwrite", handler: MiddlewareHandler<BlankEnv, "/overwrite", {}>) => Hono<{}, { "/overwrite": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/overwrite", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res = undefined
(parameter) c: Context<BlankEnv, "/overwrite", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
c_res
— The Response object to set..res = new
(parameter) c: Context<BlankEnv, "/overwrite", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response('Middleware')_res
— The Response object to set.}) app
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..get('*',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"*", "*", Response & TypedResponse<"Handler", StatusCode, "text">, BlankInput, BlankEnv>(path: "*", handler: H<BlankEnv, "*", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "*", BlankInput>
.header('x-custom', 'foo')
(parameter) c: Context<BlankEnv, "*", BlankInput>
return c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.text('Handler')
(parameter) c: Context<BlankEnv, "*", BlankInput>
}) it('Should have the custom header', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Handler", StatusCode>(text: "Handler", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('/normal')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.headers
const res: Response
.get('x-custom')).toBe('foo')
(property) Response.headers: Headers
MDN Reference}) it('Should not have the custom header', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('/overwrite')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.headers
const res: Response
.get('x-custom')).toBe(null)
(property) Response.headers: Headers
MDN Reference}) }) }) describe('Builtin Middleware', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('/abc',
const app: Hono<BlankEnv, BlankSchema, "/">
poweredBy())
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/abc", "/abc", any>(path: "/abc", handler: MiddlewareHandler<any, "/abc", {}>) => Hono<{}, { "/abc": {}; }, "/"> (+20 overloads)
app
(alias) poweredBy(): MiddlewareHandler import poweredBy
.use('/def', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/def", "/def", BlankEnv>(path: "/def", handler: MiddlewareHandler<BlankEnv, "/def", {}>) => Hono<{}, { "/def": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/def", {}>
const middleware =
(parameter) next: Next
poweredBy()
const middleware: MiddlewareHandler
await middleware
(alias) poweredBy(): MiddlewareHandler import poweredBy
(c,
const middleware: (c: Context<any, string, {}>, next: Next) => Promise<Response | void>
next)
(parameter) c: Context<BlankEnv, "/def", {}>
}) app
(parameter) next: Next
.get('/abc', () => new
const app: Hono<BlankEnv, BlankSchema, "/">
Response())
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/abc", "/abc", Response, BlankInput, BlankEnv>(path: "/abc", handler: H<BlankEnv, "/abc", BlankInput, Response>) => Hono<...> (+22 overloads)
app
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..get('/def', () => new
const app: Hono<BlankEnv, BlankSchema, "/">
Response())
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/def", "/def", Response, BlankInput, BlankEnv>(path: "/def", handler: H<BlankEnv, "/def", BlankInput, Response>) => Hono<...> (+22 overloads)
it('"powered-by" middleware', async () => { const res = await
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.app
const res: Response
.request('http://localhost/abc')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.headers
const res: Response
.get('x-powered-by')).toBe('Hono')
(property) Response.headers: Headers
MDN Reference}) it('"powered-by" middleware in a handler', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/def')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.headers
const res: Response
.get('x-powered-by')).toBe('Hono')
(property) Response.headers: Headers
MDN Reference}) }) describe('Middleware with app.HTTP_METHOD', () => { describe('Basic', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..all('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.all: HandlerInterface <"*", "*", HandlerResponse<any>, BlankInput, BlankEnv>(path: "*", handler: H<BlankEnv, "*", BlankInput, HandlerResponse<any>>) => Hono<...> (+22 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", BlankInput>
c
(parameter) next: Next
.header('x-before-dispatch', 'foo')
(parameter) c: Context<BlankEnv, "*", BlankInput>
await next()
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
(parameter) next: () => Promise<void>
.header('x-custom-message', 'hello')
(parameter) c: Context<BlankEnv, "*", BlankInput>
}) const customHeader = async
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
(c:
const customHeader: (c: Context, next: Next) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Next) => {
(parameter) next: Next
c
(alias) type Next = () => Promise<void> import Next
.req
(parameter) c: Context<any, any, {}>
.raw
(property) Context<any, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.raw: Request
.raw
can get the raw Request object.@see — https://hono.dev/docs/api/request#raw
@example
.headers
ts // For Cloudflare Workers app.post('/', async (c) => { const metadata = c.req.raw.cf?.hostMetadata? ... })
.append('x-custom-foo', 'bar')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.await next()
(method) Headers.append(name: string, value: string): void
MDN Reference} const customHeader2 = async
(parameter) next: () => Promise<void>
(c:
const customHeader2: (c: Context, next: Next) => Promise<void>
Context,
(parameter) c: Context<any, any, {}>
next:
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> import Context
Next) => {
(parameter) next: Next
await next()
(alias) type Next = () => Promise<void> import Next
c
(parameter) next: () => Promise<void>
.header('x-custom-foo-2', 'bar-2')
(parameter) c: Context<any, any, {}>
} app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.get('/abc',
const app: Hono<BlankEnv, BlankSchema, "/">
customHeader,
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/abc", any, Response & TypedResponse<string, StatusCode, "text">, {}, {}, any, {}>(path: "/abc", handlers_0: H<any, any, {}, any>, handlers_1: H<{}, any, {}, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
(c) => {
const customHeader: (c: Context, next: Next) => Promise<void>
const foo =
(parameter) c: Context<{}, any, {}>
c
const foo: string
.req
(parameter) c: Context<{}, any, {}>
.header('x-custom-foo') || ''
(property) Context<{}, any, {}>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
return c
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
.text
(parameter) c: Context<{}, any, {}>
(foo)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
}) .post
const foo: string
(customHeader2,
(property) Hono<BlankEnv, { "/abc": { $get: { input: {}; output: string; outputFormat: "text"; status: StatusCode; }; }; }, "/">.post: HandlerInterface <any, {}, {}, Response & TypedResponse<"POST /abc", StatusCode, "text">, any, {}>(handlers_0: H<any, any, {}, any>, handlers_1: H<{}, any, {}, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
(c) => {
const customHeader2: (c: Context, next: Next) => Promise<void>
return c
(parameter) c: Context<{}, any, {}>
.text('POST /abc')
(parameter) c: Context<{}, any, {}>
}) it('GET /abc', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"POST /abc", StatusCode>(text: "POST /abc", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/abc')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('x-custom-message')).toBe('hello')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-before-dispatch')).toBe('foo')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('bar')
const res: Response
}) it('POST /abc', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/abc', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'POST' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('POST /abc')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('x-custom-foo-2')).toBe('bar-2')
(property) Response.headers: Headers
MDN Reference}) }) describe('With builtin middleware', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/abc',
const app: Hono<BlankEnv, BlankSchema, "/">
poweredBy(),
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/abc", "/abc", Response & TypedResponse<"GET /abc", StatusCode, "text">, {}, {}, any, {}>(path: "/abc", handlers_0: H<any, "/abc", {}, any>, handlers_1: H<...>) => Hono<...> (+22 overloads)
(c) => {
(alias) poweredBy(): MiddlewareHandler import poweredBy
return c
(parameter) c: Context<{}, "/abc", {}>
.text('GET /abc')
(parameter) c: Context<{}, "/abc", {}>
}) it('GET /abc', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"GET /abc", StatusCode>(text: "GET /abc", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/abc')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('GET /abc')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('x-powered-by')).toBe('Hono')
(property) Response.headers: Headers
MDN Reference}) }) }) describe('Not Found', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..notFound(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.notFound: (handler: NotFoundHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
(c) => {
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('Custom 404 Not Found', 404)
(parameter) c: Context<BlankEnv, any, {}>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Custom 404 Not Found", 404>(text: "Custom 404 Not Found", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Custom 404 Not Found", 404, "text"> (+1 overload)
.get('/hello',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/hello", "/hello", Response & TypedResponse<"hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/hello", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
.text('hello')
(parameter) c: Context<BlankEnv, "/hello", BlankInput>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello", StatusCode>(text: "hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/notfound',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/notfound", "/notfound", Response | Promise<Response>, BlankInput, BlankEnv>(path: "/notfound", handler: H<BlankEnv, "/notfound", BlankInput, Response | Promise<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/notfound", BlankInput>
.notFound()
(parameter) c: Context<BlankEnv, "/notfound", BlankInput>
(property) Context<BlankEnv, "/notfound", BlankInput>.notFound: () => Response | Promise<Response>
.notFound()
can return the Not Found Response.@see — https://hono.dev/docs/api/context#notfound
@example
}) it('Custom 404 Not Found', async () => { let res = await
ts app.get('/notfound', (c) => { return c.notFound() })
app
let res: Response
.request('http://localhost/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
res = await
(property) Response.status: number
MDN Referenceapp
let res: Response
.request('http://localhost/notfound')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
let res: Response
res = await
(property) Response.status: number
MDN Referenceapp
let res: Response
.request('http://localhost/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom 404 Not Found')
let res: Response
}) describe('Not Found with a middleware', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('hello'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello", StatusCode>(text: "hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res = new
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response((await_res
— The Response object to set.c
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..res
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()) + ' + Middleware',_res
— The Response object to set.c
(method) Body.text(): Promise<string>
MDN Reference.res)
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
}) it('Custom 404 Not Found', async () => { let res = await_res
— The Response object to set.app
let res: Response
.request('http://localhost/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('404 Not Found + Middleware')
let res: Response
}) }) describe('Not Found with some middleware', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('hello'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello", StatusCode>(text: "hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res = new
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response((await_res
— The Response object to set.c
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..res
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()) + ' + Middleware 1',_res
— The Response object to set.c
(method) Body.text(): Promise<string>
MDN Reference.res)
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
}) app_res
— The Response object to set..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res = new
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response((await_res
— The Response object to set.c
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..res
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text()) + ' + Middleware 2',_res
— The Response object to set.c
(method) Body.text(): Promise<string>
MDN Reference.res)
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
}) it('Custom 404 Not Found', async () => { let res = await_res
— The Response object to set.app
let res: Response
.request('http://localhost/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('404 Not Found + Middleware 2 + Middleware 1')
let res: Response
}) }) describe('No response from a handler', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"hello", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('hello'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"hello", StatusCode>(text: "hello", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/not-found', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => undefined)
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/not-found", "/not-found", HandlerResponse<any>, BlankInput, BlankEnv>(path: "/not-found", handler: H<BlankEnv, "/not-found", BlankInput, HandlerResponse<...>>) => Hono<...> (+22 overloads)
it('Custom 404 Not Found', async () => { let res = await
(parameter) c: Context<BlankEnv, "/not-found", BlankInput>
app
let res: Response
.request('http://localhost/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('http://localhost/not-found')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('404 Not Found')
let res: Response
}) }) describe('Custom 404 Not Found with a middleware like Compress Middleware', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
// Custom Middleware which creates a new Response object after `next()`. appoptions
— Optional configuration options for the Hono instance..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res = new
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
Response(await_res
— The Response object to set.c
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..res
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.text(),_res
— The Response object to set.c
(method) Body.text(): Promise<string>
MDN Reference.res)
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
}) app_res
— The Response object to set..notFound(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.notFound: (handler: NotFoundHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
(c) => {
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('Custom NotFound', 404)
(parameter) c: Context<BlankEnv, any, {}>
}) it('Custom 404 Not Found', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Custom NotFound", 404>(text: "Custom NotFound", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Custom NotFound", 404, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom NotFound')
const res: Response
}) }) }) describe('Redirect', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/redirect',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/redirect", "/redirect", Response & TypedResponse<undefined, 302, "redirect">, BlankInput, BlankEnv>(path: "/redirect", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/redirect", BlankInput>
.redirect('/')
(parameter) c: Context<BlankEnv, "/redirect", BlankInput>
(property) Context<BlankEnv, "/redirect", BlankInput>.redirect: <302>(location: string, status?: 302 | undefined) => Response & TypedResponse<undefined, 302, "redirect">
.redirect()
can Redirect, default status code is 302.@see — https://hono.dev/docs/api/context#redirect
@example
}) it('Absolute URL', async () => { const res = await
ts app.get('/redirect', (c) => { return c.redirect('/') }) app.get('/redirect-permanently', (c) => { return c.redirect('/', 301) })
app
const res: Response
.request('https://example.com/redirect')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(302)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('Location')).toBe('/')
(property) Response.headers: Headers
MDN Reference}) }) describe('Error handle', () => { describe('Basic', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/error', () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new Error('This is Error')
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/error", "/error", never, BlankInput, BlankEnv>(path: "/error", handler: H<BlankEnv, "/error", BlankInput, never>) => Hono<BlankEnv, { ...; }, "/"> (+22 overloads)
}) app
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.get('/error-string', () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw 'This is Error' }) app
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/error-string", "/error-string", never, BlankInput, BlankEnv>(path: "/error-string", handler: H<BlankEnv, "/error-string", BlankInput, never>) => Hono<...> (+22 overloads)
.use('/error-middleware', async () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new Error('This is Middleware Error')
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/error-middleware", "/error-middleware", BlankEnv>(path: "/error-middleware", handler: MiddlewareHandler<BlankEnv, "/error-middleware", {}>) => Hono<...> (+20 overloads)
}) app
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.onError(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
c
(parameter) c: Context<BlankEnv, any, {}>
.header('x-debug',
(parameter) c: Context<BlankEnv, any, {}>
err
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.message)
(parameter) err: Error | HTTPResponseError
return c
(property) Error.message: string
.text('Custom Error Message', 500)
(parameter) c: Context<BlankEnv, any, {}>
}) it('Should throw Error if a non-Error object is thrown in a handler', async () => { expect(() => app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Custom Error Message", 500>(text: "Custom Error Message", status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Custom Error Message", 500, "text"> (+1 overload)
.request('/error-string')).toThrowError()
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
}) it('Custom Error Message', async () => { let res = awaitapp
let res: Response
.request('https://example.com/error')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom Error Message')
let res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
let res: Response
.get('x-debug')).toBe('This is Error')
(property) Response.headers: Headers
MDN Referenceres = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
let res: Response
.request('https://example.com/error-middleware')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom Error Message')
let res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
let res: Response
.get('x-debug')).toBe('This is Middleware Error')
(property) Response.headers: Headers
MDN Reference}) }) describe('Async custom handler', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/error', () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new Error('This is Error')
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/error", "/error", never, BlankInput, BlankEnv>(path: "/error", handler: H<BlankEnv, "/error", BlankInput, never>) => Hono<BlankEnv, { ...; }, "/"> (+22 overloads)
}) app
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.use('/error-middleware', async () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new Error('This is Middleware Error')
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/error-middleware", "/error-middleware", BlankEnv>(path: "/error-middleware", handler: MiddlewareHandler<BlankEnv, "/error-middleware", {}>) => Hono<...> (+20 overloads)
}) app
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.onError(async
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
const promise = new
(parameter) c: Context<BlankEnv, any, {}>
Promise(
const promise: Promise<unknown>
var Promise: PromiseConstructor new <unknown>(executor: (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void) => Promise<unknown>
Creates a new Promise.@param
(resolve) =>executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.setTimeout(() => {
(parameter) resolve: (value: unknown) => void
resolve('Promised')
function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
MDN Reference}, 1) ) const message = (await
(parameter) resolve: (value: unknown) => void
promise) as string
const message: string
c
const promise: Promise<unknown>
.header('x-debug',
(parameter) c: Context<BlankEnv, any, {}>
err
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.message)
(parameter) err: Error | HTTPResponseError
return c
(property) Error.message: string
.text(`Custom Error Message with $
(parameter) c: Context<BlankEnv, any, {}>
{message}`, 500)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`Custom Error Message with ${string}`, 500>(text: `Custom Error Message with ${string}`, status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<`Custom Error Message with ${string}`, 500, "text"> (+1 overload)
}) it('Custom Error Message', async () => { let res = await
const message: string
app
let res: Response
.request('https://example.com/error')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom Error Message with Promised')
let res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
let res: Response
.get('x-debug')).toBe('This is Error')
(property) Response.headers: Headers
MDN Referenceres = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
let res: Response
.request('https://example.com/error-middleware')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom Error Message with Promised')
let res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
let res: Response
.get('x-debug')).toBe('This is Middleware Error')
(property) Response.headers: Headers
MDN Reference}) }) describe('Handle HTTPException', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/exception', () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new HTTPException(401, {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/exception", "/exception", never, BlankInput, BlankEnv>(path: "/exception", handler: H<BlankEnv, "/exception", BlankInput, never>) => Hono<...> (+22 overloads)
(alias) new HTTPException(status?: StatusCode, options?: HTTPExceptionOptions): HTTPException import HTTPException
Creates an instance ofHTTPException
.@param
status
— HTTP status code for the exception. Defaults to 500.@param
message: 'Unauthorized',options
— Additional options for the exception.}) }) it('Should return 401 response', async () => { const res = await
(property) message?: string | undefined
app
const res: Response
.request('http://localhost/exception')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(401)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Unauthorized')
const res: Response
}) const app2 = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app2: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
app2options
— Optional configuration options for the Hono instance..get('/exception', () => {
const app2: Hono<BlankEnv, BlankSchema, "/">
throw new HTTPException(401)
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/exception", "/exception", never, BlankInput, BlankEnv>(path: "/exception", handler: H<BlankEnv, "/exception", BlankInput, never>) => Hono<...> (+22 overloads)
(alias) new HTTPException(status?: StatusCode, options?: HTTPExceptionOptions): HTTPException import HTTPException
Creates an instance ofHTTPException
.@param
status
— HTTP status code for the exception. Defaults to 500.@param
}) app2options
— Additional options for the exception..onError(
const app2: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
if (err instanceof
(parameter) c: Context<BlankEnv, any, {}>
HTTPException &&
(parameter) err: Error | HTTPResponseError
(alias) class HTTPException import HTTPException
HTTPException
must be used when a fatal error such as authentication failure occurs.@see — https://hono.dev/docs/api/exception
@param
status
— status code of HTTPException@param
options
— options of HTTPException@param
options.res
— response of options of HTTPException@param
options.message
— message of options of HTTPException@param
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() }) ```
err.status === 401) {
(parameter) err: HTTPException
return c
(property) HTTPException.status: StatusCode
.text('Custom Error Message', 401)
(parameter) c: Context<BlankEnv, any, {}>
} return c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Custom Error Message", 401>(text: "Custom Error Message", status?: 401 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Custom Error Message", 401, "text"> (+1 overload)
.text('Internal Server Error', 500)
(parameter) c: Context<BlankEnv, any, {}>
}) it('Should return 401 response with a custom message', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Internal Server Error", 500>(text: "Internal Server Error", status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Internal Server Error", 500, "text"> (+1 overload)
app2
const res: Response
.request('http://localhost/exception')
const app2: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(401)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom Error Message')
const res: Response
}) }) describe('Handle HTTPException like object', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
class CustomError extendsoptions
— Optional configuration options for the Hono instance.Error {
class CustomError
getResponse() {
var Error: ErrorConstructor
return new Response('Custom Error', {
(method) CustomError.getResponse(): Response
status: 400 })
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.} } app
(property) ResponseInit.status?: number | undefined
.get('/exception', () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new CustomError()
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/exception", "/exception", never, BlankInput, BlankEnv>(path: "/exception", handler: H<BlankEnv, "/exception", BlankInput, never>) => Hono<...> (+22 overloads)
}) it('Should return 401 response', async () => { const res = await
constructor CustomError(message?: string, options?: ErrorOptions): CustomError (+1 overload)
app
const res: Response
.request('http://localhost/exception')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(400)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom Error')
const res: Response
}) }) }) describe('Error handling in middleware', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/handle-error-in-middleware', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/handle-error-in-middleware", "/handle-error-in-middleware", HandlerResponse<any>, BlankInput, BlankEnv>(path: "/handle-error-in-middleware", handler: H<...>) => Hono<...> (+22 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware", BlankInput>
await next()
(parameter) next: Next
if (c
(parameter) next: () => Promise<void>
.error) {
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware", BlankInput>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
const message =
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
c
const message: string
.error
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware", BlankInput>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.error: Error
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
.message
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
c
(property) Error.message: string
.res =
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware", BlankInput>
(property) Context<BlankEnv, "/handle-error-in-middleware", BlankInput>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
c_res
— The Response object to set..text(`Handle the error in middleware, original message is $
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware", BlankInput>
{message}`, 500)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`Handle the error in middleware, original message is ${string}`, 500>(text: `Handle the error in middleware, original message is ${string}`, status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<`Handle the error in middleware, original message is ${string}`, 500, "text"> (+1 overload)
} }) app
const message: string
.get('/handle-error-in-middleware-async', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/handle-error-in-middleware-async", "/handle-error-in-middleware-async", HandlerResponse<any>, BlankInput, BlankEnv>(path: "/handle-error-in-middleware-async", handler: H<...>) => Hono<...> (+22 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware-async", BlankInput>
await next()
(parameter) next: Next
if (c
(parameter) next: () => Promise<void>
.error) {
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware-async", BlankInput>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.error: Error | undefined
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
const message =
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
c
const message: string
.error
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware-async", BlankInput>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.error: Error
.error
can get the error object from the middleware if the Handler throws an error.@see — https://hono.dev/docs/api/context#error
@example
.message
ts app.use('*', async (c, next) => { await next() if (c.error) { // do something... } })
c
(property) Error.message: string
.res =
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware-async", BlankInput>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response | undefined
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
c_res
— The Response object to set..text(
(parameter) c: Context<BlankEnv, "/handle-error-in-middleware-async", BlankInput>
`Handle the error in middleware with async, original message is ${message}`,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`Handle the error in middleware with async, original message is ${string}`, 500>(text: `Handle the error in middleware with async, original message is ${string}`, status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<`Handle the error in middleware with async, original message is ${string}`, 500, "text"> (+1 overload)
500 ) } }) app
const message: string
.get('/handle-error-in-middleware', () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new Error('Error message')
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/handle-error-in-middleware", "/handle-error-in-middleware", never, BlankInput, BlankEnv>(path: "/handle-error-in-middleware", handler: H<BlankEnv, "/handle-error-in-middleware", BlankInput, never>) => Hono<...> (+22 overloads)
}) app
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.get('/handle-error-in-middleware-async', async () => {
const app: Hono<BlankEnv, BlankSchema, "/">
throw new Error('Error message')
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/handle-error-in-middleware-async", "/handle-error-in-middleware-async", Promise<never>, BlankInput, BlankEnv>(path: "/handle-error-in-middleware-async", handler: H<...>) => Hono<...> (+22 overloads)
}) it('Should handle the error in middleware', async () => { const res = await
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
app
const res: Response
.request('https://example.com/handle-error-in-middleware')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe(
const res: Response
'Handle the error in middleware, original message is Error message' ) }) it('Should handle the error in middleware - async', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('https://example.com/handle-error-in-middleware-async')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe(
const res: Response
'Handle the error in middleware with async, original message is Error message' ) }) describe('Default route app.use', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use(async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <BlankEnv>(...handlers: MiddlewareHandler<BlankEnv, never, {}>[]) => Hono<{}, BlankSchema, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, never, {}>
c
(parameter) next: Next
.header('x-default-use', 'abc')
(parameter) c: Context<BlankEnv, never, {}>
await next()
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
}) .get('/multiple/abc',
(parameter) next: () => Promise<void>
(c) => {
(property) Hono<{}, BlankSchema, "/">.get: HandlerInterface <"/multiple/abc", "/multiple/abc", Response & TypedResponse<"GET multiple", StatusCode, "text">, BlankInput, {}>(path: "/multiple/abc", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<{}, "/multiple/abc", BlankInput>
.text('GET multiple')
(parameter) c: Context<{}, "/multiple/abc", BlankInput>
}) it('GET /multiple/abc', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"GET multiple", StatusCode>(text: "GET multiple", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/multiple/abc')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('GET multiple')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('x-default-use')).toBe('abc')
(property) Response.headers: Headers
MDN Reference}) }) describe('Error in `notFound()`', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('*', async () => {})
const app: Hono<BlankEnv, BlankSchema, "/">
app
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
.notFound(() => {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.notFound: (handler: NotFoundHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
throw new Error('Error in Not Found')
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
}) app
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.onError(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
return c
(parameter) c: Context<BlankEnv, any, {}>
.text
(parameter) c: Context<BlankEnv, any, {}>
(err
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, 400>(text: string, status?: 400 | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, 400, "text"> (+1 overload)
.message, 400)
(parameter) err: Error | HTTPResponseError
}) it('Should handle the error thrown in `notFound()``', async () => { const res = await
(property) Error.message: string
app
const res: Response
.request('http://localhost/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(400)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Error in Not Found')
const res: Response
}) }) }) describe('Request methods with custom middleware', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
const query =
(parameter) next: Next
c
const query: string | undefined
.req
(parameter) c: Context<BlankEnv, "*", {}>
.query('foo')
(property) Context<BlankEnv, "*", {}>.req: HonoRequest<"*", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"*", unknown>.query(key: string): string | undefined (+1 overload)
.query()
can get querystring parameters.@see — 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() }) ```
// @ts-ignore const param =c
const param: string | undefined
.req
(parameter) c: Context<BlankEnv, "*", {}>
.param('foo') // This will cause a type error.
(property) Context<BlankEnv, "*", {}>.req: HonoRequest<"*", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"*", unknown>.param(key: string): string | undefined (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
const header =
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
c
const header: string | undefined
.req
(parameter) c: Context<BlankEnv, "*", {}>
.header('User-Agent')
(property) Context<BlankEnv, "*", {}>.req: HonoRequest<"*", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"*", unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
await next()
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
c
(parameter) next: () => Promise<void>
.header('X-Query-2',
(parameter) c: Context<BlankEnv, "*", {}>
query ??
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
throwExpression('missing `X-Query-2` header'))
const query: string | undefined
c
function throwExpression(errorMessage: string): never
.header('X-Param-2',
(parameter) c: Context<BlankEnv, "*", {}>
param)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
const param: string | undefined
.header('X-Header-2',
(parameter) c: Context<BlankEnv, "*", {}>
header ??
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
throwExpression('missing `X-Header-2` header'))
const header: string | undefined
}) app
function throwExpression(errorMessage: string): never
.get('/:foo',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/:foo", "/:foo", Response, BlankInput, BlankEnv>(path: "/:foo", handler: H<BlankEnv, "/:foo", BlankInput, Response>) => Hono<...> (+22 overloads)
const query =
(parameter) c: Context<BlankEnv, "/:foo", BlankInput>
c
const query: string | undefined
.req
(parameter) c: Context<BlankEnv, "/:foo", BlankInput>
.query('foo')
(property) Context<BlankEnv, "/:foo", BlankInput>.req: HonoRequest<"/:foo", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:foo", unknown>.query(key: string): string | undefined (+1 overload)
.query()
can get querystring parameters.@see — 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() }) ```
const param =c
const param: string
.req
(parameter) c: Context<BlankEnv, "/:foo", BlankInput>
.param('foo')
(property) Context<BlankEnv, "/:foo", BlankInput>.req: HonoRequest<"/:foo", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:foo", unknown>.param<"foo">(key: "foo"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
const header =
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
c
const header: string | undefined
.req
(parameter) c: Context<BlankEnv, "/:foo", BlankInput>
.header('User-Agent')
(property) Context<BlankEnv, "/:foo", BlankInput>.req: HonoRequest<"/:foo", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:foo", unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
c
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
.header('X-Query',
(parameter) c: Context<BlankEnv, "/:foo", BlankInput>
query ??
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
throwExpression('missing `X-Query` header'))
const query: string | undefined
c
function throwExpression(errorMessage: string): never
.header('X-Param',
(parameter) c: Context<BlankEnv, "/:foo", BlankInput>
param)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
const param: string
.header('X-Header',
(parameter) c: Context<BlankEnv, "/:foo", BlankInput>
header ??
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
throwExpression('missing `X-Header` header'))
const header: string | undefined
return c
function throwExpression(errorMessage: string): never
.body('Hono')
(parameter) c: Context<BlankEnv, "/:foo", BlankInput>
}) it('query', async () => { const url = new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.body: BodyRespond (data: Data | null, status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
URL('http://localhost/bar')
const url: URL
url
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs..searchParams
const url: URL
.append('foo', 'bar')
(property) URL.searchParams: URLSearchParams
MDN Referenceconst req = new
(method) URLSearchParams.append(name: string, value: string): void
Appends a specified key/value pair as a new search parameter.Request
const req: Request
(url
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request..toString())
const url: URL
req
(method) URL.toString(): string
.headers
const req: Request
.append('User-Agent', 'bar')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.const res = await
(method) Headers.append(name: string, value: string): void
MDN Referenceapp
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('X-Query')).toBe('bar')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('X-Param')).toBe('bar')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('X-Header')).toBe('bar')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('X-Query-2')).toBe('bar')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('X-Param-2')).toBe(null)
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('X-Header-2')).toBe('bar')
(property) Response.headers: Headers
MDN Reference}) }) describe('Middleware + c.json(0, requestInit)', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('/', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/", "/", BlankEnv>(path: "/", handler: MiddlewareHandler<BlankEnv, "/", {}>) => Hono<{}, { "/": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/", {}>
await next()
(parameter) next: Next
}) app
(parameter) next: () => Promise<void>
.get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", JSONRespondReturn<0, StatusCode>, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.json(0, {
(parameter) c: Context<BlankEnv, "/", BlankInput>
status: 200,
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <0, StatusCode>(object: 0, init?: ResponseInit) => JSONRespondReturn<0, StatusCode> (+1 overload)
headers: {
(property) ResponseInit.status?: number | undefined
foo: 'bar',
(property) ResponseInit.headers?: ResponseHeadersInit | undefined
}, }) }) it('Should return a correct headers', async () => { const res = await
(property) foo: string
app
const res: Response
.request('/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.headers
const res: Response
.get('content-type')).toMatch(/^application\/json/)
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('foo')).toBe('bar')
(property) Response.headers: Headers
MDN Reference}) }) describe('Hono with `app.route`', () => { describe('Basic', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const api = newoptions
— Optional configuration options for the Hono instance.Hono()
const api: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const middleware = newoptions
— Optional configuration options for the Hono instance.Hono()
const middleware: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
apioptions
— Optional configuration options for the Hono instance..use('*', async
const api: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('x-custom-a', 'a')
(property) Response.headers: Headers
MDN Reference}) api
(method) Headers.append(name: string, value: string): void
MDN Reference.get('/posts',
const api: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts", "/posts", Response & TypedResponse<"List", StatusCode, "text">, BlankInput, BlankEnv>(path: "/posts", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/posts", BlankInput>
.text('List'))
(parameter) c: Context<BlankEnv, "/posts", BlankInput>
api
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"List", StatusCode>(text: "List", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"List", StatusCode, "text"> (+1 overload)
.post('/posts',
const api: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.post: HandlerInterface <"/posts", "/posts", Response & TypedResponse<"Create", StatusCode, "text">, BlankInput, BlankEnv>(path: "/posts", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/posts", BlankInput>
.text('Create'))
(parameter) c: Context<BlankEnv, "/posts", BlankInput>
api
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Create", StatusCode>(text: "Create", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/posts/:id',
const api: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id", "/posts/:id", Response & TypedResponse<`GET ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/posts/:id", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.text(`GET $
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`GET ${string}`, StatusCode>(text: `GET ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.param('id')}`))
(property) Context<BlankEnv, "/posts/:id", BlankInput>.req: HonoRequest<"/posts/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
middleware
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.use('*', async
const middleware: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.res
(parameter) c: Context<BlankEnv, "*", {}>
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.res: Response
Sets the Response object for the current request.@see — https://hono.dev/docs/api/context#resThe Response object for the current request.
@param
.headers_res
— The Response object to set..append('x-custom-b', 'b')
(property) Response.headers: Headers
MDN Reference}) app
(method) Headers.append(name: string, value: string): void
MDN Reference.route('/api',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", BlankEnv, BlankSchema, "/">(path: "/api", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
middleware)app
const middleware: Hono<BlankEnv, BlankSchema, "/">
.route('/api',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", BlankEnv, BlankSchema, "/">(path: "/api", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api)app
const api: Hono<BlankEnv, BlankSchema, "/">
.get('/foo',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo", "/foo", Response & TypedResponse<"bar", StatusCode, "text">, BlankInput, BlankEnv>(path: "/foo", handler: H<BlankEnv, "/foo", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.text('bar'))
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
it('Should return not found response', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"bar", StatusCode>(text: "bar", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"bar", StatusCode, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
}) it('Should return not found response', async () => { const res = await
(property) Response.status: number
MDN Referenceapp
const res: Response
.request('http://localhost/posts')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
}) test('GET /api/posts', async () => { const res = await
(property) Response.status: number
MDN Referenceapp
const res: Response
.request('http://localhost/api/posts')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('List')
const res: Response
}) test('Custom header by middleware', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/api/posts')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('x-custom-a')).toBe('a')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('x-custom-b')).toBe('b')
(property) Response.headers: Headers
MDN Reference}) test('POST /api/posts', async () => { const res = await
(method) Headers.get(name: string): string | null
MDN Referenceapp
const res: Response
.request('http://localhost/api/posts', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'POST' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Create')
const res: Response
}) test('GET /api/posts/123', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/api/posts/123')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('GET 123')
const res: Response
}) test('GET /foo', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('bar')
const res: Response
}) describe('With app.get(...handler)', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const about = newoptions
— Optional configuration options for the Hono instance.Hono()
const about: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
aboutoptions
— Optional configuration options for the Hono instance..get(
const about: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", BlankInput, Response & TypedResponse<"me", StatusCode, "text">, BlankEnv>(handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('me'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
const subApp = new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"me", StatusCode>(text: "me", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"me", StatusCode, "text"> (+1 overload)
Hono()
const subApp: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
subAppoptions
— Optional configuration options for the Hono instance..route('/about',
const subApp: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/about", BlankEnv, BlankSchema, "/">(path: "/about", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
about)app
const about: Hono<BlankEnv, BlankSchema, "/">
.route('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/", BlankEnv, BlankSchema, "/">(path: "/", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
subApp)it('Should return 200 response - /about', async () => { const res = await
const subApp: Hono<BlankEnv, BlankSchema, "/">
app
const res: Response
.request('/about')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('me')
const res: Response
}) test('Should return 404 response /about/foo', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/about/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
}) }) describe('With app.get(...handler) and app.basePath()', () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const about = newoptions
— Optional configuration options for the Hono instance.Hono()
const about: Hono<BlankEnv, BlankSchema, "/about">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.basePath('/about')options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/about">(path: "/about"): Hono<BlankEnv, BlankSchema, "/about">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
about
ts const api = new Hono().basePath('/api')
.get(
const about: Hono<BlankEnv, BlankSchema, "/about">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/about">.get: HandlerInterface <"/about", BlankInput, Response & TypedResponse<"me", StatusCode, "text">, BlankEnv>(handler: H<BlankEnv, "/about", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/about", BlankInput>
.text('me'))
(parameter) c: Context<BlankEnv, "/about", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"me", StatusCode>(text: "me", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"me", StatusCode, "text"> (+1 overload)
.route('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/", BlankEnv, BlankSchema, "/about">(path: "/", app: Hono<BlankEnv, BlankSchema, "/about">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
about)it('Should return 200 response - /about', async () => { const res = await
const about: Hono<BlankEnv, BlankSchema, "/about">
app
const res: Response
.request('/about')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('me')
const res: Response
}) test('Should return 404 response /about/foo', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/about/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
}) }) }) describe('Chaining', () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const route = newoptions
— Optional configuration options for the Hono instance.Hono()
const route: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
routeoptions
— Optional configuration options for the Hono instance..get('/post',
const route: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/post", "/post", Response & TypedResponse<"GET /POST v2", StatusCode, "text">, BlankInput, BlankEnv>(path: "/post", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/post", BlankInput>
.text('GET /POST v2'))
(parameter) c: Context<BlankEnv, "/post", BlankInput>
.post(
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"GET /POST v2", StatusCode>(text: "GET /POST v2", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
(c) =>
(property) Hono<BlankEnv, { "/post": { $get: { input: {}; output: "GET /POST v2"; outputFormat: "text"; status: StatusCode; }; }; }, "/">.post: HandlerInterface <"/post", BlankInput, Response & TypedResponse<"POST /POST v2", StatusCode, "text">, BlankEnv>(handler: H<BlankEnv, "/post", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/post", BlankInput>
.text('POST /POST v2'))
(parameter) c: Context<BlankEnv, "/post", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"POST /POST v2", StatusCode>(text: "POST /POST v2", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.route('/v2',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/v2", BlankEnv, BlankSchema, "/">(path: "/v2", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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)it('Should return 200 response - GET /v2/post', async () => { const res = await
const route: Hono<BlankEnv, BlankSchema, "/">
app
const res: Response
.request('http://localhost/v2/post')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('GET /POST v2')
const res: Response
}) it('Should return 200 response - POST /v2/post', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/v2/post', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'POST' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('POST /POST v2')
const res: Response
}) it('Should return 404 response - DELETE /v2/post', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/v2/post', {
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
method: 'DELETE' })expect(res
(property) RequestInit.method?: string | undefined
A string to set request's method..status).toBe(404)
const res: Response
}) }) describe('Nested', () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const api = newoptions
— Optional configuration options for the Hono instance.Hono()
const api: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const book = newoptions
— Optional configuration options for the Hono instance.Hono()
const book: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
bookoptions
— Optional configuration options for the Hono instance..get('/',
const book: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"list books", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('list books'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
book
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"list books", StatusCode>(text: "list books", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.get('/:id',
const book: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/:id", "/:id", Response & TypedResponse<`book ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/:id", handler: H<BlankEnv, "/:id", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/:id", BlankInput>
.text(`book $
(parameter) c: Context<BlankEnv, "/:id", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`book ${string}`, StatusCode>(text: `book ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/:id", BlankInput>
.param('id')}`))
(property) Context<BlankEnv, "/:id", BlankInput>.req: HonoRequest<"/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
api
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.get('/',
const api: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"this is API", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('this is API'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
api
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"this is API", StatusCode>(text: "this is API", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.route('/book',
const api: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/book", BlankEnv, BlankSchema, "/">(path: "/book", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
book)app
const book: Hono<BlankEnv, BlankSchema, "/">
.get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"root", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('root'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"root", StatusCode>(text: "root", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"root", StatusCode, "text"> (+1 overload)
.route('/v2',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/v2", BlankEnv, BlankSchema, "/">(path: "/v2", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api)it('Should return 200 response - GET /', async () => { const res = await
const api: Hono<BlankEnv, BlankSchema, "/">
app
const res: Response
.request('http://localhost/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('root')
const res: Response
}) it('Should return 200 response - GET /v2', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/v2')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('this is API')
const res: Response
}) it('Should return 200 response - GET /v2/book', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/v2/book')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('list books')
const res: Response
}) it('Should return 200 response - GET /v2/book/123', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('http://localhost/v2/book/123')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('book 123')
const res: Response
}) }) describe('onError', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const sub = newoptions
— Optional configuration options for the Hono instance.Hono()
const sub: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
if (c
(parameter) next: () => Promise<void>
.req
(parameter) c: Context<BlankEnv, "*", {}>
.query('app-error')) {
(property) Context<BlankEnv, "*", {}>.req: HonoRequest<"*", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"*", unknown>.query(key: string): string | undefined (+1 overload)
.query()
can get querystring parameters.@see — 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() }) ```
throw new Error('This is Error')} }) app
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.onError(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('onError by app', 500)
(parameter) c: Context<BlankEnv, any, {}>
}) sub
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"onError by app", 500>(text: "onError by app", status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"onError by app", 500, "text"> (+1 overload)
.get('/posts/:id', async
const sub: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id", "/posts/:id", HandlerResponse<any>, BlankInput, BlankEnv>(path: "/posts/:id", handler: H<BlankEnv, "/posts/:id", BlankInput, HandlerResponse<...>>) => Hono<...> (+22 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
c
(parameter) next: Next
.header('handler-chain', '1')
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
await next()
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
}) sub
(parameter) next: () => Promise<void>
.get('/posts/:id',
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id", "/posts/:id", Response & TypedResponse<`post: ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/posts/:id", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.text(`post: $
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`post: ${string}`, StatusCode>(text: `post: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.param('id')}`)
(property) Context<BlankEnv, "/posts/:id", BlankInput>.req: HonoRequest<"/posts/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) sub
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.get('/error', () => {
const sub: Hono<BlankEnv, BlankSchema, "/">
throw new Error('This is Error')
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/error", "/error", never, BlankInput, BlankEnv>(path: "/error", handler: H<BlankEnv, "/error", BlankInput, never>) => Hono<BlankEnv, { ...; }, "/"> (+22 overloads)
}) sub
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.onError(
const sub: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('onError by sub', 500)
(parameter) c: Context<BlankEnv, any, {}>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"onError by sub", 500>(text: "onError by sub", status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"onError by sub", 500, "text"> (+1 overload)
.route('/sub',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/sub", BlankEnv, BlankSchema, "/">(path: "/sub", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
sub)it('GET /posts/123 for sub', async () => { const res = await
const sub: Hono<BlankEnv, BlankSchema, "/">
app
const res: Response
.request('https://example.com/sub/posts/123')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('handler-chain')).toBe('1')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('post: 123')
const res: Response
}) it('should be handled by app', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('https://example.com/sub/ok?app-error=1')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('onError by app')
const res: Response
}) it('should be handled by sub', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('https://example.com/sub/error')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('onError by sub')
const res: Response
}) }) describe('onError for a single handler', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const sub = newoptions
— Optional configuration options for the Hono instance.Hono()
const sub: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
suboptions
— Optional configuration options for the Hono instance..get('/ok',
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/ok", "/ok", Response & TypedResponse<"OK", StatusCode, "text">, BlankInput, BlankEnv>(path: "/ok", handler: H<BlankEnv, "/ok", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/ok", BlankInput>
.text('OK'))
(parameter) c: Context<BlankEnv, "/ok", BlankInput>
sub
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"OK", StatusCode>(text: "OK", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"OK", StatusCode, "text"> (+1 overload)
.get('/error', () => {
const sub: Hono<BlankEnv, BlankSchema, "/">
throw new Error('This is Error')
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/error", "/error", never, BlankInput, BlankEnv>(path: "/error", handler: H<BlankEnv, "/error", BlankInput, never>) => Hono<BlankEnv, { ...; }, "/"> (+22 overloads)
}) sub
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
.onError(
const sub: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('onError by sub', 500)
(parameter) c: Context<BlankEnv, any, {}>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"onError by sub", 500>(text: "onError by sub", status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"onError by sub", 500, "text"> (+1 overload)
.route('/sub',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/sub", BlankEnv, BlankSchema, "/">(path: "/sub", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
sub)it('ok', async () => { const res = await
const sub: Hono<BlankEnv, BlankSchema, "/">
app
const res: Response
.request('https://example.com/sub/ok')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
}) it('error', async () => { const res = await
(property) Response.status: number
MDN Referenceapp
const res: Response
.request('https://example.com/sub/error')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('onError by sub')
const res: Response
}) }) describe('notFound', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const sub = newoptions
— Optional configuration options for the Hono instance.Hono()
const sub: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/explicit-404', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/explicit-404", "/explicit-404", HandlerResponse<any>, BlankInput, BlankEnv>(path: "/explicit-404", handler: H<BlankEnv, "/explicit-404", BlankInput, HandlerResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/explicit-404", BlankInput>
.header('explicit', '1')
(parameter) c: Context<BlankEnv, "/explicit-404", BlankInput>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.notFound(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.notFound: (handler: NotFoundHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
(c) => {
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('404 Not Found by app', 404)
(parameter) c: Context<BlankEnv, any, {}>
}) sub
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"404 Not Found by app", 404>(text: "404 Not Found by app", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"404 Not Found by app", 404, "text"> (+1 overload)
.get('/ok',
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/ok", "/ok", Response & TypedResponse<"ok", StatusCode, "text">, BlankInput, BlankEnv>(path: "/ok", handler: H<BlankEnv, "/ok", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/ok", BlankInput>
.text('ok')
(parameter) c: Context<BlankEnv, "/ok", BlankInput>
}) sub
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"ok", StatusCode>(text: "ok", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"ok", StatusCode, "text"> (+1 overload)
.get('/explicit-404', async
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/explicit-404", "/explicit-404", HandlerResponse<any>, BlankInput, BlankEnv>(path: "/explicit-404", handler: H<BlankEnv, "/explicit-404", BlankInput, HandlerResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/explicit-404", BlankInput>
.header('explicit', '1')
(parameter) c: Context<BlankEnv, "/explicit-404", BlankInput>
}) sub
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.notFound(
const sub: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.notFound: (handler: NotFoundHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
(c) => {
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('404 Not Found by sub', 404)
(parameter) c: Context<BlankEnv, any, {}>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"404 Not Found by sub", 404>(text: "404 Not Found by sub", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"404 Not Found by sub", 404, "text"> (+1 overload)
.route('/sub',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/sub", BlankEnv, BlankSchema, "/">(path: "/sub", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
sub)it('/explicit-404 should be handled on app', async () => { const res = await
const sub: Hono<BlankEnv, BlankSchema, "/">
app
const res: Response
.request('https://example.com/explicit-404')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('explicit')).toBe('1')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('404 Not Found by app')
const res: Response
}) it('/sub/explicit-404 should be handled on app', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('https://example.com/sub/explicit-404')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('explicit')).toBe('1')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('404 Not Found by app')
const res: Response
}) it('/implicit-404 should be handled by app', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('https://example.com/implicit-404')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('explicit')).toBe(null)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('404 Not Found by app')
const res: Response
}) it('/sub/implicit-404 should be handled by sub', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('https://example.com/sub/implicit-404')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('explicit')).toBe(null)
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('404 Not Found by app')
const res: Response
}) }) }) describe('Using other methods with `app.on`', () => { it('Should handle PURGE method with RegExpRouter', async () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono({
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
router: newoptions
— Optional configuration options for the Hono instance.
(property) router?: Router<[H, RouterRoute]> | undefined
router
option specifices which router to use.@see — https://hono.dev/docs/api/hono#router-option
@example
RegExpRouter() })
ts const app = new Hono({ router: new RegExpRouter() })
app
(alias) new RegExpRouter<[H, RouterRoute]>(): RegExpRouter<[H, RouterRoute]> import RegExpRouter
.on('PURGE', '/purge',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.on: OnHandlerInterface <"PURGE", "/purge", "/purge", Response & TypedResponse<"Accepted", 202, "text">, BlankInput, BlankEnv>(method: "PURGE", path: "/purge", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/purge", BlankInput>
.text('Accepted', 202))
(parameter) c: Context<BlankEnv, "/purge", BlankInput>
const req = new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Accepted", 202>(text: "Accepted", status?: 202 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Accepted", 202, "text"> (+1 overload)
Request('http://localhost/purge', {
const req: Request
method: 'PURGE',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.}) const res = await
(property) RequestInit.method?: string | undefined
A string to set request's method.app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(202)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Accepted')
const res: Response
}) it('Should handle PURGE method with TrieRouter', async () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono({
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
router: newoptions
— Optional configuration options for the Hono instance.
(property) router?: Router<[H, RouterRoute]> | undefined
router
option specifices which router to use.@see — https://hono.dev/docs/api/hono#router-option
@example
TrieRouter() })
ts const app = new Hono({ router: new RegExpRouter() })
app
(alias) new TrieRouter<[H, RouterRoute]>(): TrieRouter<[H, RouterRoute]> import TrieRouter
.on('PURGE', '/purge',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.on: OnHandlerInterface <"PURGE", "/purge", "/purge", Response & TypedResponse<"Accepted", 202, "text">, BlankInput, BlankEnv>(method: "PURGE", path: "/purge", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/purge", BlankInput>
.text('Accepted', 202))
(parameter) c: Context<BlankEnv, "/purge", BlankInput>
const req = new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Accepted", 202>(text: "Accepted", status?: 202 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Accepted", 202, "text"> (+1 overload)
Request('http://localhost/purge', {
const req: Request
method: 'PURGE',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.}) const res = await
(property) RequestInit.method?: string | undefined
A string to set request's method.app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(202)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Accepted')
const res: Response
}) }) describe('Multiple methods with `app.on`', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..on(['PUT', 'DELETE'], '/posts/:id',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.on: OnHandlerInterface <string[], "/posts/:id", "/posts/:id", JSONRespondReturn<{ postId: string; method: string; }, StatusCode>, BlankInput, BlankEnv>(methods: string[], path: "/posts/:id", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
postId:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ postId: string; method: string; }, StatusCode>(object: { postId: string; method: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
c
(property) postId: string
.req
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.param('id'),
(property) Context<BlankEnv, "/posts/:id", BlankInput>.req: HonoRequest<"/posts/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
method:
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
c
(property) method: string
.req
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.method,
(property) Context<BlankEnv, "/posts/:id", BlankInput>.req: HonoRequest<"/posts/:id", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.method: string
.method()
can get the method name of the request.@see — https://hono.dev/docs/api/request#method
@example
}) }) it('Should return 200 with PUT', async () => { const req = new
ts app.get('/about/me', (c) => { const method = c.req.method // `GET` })
Request('http://localhost/posts/123', {
const req: Request
method: 'PUT',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.}) const res = await
(property) RequestInit.method?: string | undefined
A string to set request's method.app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
postId: '123',
(method) Body.json(): Promise<any>
MDN Referencemethod: 'PUT',
(property) postId: string
}) }) it('Should return 200 with DELETE', async () => { const req = new
(property) method: string
Request('http://localhost/posts/123', {
const req: Request
method: 'DELETE',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.}) const res = await
(property) RequestInit.method?: string | undefined
A string to set request's method.app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
postId: '123',
(method) Body.json(): Promise<any>
MDN Referencemethod: 'DELETE',
(property) postId: string
}) }) it('Should return 404 with POST', async () => { const req = new
(property) method: string
Request('http://localhost/posts/123', {
const req: Request
method: 'POST',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.}) const res = await
(property) RequestInit.method?: string | undefined
A string to set request's method.app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(404)
const res: Response
}) }) describe('Multiple paths with one handler', () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const paths = ['/hello', '/ja/hello', '/en/hello']options
— Optional configuration options for the Hono instance.app
const paths: string[]
.on('GET',
const app: Hono<BlankEnv, BlankSchema, "/">
paths,
(property) Hono<BlankEnv, BlankSchema, "/">.on: OnHandlerInterface <BlankInput, JSONRespondReturn<{ path: string; routePath: string; }, StatusCode>>(methods: string | string[], paths: string[], ...handlers: H<...>[]) => Hono<...> (+22 overloads)
(c) => {
const paths: string[]
return c
(parameter) c: Context<BlankEnv, any, BlankInput>
.json({
(parameter) c: Context<BlankEnv, any, BlankInput>
path:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ path: string; routePath: string; }, StatusCode>(object: { path: string; routePath: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
c
(property) path: string
.req
(parameter) c: Context<BlankEnv, any, BlankInput>
.path,
(property) Context<BlankEnv, any, BlankInput>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.path: string
.path
can get the pathname of the request.@see — https://hono.dev/docs/api/request#path
@example
routePath:
ts app.get('/about/me', (c) => { const pathname = c.req.path // `/about/me` })
c
(property) routePath: string
.req
(parameter) c: Context<BlankEnv, any, BlankInput>
.routePath,
(property) Context<BlankEnv, any, BlankInput>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.routePath: string
routePath()
can retrieve the path registered within the handler@see — https://hono.dev/docs/api/request#routepath
@example
}) }) it('Should handle multiple paths', async () => { paths
ts app.get('/posts/:id', (c) => { return c.json({ path: c.req.routePath }) })
.map(async
const paths: string[]
(method) Array<string>.map<Promise<void>>(callbackfn: (value: string, index: number, array: string[]) => Promise<void>, thisArg?: any): Promise<void>[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(path) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.const res = await
(parameter) path: string
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(path)expect(res
(parameter) path: string
.status).toBe(200)
const res: Response
const data = await
(property) Response.status: number
MDN Referenceres
const data: any
.json()
const res: Response
expect(data).toEqual({
(method) Body.json(): Promise<any>
MDN Referencepath,
const data: any
routePath:
(property) path: string
path,
(property) routePath: string
}) }) }) }) describe('Multiple handler', () => { describe('handler + handler', () => { const app = new
(parameter) path: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/posts/:id',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id", "/posts/:id", Response & TypedResponse<`id is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/posts/:id", handler: H<...>) => Hono<...> (+22 overloads)
const id =
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
c
const id: string
.req
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.param('id')
(property) Context<BlankEnv, "/posts/:id", BlankInput>.req: HonoRequest<"/posts/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.header('foo', 'bar')
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
return c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.text(`id is $
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
{id}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id is ${string}`, StatusCode>(text: `id is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) app
const id: string
.get('/:type/:id',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/:type/:id", "/:type/:id", Response & TypedResponse<"foo", StatusCode, "text">, BlankInput, BlankEnv>(path: "/:type/:id", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/:type/:id", BlankInput>
.status(404)
(parameter) c: Context<BlankEnv, "/:type/:id", BlankInput>
c
(property) Context<BlankEnv, "/:type/:id", BlankInput>.status: (status: StatusCode) => void
.header('foo2', 'bar2')
(parameter) c: Context<BlankEnv, "/:type/:id", BlankInput>
return c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.text('foo')
(parameter) c: Context<BlankEnv, "/:type/:id", BlankInput>
}) it('Should return response from `specialized` route', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"foo", StatusCode>(text: "foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/posts/123')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id is 123')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('foo')).toBe('bar')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('foo2')).toBeNull()
(property) Response.headers: Headers
MDN Reference}) }) describe('Duplicate param name', () => { describe('basic', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/:type/:url',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/:type/:url", "/:type/:url", Response & TypedResponse<`type: ${string}, url: ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/:type/:url", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/:type/:url", BlankInput>
.text(`type: $
(parameter) c: Context<BlankEnv, "/:type/:url", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`type: ${string}, url: ${string}`, StatusCode>(text: `type: ${string}, url: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/:type/:url", BlankInput>
.param('type')}, url: $
(property) Context<BlankEnv, "/:type/:url", BlankInput>.req: HonoRequest<"/:type/:url", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:type/:url", unknown>.param<"type">(key: "type"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
{c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.req
(parameter) c: Context<BlankEnv, "/:type/:url", BlankInput>
.param('url')}`)
(property) Context<BlankEnv, "/:type/:url", BlankInput>.req: HonoRequest<"/:type/:url", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:type/:url", unknown>.param<"url">(key: "url"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) app
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.get('/foo/:type/:url',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo/:type/:url", "/foo/:type/:url", Response & TypedResponse<`foo type: ${string}, url: ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/foo/:type/:url", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/foo/:type/:url", BlankInput>
.text(`foo type: $
(parameter) c: Context<BlankEnv, "/foo/:type/:url", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`foo type: ${string}, url: ${string}`, StatusCode>(text: `foo type: ${string}, url: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/foo/:type/:url", BlankInput>
.param('type')}, url: $
(property) Context<BlankEnv, "/foo/:type/:url", BlankInput>.req: HonoRequest<"/foo/:type/:url", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/foo/:type/:url", unknown>.param<"type">(key: "type"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
{c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.req
(parameter) c: Context<BlankEnv, "/foo/:type/:url", BlankInput>
.param('url')}`)
(property) Context<BlankEnv, "/foo/:type/:url", BlankInput>.req: HonoRequest<"/foo/:type/:url", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/foo/:type/:url", unknown>.param<"url">(key: "url"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) it('Should return a correct param - GET /car/good-car', async () => { const res = await
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
app
const res: Response
.request('/car/good-car')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.ok).toBe(true)
const res: Response
expect(await res
(property) Response.ok: boolean
MDN Reference.text()).toBe('type: car, url: good-car')
const res: Response
}) it('Should return a correct param - GET /foo/food/good-food', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/foo/food/good-food')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.ok).toBe(true)
const res: Response
expect(await res
(property) Response.ok: boolean
MDN Reference.text()).toBe('foo type: food, url: good-food')
const res: Response
}) }) describe('self', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/:id/:id',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/:id/:id", "/:id/:id", Response & TypedResponse<`id is ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/:id/:id", handler: H<...>) => Hono<...> (+22 overloads)
const id =
(parameter) c: Context<BlankEnv, "/:id/:id", BlankInput>
c
const id: string
.req
(parameter) c: Context<BlankEnv, "/:id/:id", BlankInput>
.param('id')
(property) Context<BlankEnv, "/:id/:id", BlankInput>.req: HonoRequest<"/:id/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:id/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`id is $
(parameter) c: Context<BlankEnv, "/:id/:id", BlankInput>
{id}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id is ${string}`, StatusCode>(text: `id is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) it('Should return 123 - GET /123/456', async () => { const res = await
const id: string
app
const res: Response
.request('/123/456')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id is 123')
const res: Response
}) }) describe('hierarchy', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/posts/:id/comments/:comment_id',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id/comments/:comment_id", "/posts/:id/comments/:comment_id", Response & TypedResponse<`post: ${string}, comment: ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/posts/:id/comments/:comment_id", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/posts/:id/comments/:comment_id", BlankInput>
.text(`post: $
(parameter) c: Context<BlankEnv, "/posts/:id/comments/:comment_id", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`post: ${string}, comment: ${string}`, StatusCode>(text: `post: ${string}, comment: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/posts/:id/comments/:comment_id", BlankInput>
.param('id')}, comment: $
(property) Context<BlankEnv, "/posts/:id/comments/:comment_id", BlankInput>.req: HonoRequest<"/posts/:id/comments/:comment_id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id/comments/:comment_id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
{c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.req
(parameter) c: Context<BlankEnv, "/posts/:id/comments/:comment_id", BlankInput>
.param('comment_id')}`)
(property) Context<BlankEnv, "/posts/:id/comments/:comment_id", BlankInput>.req: HonoRequest<"/posts/:id/comments/:comment_id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id/comments/:comment_id", unknown>.param<"comment_id">(key: "comment_id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) app
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.get('/posts/:id',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id", "/posts/:id", Response & TypedResponse<`post: ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/posts/:id", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.text(`post: $
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`post: ${string}`, StatusCode>(text: `post: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.param('id')}`)
(property) Context<BlankEnv, "/posts/:id", BlankInput>.req: HonoRequest<"/posts/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) it('Should return a correct param - GET /posts/123/comments/456', async () => { const res = await
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
app
const res: Response
.request('/posts/123/comments/456')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('post: 123, comment: 456')
const res: Response
}) it('Should return a correct param - GET /posts/789', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/posts/789')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('post: 789')
const res: Response
}) }) describe('different regular expression', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/:id/:action{create|update}',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/:id/:action{create|update}", "/:id/:action{create|update}", Response & TypedResponse<`id: ${string}, action: ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/:id/:action{create|update}", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/:id/:action{create|update}", BlankInput>
.text(`id: $
(parameter) c: Context<BlankEnv, "/:id/:action{create|update}", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id: ${string}, action: ${string}`, StatusCode>(text: `id: ${string}, action: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/:id/:action{create|update}", BlankInput>
.param('id')}, action: $
(property) Context<BlankEnv, "/:id/:action{create|update}", BlankInput>.req: HonoRequest<"/:id/:action{create|update}", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:id/:action{create|update}", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
{c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.req
(parameter) c: Context<BlankEnv, "/:id/:action{create|update}", BlankInput>
.param('action')}`)
(property) Context<BlankEnv, "/:id/:action{create|update}", BlankInput>.req: HonoRequest<"/:id/:action{create|update}", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:id/:action{create|update}", unknown>.param<"action">(key: "action"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) app
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.get('/:id/:action{delete}',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/:id/:action{delete}", "/:id/:action{delete}", Response & TypedResponse<`id: ${string}, action: ${string}`, StatusCode, "text">, BlankInput, BlankEnv>(path: "/:id/:action{delete}", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/:id/:action{delete}", BlankInput>
.text(`id: $
(parameter) c: Context<BlankEnv, "/:id/:action{delete}", BlankInput>
{c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id: ${string}, action: ${string}`, StatusCode>(text: `id: ${string}, action: ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/:id/:action{delete}", BlankInput>
.param('id')}, action: $
(property) Context<BlankEnv, "/:id/:action{delete}", BlankInput>.req: HonoRequest<"/:id/:action{delete}", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:id/:action{delete}", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
{c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.req
(parameter) c: Context<BlankEnv, "/:id/:action{delete}", BlankInput>
.param('action')}`)
(property) Context<BlankEnv, "/:id/:action{delete}", BlankInput>.req: HonoRequest<"/:id/:action{delete}", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/:id/:action{delete}", unknown>.param<"action">(key: "action"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
}) it('Should return a correct param - GET /123/create', async () => { const res = await
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
app
const res: Response
.request('/123/create')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id: 123, action: create')
const res: Response
}) it('Should return a correct param - GET /456/update', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/467/update')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id: 467, action: update')
const res: Response
}) it('Should return a correct param - GET /789/delete', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/789/delete')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id: 789, action: delete')
const res: Response
}) }) }) }) describe('Multiple handler - async', () => { describe('handler + handler', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/posts/:id', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id", "/posts/:id", Promise<Response & TypedResponse<`id is ${string}`, StatusCode, "text">>, BlankInput, BlankEnv>(path: "/posts/:id", handler: H<...>) => Hono<...> (+22 overloads)
await new Promise(
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
var Promise: PromiseConstructor new <unknown>(executor: (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void) => Promise<unknown>
Creates a new Promise.@param
(resolve) =>executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.setTimeout
(parameter) resolve: (value: unknown) => void
(resolve, 1))
function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
MDN Referencec
(parameter) resolve: (value: unknown) => void
.header('foo2', 'bar2')
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
const id =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
c
const id: string
.req
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
.param('id')
(property) Context<BlankEnv, "/posts/:id", BlankInput>.req: HonoRequest<"/posts/:id", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/posts/:id", unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`id is $
(parameter) c: Context<BlankEnv, "/posts/:id", BlankInput>
{id}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`id is ${string}`, StatusCode>(text: `id is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
}) app
const id: string
.get('/:type/:id', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/:type/:id", "/:type/:id", Promise<Response & TypedResponse<"foo", StatusCode, "text">>, BlankInput, BlankEnv>(path: "/:type/:id", handler: H<...>) => Hono<...> (+22 overloads)
await new Promise(
(parameter) c: Context<BlankEnv, "/:type/:id", BlankInput>
var Promise: PromiseConstructor new <unknown>(executor: (resolve: (value: unknown) => void, reject: (reason?: any) => void) => void) => Promise<unknown>
Creates a new Promise.@param
(resolve) =>executor
A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error.setTimeout
(parameter) resolve: (value: unknown) => void
(resolve, 1))
function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
MDN Referencec
(parameter) resolve: (value: unknown) => void
.header('foo', 'bar')
(parameter) c: Context<BlankEnv, "/:type/:id", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.status(404)
(parameter) c: Context<BlankEnv, "/:type/:id", BlankInput>
return c
(property) Context<BlankEnv, "/:type/:id", BlankInput>.status: (status: StatusCode) => void
.text('foo')
(parameter) c: Context<BlankEnv, "/:type/:id", BlankInput>
}) it('Should return response from `specialized` route', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"foo", StatusCode>(text: "foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/posts/123')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('id is 123')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('foo')).toBeNull()
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('foo2')).toBe('bar2')
(property) Response.headers: Headers
MDN Reference}) }) }) describe('Lack returning response with a single handler', () => { const app = new
(method) Headers.get(name: string): string | null
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
// @ts-expect-error it should return Response to type it appoptions
— Optional configuration options for the Hono instance..get('/sync', () => {})
const app: Hono<BlankEnv, BlankSchema, "/">
app
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", BlankInput, BlankInput, HandlerResponse<any>, BlankEnv, {}>(handlers_0: H<BlankEnv, "/", BlankInput, any>, handlers_1: H<...>) => Hono<...> (+22 overloads)
.get('/async', async () => {})
const app: Hono<BlankEnv, BlankSchema, "/">
it('Should return 404 response if lacking returning response', async () => { const res = await
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/async", "/async", HandlerResponse<any>, BlankInput, BlankEnv>(path: "/async", handler: H<BlankEnv, "/async", BlankInput, HandlerResponse<...>>) => Hono<...> (+22 overloads)
app
const res: Response
.request('/sync')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
}) it('Should return 404 response if lacking returning response in an async handler', async () => { const res = await
(property) Response.status: number
MDN Referenceapp
const res: Response
.request('/async')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
const res: Response
}) }) describe('Context is not finalized', () => { it('should throw error - lack `await next()`', async () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
// @ts-ignore appoptions
— Optional configuration options for the Hono instance..use('*', () => {})
const app: Hono<BlankEnv, BlankSchema, "/">
app
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <BlankEnv>(...handlers: MiddlewareHandler<BlankEnv, never, {}>[]) => Hono<{}, BlankSchema, "/"> (+20 overloads)
.get('/foo',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo", "/foo", Response & TypedResponse<"foo", StatusCode, "text">, BlankInput, BlankEnv>(path: "/foo", handler: H<BlankEnv, "/foo", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.text('foo')
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"foo", StatusCode>(text: "foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
.onError(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
return c
(parameter) c: Context<BlankEnv, any, {}>
.text
(parameter) c: Context<BlankEnv, any, {}>
(err
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, 500>(text: string, status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, 500, "text"> (+1 overload)
.message, 500)
(parameter) err: Error | HTTPResponseError
}) const res = await
(property) Error.message: string
app
const res: Response
.request('http://localhost/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toMatch(/^Context is not finalized/)
const res: Response
}) it('should throw error - lack `returning Response`', async () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(_c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) _c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
}) // @ts-ignore app
(parameter) next: () => Promise<void>
.get('/foo', () => {})
const app: Hono<BlankEnv, BlankSchema, "/">
app
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", BlankInput, BlankInput, HandlerResponse<any>, BlankEnv, {}>(handlers_0: H<BlankEnv, "/", BlankInput, any>, handlers_1: H<...>) => Hono<...> (+22 overloads)
.onError(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.onError: (handler: ErrorHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.onError()
handles an error and returns a customized Response.@see — https://hono.dev/docs/api/hono#error-handling
@param
handler
— request Handler for error@returns — changed Hono instance
@example
(err,
ts app.onError((err, c) => { console.error(`${err}`) return c.text('Custom Error Message', 500) })
c) => {
(parameter) err: Error | HTTPResponseError
return c
(parameter) c: Context<BlankEnv, any, {}>
.text
(parameter) c: Context<BlankEnv, any, {}>
(err
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, 500>(text: string, status?: 500 | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, 500, "text"> (+1 overload)
.message, 500)
(parameter) err: Error | HTTPResponseError
}) const res = await
(property) Error.message: string
app
const res: Response
.request('http://localhost/foo')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(500)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toMatch(/^Context is not finalized/)
const res: Response
}) }) describe('Parse Body', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..post('/json', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.post: HandlerInterface <"/json", "/json", Promise<JSONRespondReturn<{}, 200>>, BlankInput, BlankEnv>(path: "/json", handler: H<BlankEnv, "/json", BlankInput, Promise<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/json", BlankInput>
.json<{}, 200>(await
(parameter) c: Context<BlankEnv, "/json", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, 200>(object: {}, status?: 200 | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, 200> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/json", BlankInput>
.parseBody(), 200)
(property) Context<BlankEnv, "/json", BlankInput>.req: HonoRequest<"/json", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/json", unknown>.parseBody<Partial<ParseBodyOptions>, {}>(options?: Partial<ParseBodyOptions> | undefined): Promise<{}> (+1 overload)
.parseBody()
can parse Request body of typemultipart/form-data
orapplication/x-www-form-urlencoded
@see — https://hono.dev/docs/api/request#parsebody
@example
}) app
ts app.post('/entry', async (c) => { const body = await c.req.parseBody() })
.post('/form', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.post: HandlerInterface <"/form", "/form", Promise<JSONRespondReturn<{}, 200>>, BlankInput, BlankEnv>(path: "/form", handler: H<BlankEnv, "/form", BlankInput, Promise<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/form", BlankInput>
.json<{}, 200>(await
(parameter) c: Context<BlankEnv, "/form", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{}, 200>(object: {}, status?: 200 | undefined, headers?: HeaderRecord) => JSONRespondReturn<{}, 200> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/form", BlankInput>
.parseBody(), 200)
(property) Context<BlankEnv, "/form", BlankInput>.req: HonoRequest<"/form", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/form", unknown>.parseBody<Partial<ParseBodyOptions>, {}>(options?: Partial<ParseBodyOptions> | undefined): Promise<{}> (+1 overload)
.parseBody()
can parse Request body of typemultipart/form-data
orapplication/x-www-form-urlencoded
@see — https://hono.dev/docs/api/request#parsebody
@example
}) it('POST with JSON', async () => { const req = new
ts app.post('/entry', async (c) => { const body = await c.req.parseBody() })
Request('http://localhost/json', {
const req: Request
method: 'POST',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.body:
(property) RequestInit.method?: string | undefined
A string to set request's method.JSON
(property) RequestInit.body?: BodyInit | null | undefined
A BodyInit object or null to set request's body..stringify({
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
message: 'hello hono' }),space
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.headers: new
(property) message: string
Headers({ 'Content-Type': 'application/json' }),
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.}) const res = await
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res).not.toBeNull()
const req: Request
expect(res
const res: Response
.status).toBe(200)
const res: Response
}) it('POST with `multipart/form-data`', async () => { const formData = new
(property) Response.status: number
MDN ReferenceFormData()
const formData: FormData
formData
var FormData: new (form?: HTMLFormElement, submitter?: HTMLElement | null) => FormData
Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data"..append('message', 'hello')
const formData: FormData
const req = new
(method) FormData.append(name: string, value: string | Blob): void (+2 overloads)
MDN ReferenceRequest('https://localhost/form', {
const req: Request
method: 'POST',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.body:
(property) RequestInit.method?: string | undefined
A string to set request's method.formData,
(property) RequestInit.body?: BodyInit | null | undefined
A BodyInit object or null to set request's body.}) const res = await
const formData: FormData
app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res).not.toBeNull()
const req: Request
expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
message: 'hello' })
(method) Body.json(): Promise<any>
MDN Reference}) it('POST with `application/x-www-form-urlencoded`', async () => { const searchParam = new
(property) message: string
URLSearchParams()
const searchParam: URLSearchParams
searchParam
var URLSearchParams: new (init?: string[][] | Record<string, string> | string | URLSearchParams) => URLSearchParams
MDN Reference.append('message', 'hello')
const searchParam: URLSearchParams
const req = new
(method) URLSearchParams.append(name: string, value: string): void
Appends a specified key/value pair as a new search parameter.Request('https://localhost/form', {
const req: Request
method: 'POST',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.body:
(property) RequestInit.method?: string | undefined
A string to set request's method.searchParam,
(property) RequestInit.body?: BodyInit | null | undefined
A BodyInit object or null to set request's body.headers: {
const searchParam: URLSearchParams
'Content-Type': 'application/x-www-form-urlencoded', }, }) const res = await
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res).not.toBeNull()
const req: Request
expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
message: 'hello' })
(method) Body.json(): Promise<any>
MDN Reference}) }) describe('Both two middleware returning response', () => { it('Should return correct Content-Type`', async () => { const app = new
(property) message: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
return c
(parameter) next: () => Promise<void>
.html('Foo')
(parameter) c: Context<BlankEnv, "*", {}>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.html: HTMLRespond <"Foo">(html: "Foo", status?: StatusCode, headers?: HeaderRecord) => Response (+1 overload)
.get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"Bar", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('Bar')
(parameter) c: Context<BlankEnv, "/", BlankInput>
}) const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Bar", StatusCode>(text: "Bar", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Bar", StatusCode, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Bar')
const res: Response
expect(res
(method) Body.text(): Promise<string>
MDN Reference.headers
const res: Response
.get('Content-Type')).toMatch(/^text\/plain/)
(property) Response.headers: Headers
MDN Reference}) }) describe('Count of logger called', () => { // It will be added `2` each time the logger is called once. let count = 0
(method) Headers.get(name: string): string | null
MDN Referencelet log = ''
let count: number
const app = new
let log: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const logFn =options
— Optional configuration options for the Hono instance.(str: string) => {
const logFn: (str: string) => void
count++
(parameter) str: string
log =
let count: number
str
let log: string
} app
(parameter) str: string
.use('*',
const app: Hono<BlankEnv, BlankSchema, "/">
logger
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", any>(path: "*", handler: MiddlewareHandler<any, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
(alias) logger(fn?: PrintFunc): MiddlewareHandler import logger
Logger Middleware for Hono.@see — https://hono.dev/docs/middleware/builtin/logger
@param
fn
— Optional function for customized logging behavior.@returns — The middleware handler function.
@example
```ts const app = new Hono()app.use(logger()) app.get('/', (c) => c.text('Hello Hono!')) ```
(logFn))app
const logFn: (str: string) => void
.get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"foo", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('foo'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
it('Should be called two times', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"foo", StatusCode>(text: "foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/not-found')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(404)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('404 Not Found')
const res: Response
expect(count).toBe(2)
(method) Body.text(): Promise<string>
MDN Referenceexpect(log).toMatch(/404/)
let count: number
}) it('Should be called two times / Custom Not Found', async () => { app
let log: string
.notFound(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.notFound: (handler: NotFoundHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
(c) =>
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
c
(parameter) c: Context<BlankEnv, any, {}>
.text('Custom Not Found', 404))
(parameter) c: Context<BlankEnv, any, {}>
const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Custom Not Found", 404>(text: "Custom Not Found", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Custom Not Found", 404, "text"> (+1 overload)
app
const res: Response
.request('http://localhost/custom-not-found')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res).not.toBeNull()expect(res
const res: Response
.status).toBe(404)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Custom Not Found')
const res: Response
expect(count).toBe(4)
(method) Body.text(): Promise<string>
MDN Referenceexpect(log).toMatch(/404/)
let count: number
}) }) describe('Context set/get variables', () => { type Variables = {
let log: string
id: number
type Variables = { id: number; title: string; }
title: string
(property) id: number
} const app = new
(property) title: string
Hono<{
const app: Hono<{ Variables: Variables; }, BlankSchema, "/">
(alias) new Hono<{ Variables: Variables; }, BlankSchema, "/">(options?: HonoOptions<{ Variables: Variables; }>): Hono<{ Variables: Variables; }, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
Variables:options
— Optional configuration options for the Hono instance.Variables }>()
(property) Variables: Variables
it('Should set and get variables with correct types', async () => { app
type Variables = { id: number; title: string; }
.use('*', async
const app: Hono<{ Variables: Variables; }, BlankSchema, "/">
(c,
(property) Hono<{ Variables: Variables; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", { Variables: Variables; }>(path: "*", handler: MiddlewareHandler<{ Variables: Variables; }, "*", {}>) => Hono<{ Variables: Variables; }, { ...; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<{ Variables: Variables; }, "*", {}>
c
(parameter) next: Next
.set('id', 123)
(parameter) c: Context<{ Variables: Variables; }, "*", {}>
c
(property) Context<{ Variables: Variables; }, "*", {}>.set: Set <"id">(key: "id", value: number) => void (+1 overload)
.set('title', 'Hello')
(parameter) c: Context<{ Variables: Variables; }, "*", {}>
await next()
(property) Context<{ Variables: Variables; }, "*", {}>.set: Set <"title">(key: "title", value: string) => void (+1 overload)
}) app
(parameter) next: () => Promise<void>
.get('/',
const app: Hono<{ Variables: Variables; }, BlankSchema, "/">
(c) => {
(property) Hono<{ Variables: Variables; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<`${number} is ${string}`, StatusCode, "text">, BlankInput, { Variables: Variables; }>(path: "/", handler: H<...>) => Hono<...> (+22 overloads)
const id =
(parameter) c: Context<{ Variables: Variables; }, "/", BlankInput>
c
const id: number
.get('id')
(parameter) c: Context<{ Variables: Variables; }, "/", BlankInput>
const title =
(property) Context<{ Variables: Variables; }, "/", BlankInput>.get: Get <"id">(key: "id") => number (+1 overload)
c
const title: string
.get('title')
(parameter) c: Context<{ Variables: Variables; }, "/", BlankInput>
// type verifyID = Expect
(property) Context<{ Variables: Variables; }, "/", BlankInput>.get: Get <"title">(key: "title") => string (+1 overload)
> expectTypeOf(id).toEqualTypeOf() // type verifyTitle = Expect
const id: number
> expectTypeOf(title).toEqualTypeOf() return c
const title: string
.text(`$
(parameter) c: Context<{ Variables: Variables; }, "/", BlankInput>
{id} is $
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`${number} is ${string}`, StatusCode>(text: `${number} is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
{title}`)
const id: number
}) const res = await
const title: string
app
const res: Response
.request('http://localhost/')
const app: Hono<{ Variables: Variables; }, BlankSchema, "/">
(property) Hono<{ Variables: Variables; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('123 is Hello')
const res: Response
}) }) describe('Context binding variables', () => { type Bindings = {
(method) Body.text(): Promise<string>
MDN ReferenceUSER_ID: number
type Bindings = { USER_ID: number; USER_NAME: string; }
USER_NAME: string
(property) USER_ID: number
} const app = new
(property) USER_NAME: string
Hono<{
const app: Hono<{ Bindings: Bindings; }, BlankSchema, "/">
(alias) new Hono<{ Bindings: Bindings; }, BlankSchema, "/">(options?: HonoOptions<{ Bindings: Bindings; }>): Hono<{ Bindings: Bindings; }, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
Bindings:options
— Optional configuration options for the Hono instance.Bindings }>()
(property) Bindings: Bindings
it('Should get binding variables with correct types', async () => { app
type Bindings = { USER_ID: number; USER_NAME: string; }
.get('/',
const app: Hono<{ Bindings: Bindings; }, BlankSchema, "/">
(c) => {
(property) Hono<{ Bindings: Bindings; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"These are verified", StatusCode, "text">, BlankInput, { Bindings: Bindings; }>(path: "/", handler: H<...>) => Hono<...> (+22 overloads)
expectTypeOf(c
(parameter) c: Context<{ Bindings: Bindings; }, "/", BlankInput>
.env).toEqualTypeOf
(parameter) c: Context<{ Bindings: Bindings; }, "/", BlankInput>
(property) Context<{ Bindings: Bindings; }, "/", BlankInput>.env: Bindings
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
<Bindings>()
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
return c
type Bindings = { USER_ID: number; USER_NAME: string; }
.text('These are verified')
(parameter) c: Context<{ Bindings: Bindings; }, "/", BlankInput>
}) const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"These are verified", StatusCode>(text: "These are verified", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('http://localhost/')
const app: Hono<{ Bindings: Bindings; }, BlankSchema, "/">
(property) Hono<{ Bindings: Bindings; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | Bindings | undefined, 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
expect(res.status).toBe(200)
const res: Response
}) }) describe('Handler as variables', () => { const app = new
(property) Response.status: number
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
it('Should be typed correctly', async () => { const handler:options
— Optional configuration options for the Hono instance.Handler =
const handler: Handler
(c) => {
(alias) 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 import Handler
const id =
(parameter) c: Context<any, any, BlankInput>
c
const id: string
.req
(parameter) c: Context<any, any, BlankInput>
.param('id')
(property) Context<any, any, BlankInput>.req: HonoRequest<any, unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<any, unknown>.param<"id">(key: "id"): string (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
return c
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
.text(`Post id is $
(parameter) c: Context<any, any, BlankInput>
{id}`)
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <`Post id is ${string}`, StatusCode>(text: `Post id is ${string}`, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
} app
const id: string
.get('/posts/:id',
const app: Hono<BlankEnv, BlankSchema, "/">
handler)
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/posts/:id", any, any, BlankInput, any>(path: "/posts/:id", handler: H<any, any, BlankInput, any>) => Hono<BlankEnv, { "/posts/:id": { $get: { input: { ...; }; output: {}; outputFormat: ResponseFormat; status: StatusCode; }; }; }, "/"> (+22 overloads)
const res = await
const handler: Handler
app
const res: Response
.request('http://localhost/posts/123')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Post id is 123')
const res: Response
}) }) describe('json', () => { const api = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const api: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
apioptions
— Optional configuration options for the Hono instance..get('/message',
const api: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/message", "/message", JSONRespondReturn<{ message: string; }, StatusCode>, BlankInput, BlankEnv>(path: "/message", handler: H<BlankEnv, "/message", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/message", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/message", BlankInput>
message: 'Hello',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ message: string; }, StatusCode>(object: { message: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ message: string; }, StatusCode> (+1 overload)
}) }) api
(property) message: string
.get('/message-async', async
const api: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/message-async", "/message-async", Promise<JSONRespondReturn<{ message: string; }, StatusCode>>, BlankInput, BlankEnv>(path: "/message-async", handler: H<...>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/message-async", BlankInput>
.json({
(parameter) c: Context<BlankEnv, "/message-async", BlankInput>
message: 'Hello',
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ message: string; }, StatusCode>(object: { message: string; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<{ message: string; }, StatusCode> (+1 overload)
}) }) describe('Single handler', () => { const app = new
(property) message: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..route('/api',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", BlankEnv, BlankSchema, "/">(path: "/api", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api)it('Should return 200 response', async () => { const res = await
const api: Hono<BlankEnv, BlankSchema, "/">
app
const res: Response
.request('http://localhost/api/message')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
message: 'Hello',
(method) Body.json(): Promise<any>
MDN Reference}) }) it('Should return 200 response - with async', async () => { const res = await
(property) message: string
app
const res: Response
.request('http://localhost/api/message-async')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
message: 'Hello',
(method) Body.json(): Promise<any>
MDN Reference}) }) }) describe('With middleware', () => { const app = new
(property) message: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(_c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) _c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
}) app
(parameter) next: () => Promise<void>
.route('/api',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.route<"/api", BlankEnv, BlankSchema, "/">(path: "/api", app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
api)it('Should return 200 response', async () => { const res = await
const api: Hono<BlankEnv, BlankSchema, "/">
app
const res: Response
.request('http://localhost/api/message')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
message: 'Hello',
(method) Body.json(): Promise<any>
MDN Reference}) }) it('Should return 200 response - with async', async () => { const res = await
(property) message: string
app
const res: Response
.request('http://localhost/api/message-async')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
message: 'Hello',
(method) Body.json(): Promise<any>
MDN Reference}) }) }) }) describe('Optional parameters', () => { const app = new
(property) message: string
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/api/:version/animal/:type?',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/api/:version/animal/:type?", "/api/:version/animal/:type?", JSONRespondReturn<{ type: string | undefined; }, StatusCode>, BlankInput, BlankEnv>(path: "/api/:version/animal/:type?", handler: H<...>) => Hono<...> (+22 overloads)
const type1 =
(parameter) c: Context<BlankEnv, "/api/:version/animal/:type?", BlankInput>
c
const type1: string | undefined
.req
(parameter) c: Context<BlankEnv, "/api/:version/animal/:type?", BlankInput>
.param('type')
(property) Context<BlankEnv, "/api/:version/animal/:type?", BlankInput>.req: HonoRequest<"/api/:version/animal/:type?", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/api/:version/animal/:type?", unknown>.param<"type">(key: "type"): string | undefined (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
expectTypeOf(type1).toEqualTypeOf
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
() const { type,
const type1: string | undefined
version } =
const type: string | undefined
c
const version: string
.req
(parameter) c: Context<BlankEnv, "/api/:version/animal/:type?", BlankInput>
.param()
(property) Context<BlankEnv, "/api/:version/animal/:type?", BlankInput>.req: HonoRequest<"/api/:version/animal/:type?", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/api/:version/animal/:type?", unknown>.param<"/api/:version/animal/:type?">(): { version: string; type: string | undefined; } (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
expectTypeOf(version).toEqualTypeOf
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
() expectTypeOf(type).toEqualTypeOf
const version: string
() return c
const type: string | undefined
.json({
(parameter) c: Context<BlankEnv, "/api/:version/animal/:type?", BlankInput>
type:
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <{ type: string | undefined; }, StatusCode>(object: { type: string | undefined; }, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
type,
(property) type: string | undefined
}) }) it('Should match with an optional parameter', async () => { const res = await
const type: string | undefined
app
const res: Response
.request('http://localhost/api/v1/animal/bird')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
type: 'bird',
(method) Body.json(): Promise<any>
MDN Reference}) }) it('Should match without an optional parameter', async () => { const res = await
(property) type: string
app
const res: Response
.request('http://localhost/api/v1/animal')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
type: undefined,
(method) Body.json(): Promise<any>
MDN Reference}) }) it('Should have a correct type with an optional parameter in a regexp path', async () => { const app = new
(property) type: undefined
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/url/:url{.*}?',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/url/:url{.*}?", "/url/:url{.*}?", JSONRespondReturn<0, StatusCode>, BlankInput, BlankEnv>(path: "/url/:url{.*}?", handler: H<...>) => Hono<...> (+22 overloads)
const url =
(parameter) c: Context<BlankEnv, "/url/:url{.*}?", BlankInput>
c
const url: string | undefined
.req
(parameter) c: Context<BlankEnv, "/url/:url{.*}?", BlankInput>
.param('url')
(property) Context<BlankEnv, "/url/:url{.*}?", BlankInput>.req: HonoRequest<"/url/:url{.*}?", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/url/:url{.*}?", unknown>.param<"url">(key: "url"): string | undefined (+3 overloads)
.req.param()
gets the path parameters.@see — https://hono.dev/docs/api/routing#path-parameter
@example
expectTypeOf(url).toEqualTypeOf
ts const name = c.req.param('name') // or all parameters at once const { id, comment_id } = c.req.param()
() return c
const url: string | undefined
.json(0)
(parameter) c: Context<BlankEnv, "/url/:url{.*}?", BlankInput>
}) }) }) describe('app.mount()', () => { describe('Basic', () => { const anotherApp =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <0, StatusCode>(object: 0, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<0, StatusCode> (+1 overload)
(req:
const anotherApp: (req: Request, ...params: unknown[]) => Response
Request, ..
(parameter) req: Request
.params: unknown[]) => {
interface Request
This Fetch API interface represents a resource request.const path =
(parameter) params: unknown[]
getPath
const path: string
(req)
(alias) getPath(request: Request): string import getPath
if (path === '/') {
(parameter) req: Request
return new Response('AnotherApp')
const path: string
} if (path === '/hello') {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.return new Response('Hello from AnotherApp')
const path: string
} if (path === '/header') {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.const message =
const path: string
req
const message: string | null
.headers
(parameter) req: Request
.get('x-message')
(property) Request.headers: Headers
Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.return new Response
(method) Headers.get(name: string): string | null
MDN Reference(message)
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.} if (path === '/with-query') {
const message: string | null
const queryStrings = new
const path: string
URL
const queryStrings: string
(req
var URL: new (url: string | URL, base?: string | URL) => URL
The URL interface represents an object providing static methods used for creating object URLs..url)
(parameter) req: Request
.searchParams
(property) Request.url: string
Returns the URL of request as a string..toString()
(property) URL.searchParams: URLSearchParams
MDN Referencereturn new Response
(method) URLSearchParams.toString(): string
Returns a string containing a query string suitable for use in a URL. Does not include the question mark.(queryStrings)
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.} if (path == '/with-params') {
const queryStrings: string
return new Response(
const path: string
JSON
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..stringify({
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
params,space
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.}), { headers: {
(property) params: unknown[]
'Content-Type': 'application.json', }, } ) } if (path === '/undefined') {
(property) ResponseInit.headers?: HeadersInit | undefined
return undefined as unknown as Response
const path: string
} return new Response('Not Found from AnotherApp', {
interface Response
This Fetch API interface represents the response to a request.status: 404,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.}) } const app = new
(property) ResponseInit.status?: number | undefined
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..use('*', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", BlankEnv>(path: "*", handler: MiddlewareHandler<BlankEnv, "*", {}>) => Hono<{}, { "*": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "*", {}>
await next()
(parameter) next: Next
c
(parameter) next: () => Promise<void>
.header('x-message', 'Foo')
(parameter) c: Context<BlankEnv, "*", {}>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.get('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"Hono", StatusCode, "text">, BlankInput, BlankEnv>(path: "/", handler: H<BlankEnv, "/", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/", BlankInput>
.text('Hono'))
(parameter) c: Context<BlankEnv, "/", BlankInput>
app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Hono", StatusCode>(text: "Hono", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Hono", StatusCode, "text"> (+1 overload)
.notFound(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.notFound: (handler: NotFoundHandler<BlankEnv>) => Hono<BlankEnv, BlankSchema, "/">
.notFound()
allows you to customize a Not Found Response.@see — https://hono.dev/docs/api/hono#not-found
@param
handler
— request handler for not-found@returns — changed Hono instance
@example
(c) => {
ts app.notFound((c) => { return c.text('Custom 404 Message', 404) })
return c
(parameter) c: Context<BlankEnv, any, {}>
.text('Not Found from App', 404)
(parameter) c: Context<BlankEnv, any, {}>
}) app
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Not Found from App", 404>(text: "Not Found from App", status?: 404 | undefined, headers?: HeaderRecord) => Response & TypedResponse<"Not Found from App", 404, "text"> (+1 overload)
.mount('/another-app',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<BlankEnv, BlankSchema, "/">
.mount()
allows you to mount applications built with other frameworks into your Hono application.@see — https://hono.dev/docs/api/hono#mount
@param
path
— base Path@param
applicationHandler
— other Request Handler@param
options
— options of.mount()
@returns — 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
anotherApp, () => {
ts const app = new Hono() // Send the request to another application without modification. app.mount('/app', anotherApp, { replaceRequest: (req) => req, })
return 'params' }) app
const anotherApp: (req: Request, ...params: unknown[]) => Response
.mount('/another-app-with-array-option',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<BlankEnv, BlankSchema, "/">
.mount()
allows you to mount applications built with other frameworks into your Hono application.@see — https://hono.dev/docs/api/hono#mount
@param
path
— base Path@param
applicationHandler
— other Request Handler@param
options
— options of.mount()
@returns — 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
anotherApp, () => {
ts const app = new Hono() // Send the request to another application without modification. app.mount('/app', anotherApp, { replaceRequest: (req) => req, })
return ['param1', 'param2'] }) app
const anotherApp: (req: Request, ...params: unknown[]) => Response
.mount('/another-app2/sub-slash/',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<BlankEnv, BlankSchema, "/">
.mount()
allows you to mount applications built with other frameworks into your Hono application.@see — https://hono.dev/docs/api/hono#mount
@param
path
— base Path@param
applicationHandler
— other Request Handler@param
options
— options of.mount()
@returns — 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
anotherApp)
ts const app = new Hono() // Send the request to another application without modification. app.mount('/app', anotherApp, { replaceRequest: (req) => req, })
const api = new
const anotherApp: (req: Request, ...params: unknown[]) => Response
Hono()
const api: Hono<BlankEnv, BlankSchema, "/api">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
.basePath('/api')options
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<"/api">(path: "/api"): Hono<BlankEnv, BlankSchema, "/api">
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
api
ts const api = new Hono().basePath('/api')
.mount('/another-app',
const api: Hono<BlankEnv, BlankSchema, "/api">
(method) Hono<BlankEnv, BlankSchema, "/api">.mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<BlankEnv, BlankSchema, "/api">
.mount()
allows you to mount applications built with other frameworks into your Hono application.@see — https://hono.dev/docs/api/hono#mount
@param
path
— base Path@param
applicationHandler
— other Request Handler@param
options
— options of.mount()
@returns — 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
anotherApp)
ts const app = new Hono() // Send the request to another application without modification. app.mount('/app', anotherApp, { replaceRequest: (req) => req, })
it('Should return responses from Hono app', async () => { const res = await
const anotherApp: (req: Request, ...params: unknown[]) => Response
app
const res: Response
.request('/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('x-message')).toBe('Foo')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('Hono')
const res: Response
}) it('Should return responses from AnotherApp', async () => { let res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/another-app')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
let res: Response
.get('x-message')).toBe('Foo')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('AnotherApp')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/another-app/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
let res: Response
.get('x-message')).toBe('Foo')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('Hello from AnotherApp')
let res: Response
const req = new
(method) Body.text(): Promise<string>
MDN ReferenceRequest('http://localhost/another-app/header', {
const req: Request
headers: {
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.'x-message': 'Message Foo!', }, }) res = await
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers.app
let res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(200)
let res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
let res: Response
.get('x-message')).toBe('Foo')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('Message Foo!')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/another-app/not-found')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
let res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
let res: Response
.get('x-message')).toBe('Foo')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('Not Found from AnotherApp')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/another-app/with-query?foo=bar&baz=qux')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('foo=bar&baz=qux')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/another-app/with-params')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
let res: Response
params: ['params'],
(method) Body.json(): Promise<any>
MDN Reference}) res = await
(property) params: string[]
app
let res: Response
.request('/another-app/undefined')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Not Found from App')
let res: Response
}) it('Should return response from Another app with an array option', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/another-app-with-array-option/with-params')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
params: ['param1', 'param2'],
(method) Body.json(): Promise<any>
MDN Reference}) }) it('Should return responses from AnotherApp - sub + slash', async () => { const res = await
(property) params: string[]
app
const res: Response
.request('/another-app2/sub-slash')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('AnotherApp')
const res: Response
}) it('Should return responses from AnotherApp - with `basePath()`', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapi
const res: Response
.request('/api/another-app')
const api: Hono<BlankEnv, BlankSchema, "/api">
(property) Hono<BlankEnv, BlankSchema, "/api">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('AnotherApp')
const res: Response
}) }) describe('With fetch', () => { const anotherApp = async
(method) Body.text(): Promise<string>
MDN Reference(req:
const anotherApp: (req: Request, env: {}, executionContext: ExecutionContext) => Promise<Response>
Request,
(parameter) req: Request
env: {},
interface Request
This Fetch API interface represents a resource request.executionContext:
(parameter) env: {}
ExecutionContext) => {
(parameter) executionContext: ExecutionContext
const path =
(alias) interface ExecutionContext import ExecutionContext
Interface for the execution context in a web worker or similar environment.getPath
const path: string
(req)
(alias) getPath(request: Request): string import getPath
if (path === '/') {
(parameter) req: Request
return new Response(
const path: string
JSON
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..stringify({
var JSON: JSON
An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
(method) JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)
Converts a JavaScript value to a JavaScript Object Notation (JSON) string.@param
value
— A JavaScript value, usually an object or array, to be converted.@param
replacer
— A function that transforms the results.@param
env,space
— Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.executionContext,
(property) env: {}
}), { headers: {
(property) executionContext: ExecutionContext
'Content-Type': 'application/json', }, } ) } return new Response('Not Found from AnotherApp', {
(property) ResponseInit.headers?: HeadersInit | undefined
status: 404,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.}) } const app = new
(property) ResponseInit.status?: number | undefined
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..mount('/another-app',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<BlankEnv, BlankSchema, "/">
.mount()
allows you to mount applications built with other frameworks into your Hono application.@see — https://hono.dev/docs/api/hono#mount
@param
path
— base Path@param
applicationHandler
— other Request Handler@param
options
— options of.mount()
@returns — 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
anotherApp)
ts const app = new Hono() // Send the request to another application without modification. app.mount('/app', anotherApp, { replaceRequest: (req) => req, })
it('Should handle Env and ExecuteContext', async () => { const request = new
const anotherApp: (req: Request, env: {}, executionContext: ExecutionContext) => Promise<Response>
Request('http://localhost/another-app')
const request: Request
const res = await
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.app
const res: Response
.fetch(
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.fetch: (request: Request, Env?: unknown, executionCtx?: ExecutionContext) => Response | Promise<Response>
.fetch()
will be entry point of your app.@see — https://hono.dev/docs/api/hono#fetch
@param
request
— request Object of request@param
Env
— env Object@param — - context of execution
@returns — response of request
request,{ TOKEN: 'foo',
const request: Request
}, { // Force mocking! // @ts-ignore waitUntil: 'waitUntil',
(property) TOKEN: string
(method) ExecutionContext.waitUntil(promise: Promise<unknown>): void
Extends the lifetime of the event callback until the promise is settled.@param
// @ts-ignore passThroughOnException: 'passThroughOnException',promise
— A promise to wait for.} ) expect(res
(method) ExecutionContext.passThroughOnException(): void
Allows the event to be passed through to subsequent event listeners..status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.json()).toEqual({
const res: Response
env: {
(method) Body.json(): Promise<any>
MDN ReferenceTOKEN: 'foo',
(property) env: { TOKEN: string; }
}, executionContext: {
(property) TOKEN: string
waitUntil: 'waitUntil',
(property) executionContext: { waitUntil: string; passThroughOnException: string; }
passThroughOnException: 'passThroughOnException',
(property) waitUntil: string
}, }) }) }) describe('Mount on `/`', () => { const anotherApp =
(property) passThroughOnException: string
(req:
const anotherApp: (req: Request, params: unknown) => Response
Request,
(parameter) req: Request
params: unknown) => {
interface Request
This Fetch API interface represents a resource request.const path =
(parameter) params: unknown
getPath
const path: string
(req)
(alias) getPath(request: Request): string import getPath
if (path === '/') {
(parameter) req: Request
return new Response('AnotherApp')
const path: string
} if (path === '/hello') {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.return new Response('Hello from AnotherApp')
const path: string
} if (path === '/good/night') {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.return new Response('Good Night from AnotherApp')
const path: string
} return new Response('Not Found from AnotherApp', {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.status: 404,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.}) } const app = new
(property) ResponseInit.status?: number | undefined
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..mount('/',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<BlankEnv, BlankSchema, "/">
.mount()
allows you to mount applications built with other frameworks into your Hono application.@see — https://hono.dev/docs/api/hono#mount
@param
path
— base Path@param
applicationHandler
— other Request Handler@param
options
— options of.mount()
@returns — 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
anotherApp)
ts const app = new Hono() // Send the request to another application without modification. app.mount('/app', anotherApp, { replaceRequest: (req) => req, })
it('Should return responses from AnotherApp - mount on `/`', async () => { let res = await
const anotherApp: (req: Request, params: unknown) => Response
app
let res: Response
.request('/')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('AnotherApp')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/hello')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Hello from AnotherApp')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/good/night')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Good Night from AnotherApp')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/not-found')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(404)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Not Found from AnotherApp')
let res: Response
}) }) describe('With replaceRequest option', () => { const anotherApp =
(method) Body.text(): Promise<string>
MDN Reference(req:
const anotherApp: (req: Request) => Response
Request) => {
(parameter) req: Request
const path =
interface Request
This Fetch API interface represents a resource request.getPath
const path: string
(req)
(alias) getPath(request: Request): string import getPath
if (path === '/app') {
(parameter) req: Request
return new Response
const path: string
(getPath
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.(req))
(alias) getPath(request: Request): string import getPath
} return new Response(null, {
(parameter) req: Request
status: 404 })
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.} const app = new
(property) ResponseInit.status?: number | undefined
Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..mount('/app',
const app: Hono<BlankEnv, BlankSchema, "/">
(method) Hono<BlankEnv, BlankSchema, "/">.mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<BlankEnv, BlankSchema, "/">
.mount()
allows you to mount applications built with other frameworks into your Hono application.@see — https://hono.dev/docs/api/hono#mount
@param
path
— base Path@param
applicationHandler
— other Request Handler@param
options
— options of.mount()
@returns — 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
anotherApp, {
ts const app = new Hono() // Send the request to another application without modification. app.mount('/app', anotherApp, { replaceRequest: (req) => req, })
replaceRequest:
const anotherApp: (req: Request) => Response
(req) =>
(property) replaceRequest?: MountReplaceRequest | undefined
req,
(parameter) req: Request
}) it('Should return 200 response with the correct path', async () => { const res = await
(parameter) req: Request
app
const res: Response
.request('/app')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('/app')
const res: Response
}) }) }) describe('HEAD method', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/page',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/page", "/page", Response & TypedResponse<"/page", StatusCode, "text">, BlankInput, BlankEnv>(path: "/page", handler: H<...>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/page", BlankInput>
.header('X-Message', 'Foo')
(parameter) c: Context<BlankEnv, "/page", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.header('X-Method',
(parameter) c: Context<BlankEnv, "/page", BlankInput>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.header: SetHeaders (name: string, value?: string, options?: SetHeadersOptions) => void (+2 overloads)
.req
(parameter) c: Context<BlankEnv, "/page", BlankInput>
.method)
(property) Context<BlankEnv, "/page", BlankInput>.req: HonoRequest<"/page", unknown>
.req
is the instance of HonoRequest.
(property) HonoRequest<P extends string = "/", I extends Input["out"] = {}>.method: string
.method()
can get the method name of the request.@see — https://hono.dev/docs/api/request#method
@example
return c
ts app.get('/about/me', (c) => { const method = c.req.method // `GET` })
.text('/page')
(parameter) c: Context<BlankEnv, "/page", BlankInput>
}) it('Should return 200 response with body - GET /page', async () => { const res = await
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"/page", StatusCode>(text: "/page", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
app
const res: Response
.request('/page')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('X-Message')).toBe('Foo')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('X-Method')).toBe('GET')
(property) Response.headers: Headers
MDN Referenceexpect(await res
(method) Headers.get(name: string): string | null
MDN Reference.text()).toBe('/page')
const res: Response
}) it('Should return 200 response without body - HEAD /page', async () => { const req = new
(method) Body.text(): Promise<string>
MDN ReferenceRequest('http://localhost/page', {
const req: Request
method: 'HEAD',
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.}) const res = await
(property) RequestInit.method?: string | undefined
A string to set request's method.app
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req)expect(res
const req: Request
.status).toBe(200)
const res: Response
expect(res
(property) Response.status: number
MDN Reference.headers
const res: Response
.get('X-Message')).toBe('Foo')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.headers
const res: Response
.get('X-Method')).toBe('HEAD')
(property) Response.headers: Headers
MDN Referenceexpect(res
(method) Headers.get(name: string): string | null
MDN Reference.body).toBe(null)
const res: Response
}) }) declare module './context' { interface ContextRenderer {
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference(content: string |
interface ContextRenderer
Interface for context renderer.Promise
(parameter) content: string | Promise<string>
, head: {
interface Promise<T>
Represents the completion of an asynchronous operationtitle: string }):
(parameter) head: { title: string; }
Response |
(property) title: string
Promise
interface Response
This Fetch API interface represents the response to a request.<Response>
interface Promise<T>
Represents the completion of an asynchronous operation} } describe('app.request()', () => { it('Should return response with Request and RequestInit as args', async () => { const app = new
interface Response
This Fetch API interface represents the response to a request.Hono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/foo',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo", "/foo", JSONRespondReturn<string | undefined, StatusCode>, BlankInput, BlankEnv>(path: "/foo", handler: H<BlankEnv, "/foo", BlankInput, JSONRespondReturn<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.json
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <string | undefined, StatusCode>(object: string | undefined, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<...> (+1 overload)
.req
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.header('x-message'))
(property) Context<BlankEnv, "/foo", BlankInput>.req: HonoRequest<"/foo", unknown>
.req
is the instance of HonoRequest.
(method) HonoRequest<"/foo", unknown>.header(name: string): string | undefined (+1 overload)
.header()
can get the request header value.@see — https://hono.dev/docs/api/request#header
@example
}) const req = new
ts app.get('/', (c) => { const userAgent = c.req.header('User-Agent') })
Request('http://localhost/foo')
const req: Request
const headers = new
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.Headers()
const headers: Headers
headers
var Headers: new (init?: HeadersInit) => Headers
This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence..append('x-message', 'hello')
const headers: Headers
const res = await
(method) Headers.append(name: string, value: string): void
MDN Referenceapp
const res: Response
.request
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
(req, {headers,
const req: Request
}) expect(res
(property) RequestInit.headers?: HeadersInit | undefined
A Headers object, an object literal, or an array of two-item arrays to set request's headers..status).toBe(200)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('"hello"')
const res: Response
}) }) describe('app.fire()', () => { it('Should call global.addEventListener', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
const addEventListener = vi.fn()options
— Optional configuration options for the Hono instance.global.addEventListener = addEventListener
const addEventListener: any
app
const addEventListener: any
.fire()
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.fire: () => void
.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/
expect(addEventListener).toHaveBeenCalledWith('fetch', expect.any(Function))
const addEventListener: any
const fetchEventListener =
var Function: FunctionConstructor
Creates a new function.addEventListener.mock.calls[0][1]
const fetchEventListener: any
const respondWith = vi.fn()
const addEventListener: any
const request = new
const respondWith: any
Request('http://localhost')
const request: Request
fetchEventListener({
var Request: new (input: RequestInfo | URL, init?: RequestInit) => Request
This Fetch API interface represents a resource request.respondWith,
const fetchEventListener: any
request })
(property) respondWith: any
expect(respondWith).toHaveBeenCalledWith(expect.any
(property) request: Request
(Promise))
const respondWith: any
}) }) describe('Context render and setRenderer', () => { const app = new
var Promise: PromiseConstructor
Represents the completion of an asynchronous operationHono()
const app: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
appoptions
— Optional configuration options for the Hono instance..get('/default',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/default", "/default", Response | Promise<Response>, BlankInput, BlankEnv>(path: "/default", handler: H<BlankEnv, "/default", BlankInput, Response | Promise<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/default", BlankInput>
.render('
(parameter) c: Context<BlankEnv, "/default", BlankInput>
content
', {title: 'dummy ' })
(property) Context<BlankEnv, "/default", BlankInput>.render: ContextRenderer (content: string | Promise<string>, head: { title: string; }) => Response | Promise<Response> (+1 overload)
}) app
(property) title: string
.use('/page', async
const app: Hono<BlankEnv, BlankSchema, "/">
(c,
(property) Hono<BlankEnv, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/page", "/page", BlankEnv>(path: "/page", handler: MiddlewareHandler<BlankEnv, "/page", {}>) => Hono<{}, { "/page": {}; }, "/"> (+20 overloads)
next) => {
(parameter) c: Context<BlankEnv, "/page", {}>
c
(parameter) next: Next
.setRenderer(
(parameter) c: Context<BlankEnv, "/page", {}>
(property) Context<BlankEnv, "/page", {}>.setRenderer: (renderer: ContextRenderer) => void
.setRenderer()
can set the layout in the custom middleware.@see — https://hono.dev/docs/api/context#render-setrenderer
@example
(content,
tsx app.use('*', async (c, next) => { c.setRenderer((content) => { return c.html( <html> <body> <p>{content}</p> </body> </html> ) }) await next() })
head) => {
(parameter) content: string | Promise<string>
return new Response(
(parameter) head: { title: string; } | { title: string; }
`
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.${ head.title}
(parameter) head: { title: string; } | { title: string; }
$
{content}`
(property) title: string
) }) await next()
(parameter) content: string | Promise<string>
}) app
(parameter) next: () => Promise<void>
.get('/page',
const app: Hono<BlankEnv, BlankSchema, "/">
(c) => {
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/page", "/page", Response | Promise<Response>, BlankInput, BlankEnv>(path: "/page", handler: H<BlankEnv, "/page", BlankInput, Response | Promise<...>>) => Hono<...> (+22 overloads)
return c
(parameter) c: Context<BlankEnv, "/page", BlankInput>
.render('page content', {
(parameter) c: Context<BlankEnv, "/page", BlankInput>
title: 'page title',
(property) Context<BlankEnv, "/page", BlankInput>.render: ContextRenderer (content: string | Promise<string>, head: { title: string; }) => Response | Promise<Response> (+1 overload)
}) }) it('Should return a Response from the default renderer', async () => { const res = await
(property) title: string
app
const res: Response
.request('/default')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(await res.text()).toBe('
const res: Response
content
')}) it('Should return a Response from the custom renderer', async () => { const res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
const res: Response
.request('/page')
const app: Hono<BlankEnv, BlankSchema, "/">
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(await res.text()).toBe(
const res: Response
'
(method) Body.text(): Promise<string>
MDN Referencepage title page content
' ) }) }) describe('c.var - with testing types', () => { const app = newHono<{
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(alias) new Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">(options?: HonoOptions<{ Bindings: { Token: string; }; }>): Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
Bindings: {options
— Optional configuration options for the Hono instance.Token: string
(property) Bindings: { Token: string; }
} }>() const mw =
(property) Token: string
(): MiddlewareHandler<{
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo:
(property) Variables: { echo: (str: string) => string; }
(str: string) => string
(property) echo: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo',
(parameter) c: Context<{ Variables: { echo: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo: (str: string) => string; }; }, string, {}>.set: Set <"echo">(key: "echo", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw2 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo2:
(property) Variables: { echo2: (str: string) => string; }
(str: string) => string
(property) echo2: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo2: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo2',
(parameter) c: Context<{ Variables: { echo2: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo2: (str: string) => string; }; }, string, {}>.set: Set <"echo2">(key: "echo2", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw3 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo3:
(property) Variables: { echo3: (str: string) => string; }
(str: string) => string
(property) echo3: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo3: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo3',
(parameter) c: Context<{ Variables: { echo3: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo3: (str: string) => string; }; }, string, {}>.set: Set <"echo3">(key: "echo3", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw4 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo4:
(property) Variables: { echo4: (str: string) => string; }
(str: string) => string
(property) echo4: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo4: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo4',
(parameter) c: Context<{ Variables: { echo4: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo4: (str: string) => string; }; }, string, {}>.set: Set <"echo4">(key: "echo4", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw5 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo5:
(property) Variables: { echo5: (str: string) => string; }
(str: string) => string
(property) echo5: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo5: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo5',
(parameter) c: Context<{ Variables: { echo5: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo5: (str: string) => string; }; }, string, {}>.set: Set <"echo5">(key: "echo5", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw6 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo6:
(property) Variables: { echo6: (str: string) => string; }
(str: string) => string
(property) echo6: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo6: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo6',
(parameter) c: Context<{ Variables: { echo6: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo6: (str: string) => string; }; }, string, {}>.set: Set <"echo6">(key: "echo6", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw7 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo7:
(property) Variables: { echo7: (str: string) => string; }
(str: string) => string
(property) echo7: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo7: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo7',
(parameter) c: Context<{ Variables: { echo7: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo7: (str: string) => string; }; }, string, {}>.set: Set <"echo7">(key: "echo7", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw8 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo8:
(property) Variables: { echo8: (str: string) => string; }
(str: string) => string
(property) echo8: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo8: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo8',
(parameter) c: Context<{ Variables: { echo8: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo8: (str: string) => string; }; }, string, {}>.set: Set <"echo8">(key: "echo8", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw9 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo9:
(property) Variables: { echo9: (str: string) => string; }
(str: string) => string
(property) echo9: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo9: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo9',
(parameter) c: Context<{ Variables: { echo9: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo9: (str: string) => string; }; }, string, {}>.set: Set <"echo9">(key: "echo9", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} const mw10 =
(parameter) next: () => Promise<void>
(): MiddlewareHandler<{
const mw10: () => MiddlewareHandler<{ Variables: { echo10: (str: string) => string; }; }>
Variables: {
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> import MiddlewareHandler
echo10:
(property) Variables: { echo10: (str: string) => string; }
(str: string) => string
(property) echo10: (str: string) => string
} }> => async (c,
(parameter) str: string
next) => {
(parameter) c: Context<{ Variables: { echo10: (str: string) => string; }; }, string, {}>
c
(parameter) next: Next
.set('echo10',
(parameter) c: Context<{ Variables: { echo10: (str: string) => string; }; }, string, {}>
(str) =>
(property) Context<{ Variables: { echo10: (str: string) => string; }; }, string, {}>.set: Set <"echo10">(key: "echo10", value: (str: string) => string) => void (+1 overload)
str)
(parameter) str: string
await next()
(parameter) str: string
} app
(parameter) next: () => Promise<void>
.use('/no-path/1')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/1", { Bindings: { Token: string; }; }>(path: "/no-path/1", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/1", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, {}, {}, Response & TypedResponse<string, StatusCode, "text">, { Variables: { echo: (str: string) => string; }; }, { ...; } & { Variables: { echo: (str: string) => string; }; }>(handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
(c) => {
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, string, {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, string, {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo: (str: string) => string
.use('/no-path/2')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/2", { Bindings: { Token: string; }; }>(path: "/no-path/2", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/2", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; } & ... 1 more ... & { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
(c) => {
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, string, {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, string, {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo2: (str: string) => string
.use('/no-path/3')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/3", { Bindings: { Token: string; }; }>(path: "/no-path/3", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/3", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; } & ... 2 more ... & { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
(c) => {
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, string, {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, string, {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo3: (str: string) => string
.use('/no-path/4')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/4", { Bindings: { Token: string; }; }>(path: "/no-path/4", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/4", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 3 more ... & { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
(c) => {
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo4: (str: string) => string
.use('/no-path/5')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/5", { Bindings: { Token: string; }; }>(path: "/no-path/5", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/5", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 4 more ... & { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
(c) => {
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo5: (str: string) => string
.use('/no-path/6')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/6", { Bindings: { Token: string; }; }>(path: "/no-path/6", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/6", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 5 more ... & { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
(c) => {
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo6: (str: string) => string
.use('/no-path/7')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/7", { Bindings: { Token: string; }; }>(path: "/no-path/7", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/7", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 6 more ... & { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
(c) => {
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo7: (str: string) => string
.use('/no-path/8')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/8", { Bindings: { Token: string; }; }>(path: "/no-path/8", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/8", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 7 more ... & { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
(c) => {
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo8: (str: string) => string
.use('/no-path/9')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/9", { Bindings: { Token: string; }; }>(path: "/no-path/9", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/9", {}>[]) => Hono<...> (+20 overloads)
(mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 8 more ... & { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>, handlers_9: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
mw9(),
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
(c) => {
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8') +
ts const result = c.var.client.oneMethod()
c
(property) echo8: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo9('hello9')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo9: (str: string) => string
.use('/no-path/10')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
.get(
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"/no-path/10", { Bindings: { Token: string; }; }>(path: "/no-path/10", ...handlers: MiddlewareHandler<{ Bindings: { Token: string; }; }, "/no-path/10", {}>[]) => Hono<...> (+20 overloads)
// @ts-expect-error The handlers are more than 10 mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, string, any, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo2: (str: string) => string; }; }, { Variables: { echo3: (str: string) => string; }; }, { Variables: { echo4: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 8 more ... & { ...; }>(path: string, handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>, handlers_9: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
mw9(),
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
mw10(),
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
(c) => {
const mw10: () => MiddlewareHandler<{ Variables: { echo10: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
// @ts-expect-error c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var.echo('hello') +
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
c
ts const result = c.var.client.oneMethod()
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8') +
ts const result = c.var.client.oneMethod()
c
(property) echo8: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo9('hello9') +
ts const result = c.var.client.oneMethod()
c
(property) echo9: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo10: (str: string) => string; }; }, string, {}>.var: Readonly<ContextVariableMap & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & ... 4 more ... & { echo10: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo10('hello10')
ts const result = c.var.client.oneMethod()
) } ) app
(property) echo10: (str: string) => string
.get('*',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw())
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"*", "*", HandlerResponse<any>, {}, { Variables: { echo: (str: string) => string; }; }>(path: "*", handler: H<{ Variables: { echo: (str: string) => string; }; }, "*", {}, HandlerResponse<...>>) => Hono<...> (+22 overloads)
app
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
.get('/path/1',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/1", "/path/1", Response & TypedResponse<string, StatusCode, "text">, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; } & { Variables: { echo: (str: string) => string; }; }>(path: "/path/1", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
(c) => {
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo: (str: string) => string
.get('/path/2',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/2", "/path/2", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; } & ... 1 more ... & { ...; }>(path: "/path/2", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
(c) => {
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/path/2", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/path/2", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/path/2", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/path/2", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/path/2", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/path/2", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo2: (str: string) => string
.get('/path/3',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/3", "/path/3", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; } & ... 2 more ... & { ...; }>(path: "/path/3", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
(c) => {
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/path/3", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/path/3", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/path/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/path/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/path/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/path/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/path/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/path/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo3: (str: string) => string
.get('/path/4',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/4", "/path/4", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 3 more ... & { ...; }>(path: "/path/4", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
(c) => {
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/path/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo4: (str: string) => string
.get('/path/5',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/5", "/path/5", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 4 more ... & { ...; }>(path: "/path/5", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
(c) => {
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/path/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo5: (str: string) => string
.get('/path/6',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/6", "/path/6", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 5 more ... & { ...; }>(path: "/path/6", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
(c) => {
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/path/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo6: (str: string) => string
.get('/path/7',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/7", "/path/7", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 6 more ... & { ...; }>(path: "/path/7", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
(c) => {
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/path/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo7: (str: string) => string
.get('/path/8',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/8", "/path/8", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 7 more ... & { ...; }>(path: "/path/8", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
(c) => {
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/path/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo8: (str: string) => string
.get('/path/9',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/9", "/path/9", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 8 more ... & { ...; }>(path: "/path/9", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>, handlers_9: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
mw9(),
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
(c) => {
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8') +
ts const result = c.var.client.oneMethod()
c
(property) echo8: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/path/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo9('hello9')
ts const result = c.var.client.oneMethod()
) }) // @ts-expect-error app
(property) echo9: (str: string) => string
.get('/path/10',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, {}, HandlerResponse<any>>(...handlers: H<{ Bindings: { Token: string; }; }, string, {}, HandlerResponse<any>>[]) => Hono<{ Bindings: { Token: string; }; }, { ...; }, "/"> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
mw9(),
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
mw10(),
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
(c) => {
const mw10: () => MiddlewareHandler<{ Variables: { echo10: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
// @ts-expect-error c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <any, StatusCode>(text: any, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<any, StatusCode, "text"> (+1 overload)
.var.echo('hello') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo2('hello2') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo3('hello3') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo4('hello4') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo5('hello5') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo6('hello6') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo7('hello7') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo8('hello8') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo9('hello9') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo10('hello10')
(parameter) c: Context<{ Bindings: { Token: string; }; }, string, {}>
(property) Context<{ Bindings: { Token: string; }; }, string, {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
) }) app
ts const result = c.var.client.oneMethod()
.on('GET', '/on/1',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/1", "/on/1", Response & TypedResponse<string, StatusCode, "text">, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; } & { Variables: { echo: (str: string) => string; }; }>(method: "GET", path: "/on/1", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
(c) => {
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/on/1", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/on/1", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/on/1", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/on/1", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo: (str: string) => string
.on('GET', '/on/2',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/2", "/on/2", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; } & ... 1 more ... & { ...; }>(method: "GET", path: "/on/2", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
(c) => {
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo2: (str: string) => string
.on('GET', '/on/3',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/3", "/on/3", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; } & ... 2 more ... & { ...; }>(method: "GET", path: "/on/3", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
(c) => {
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo3: (str: string) => string
.on('GET', '/on/4',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/4", "/on/4", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 3 more ... & { ...; }>(method: "GET", path: "/on/4", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
(c) => {
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo4: (str: string) => string
.on('GET', '/on/5',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/5", "/on/5", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 4 more ... & { ...; }>(method: "GET", path: "/on/5", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
(c) => {
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo5: (str: string) => string
.on('GET', '/on/6',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/6", "/on/6", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 5 more ... & { ...; }>(method: "GET", path: "/on/6", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
(c) => {
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo6: (str: string) => string
.on('GET', '/on/7',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/7", "/on/7", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 6 more ... & { ...; }>(method: "GET", path: "/on/7", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
(c) => {
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo7: (str: string) => string
.on('GET', '/on/8',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/8", "/on/8", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 7 more ... & { ...; }>(method: "GET", path: "/on/8", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
(c) => {
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo8: (str: string) => string
.on('GET', '/on/9',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/9", "/on/9", {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 8 more ... & { ...; }>(method: "GET", path: "/on/9", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>, handlers_9: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
mw9(),
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
(c) => {
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8') +
ts const result = c.var.client.oneMethod()
c
(property) echo8: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo9('hello9')
ts const result = c.var.client.oneMethod()
) }) // @ts-expect-error app
(property) echo9: (str: string) => string
.on(
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
'GET', '/on/10', mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <"GET", "/on/10", HandlerResponse<any>, {}>(method: "GET", path: "/on/10", ...handlers: H<{ Bindings: { Token: string; }; }, "/on/10", {}, HandlerResponse<any>>[]) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
mw9(),
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
mw10(),
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
(c) => {
const mw10: () => MiddlewareHandler<{ Variables: { echo10: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
// @ts-expect-error c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <any, StatusCode>(text: any, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<any, StatusCode, "text"> (+1 overload)
.var.echo('hello') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo2('hello2') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo3('hello3') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo4('hello4') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo5('hello5') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo6('hello6') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo7('hello7') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo8('hello8') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo9('hello9') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo10('hello10')
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
) } ) app
ts const result = c.var.client.oneMethod()
.on(['GET', 'POST'], '/on/1',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/1", "/on/1", Response & TypedResponse<string, StatusCode, "text">, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; } & { Variables: { echo: (str: string) => string; }; }>(methods: string[], path: "/on/1", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
(c) => {
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/on/1", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/on/1", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/on/1", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/on/1", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo: (str: string) => string
.on(['GET', 'POST'], '/on/2',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/2", "/on/2", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; } & ... 1 more ... & { ...; }>(methods: string[], path: "/on/2", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
(c) => {
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; }, "/on/2", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo2: (str: string) => string
.on(['GET', 'POST'], '/on/3',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/3", "/on/3", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; } & ... 2 more ... & { ...; }>(methods: string[], path: "/on/3", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
(c) => {
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; }, "/on/3", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3'))
ts const result = c.var.client.oneMethod()
}) app
(property) echo3: (str: string) => string
.on(['GET', 'POST'], '/on/4',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/4", "/on/4", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 3 more ... & { ...; }>(methods: string[], path: "/on/4", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
(c) => {
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; }, "/on/4", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo4: (str: string) => string
.on(['GET', 'POST'], '/on/5',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/5", "/on/5", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 4 more ... & { ...; }>(methods: string[], path: "/on/5", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
(c) => {
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; }, "/on/5", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo5: (str: string) => string
.on(['GET', 'POST'], '/on/6',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/6", "/on/6", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 5 more ... & { ...; }>(methods: string[], path: "/on/6", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
(c) => {
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & { Variables: { echo3: (str: string) => string; }; } & { Variables: { echo4: (str: string) => string; }; } & { Variables: { echo5: (str: string) => string; }; } & { Variables: { echo6: (str: string) => string; }; }, "/on/6", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo6: (str: string) => string
.on(['GET', 'POST'], '/on/7',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/7", "/on/7", Response & TypedResponse<string, StatusCode, "text">, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 6 more ... & { ...; }>(methods: string[], path: "/on/7", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
(c) => {
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 4 more ... & { Variables: { echo7: (str: string) => string; }; }, "/on/7", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo7: (str: string) => string
.on(['GET', 'POST'], '/on/8',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/8", "/on/8", {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 7 more ... & { ...; }>(methods: string[], path: "/on/8", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
(c) => {
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 5 more ... & { Variables: { echo8: (str: string) => string; }; }, "/on/8", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & { echo5: (str: string) => string; } & { echo6: (str: string) => string; } & { echo7: (str: string) => string; } & { echo8: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8')
ts const result = c.var.client.oneMethod()
) }) app
(property) echo8: (str: string) => string
.on(
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
['GET', 'POST'], '/on/9', mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string[], "/on/9", "/on/9", {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; }, { ...; } & ... 8 more ... & { ...; }>(methods: string[], path: "/on/9", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>, handlers_5: H<...>, handlers_6: H<...>, handlers_7: H<...>, handlers_8: H<...>, handlers_9: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
mw9(),
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
(c) => {
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello') +
ts const result = c.var.client.oneMethod()
c
(property) echo: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo2('hello2') +
ts const result = c.var.client.oneMethod()
c
(property) echo2: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo3('hello3') +
ts const result = c.var.client.oneMethod()
c
(property) echo3: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo4('hello4') +
ts const result = c.var.client.oneMethod()
c
(property) echo4: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo5('hello5') +
ts const result = c.var.client.oneMethod()
c
(property) echo5: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo6('hello6') +
ts const result = c.var.client.oneMethod()
c
(property) echo6: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo7('hello7') +
ts const result = c.var.client.oneMethod()
c
(property) echo7: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo8('hello8') +
ts const result = c.var.client.oneMethod()
c
(property) echo8: (str: string) => string
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; } & { Variables: { echo2: (str: string) => string; }; } & ... 6 more ... & { Variables: { echo9: (str: string) => string; }; }, "/on/9", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; } & { echo2: (str: string) => string; } & { echo3: (str: string) => string; } & { echo4: (str: string) => string; } & ... 4 more ... & { echo9: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo9('hello9')
ts const result = c.var.client.oneMethod()
) } ) // @ts-expect-error app
(property) echo9: (str: string) => string
.on(
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
['GET', 'POST'], '/on/10', mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.on: OnHandlerInterface <string, "/on/10", HandlerResponse<any>, {}>(method: string, path: "/on/10", ...handlers: H<{ Bindings: { Token: string; }; }, "/on/10", {}, HandlerResponse<any>>[]) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5(),
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
mw6(),
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
mw7(),
const mw6: () => MiddlewareHandler<{ Variables: { echo6: (str: string) => string; }; }>
mw8(),
const mw7: () => MiddlewareHandler<{ Variables: { echo7: (str: string) => string; }; }>
mw9(),
const mw8: () => MiddlewareHandler<{ Variables: { echo8: (str: string) => string; }; }>
mw10(),
const mw9: () => MiddlewareHandler<{ Variables: { echo9: (str: string) => string; }; }>
(c) => {
const mw10: () => MiddlewareHandler<{ Variables: { echo10: (str: string) => string; }; }>
return c
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
.text(
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
// @ts-expect-error c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <any, StatusCode>(text: any, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<any, StatusCode, "text"> (+1 overload)
.var.echo('hello') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo2('hello2') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo3('hello3') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo4('hello4') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo5('hello5') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo6('hello6') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo7('hello7') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo8('hello8') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo9('hello9') +
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
// @ts-expect-error c
ts const result = c.var.client.oneMethod()
.var.echo10('hello10')
(parameter) c: Context<{ Bindings: { Token: string; }; }, "/on/10", {}>
(property) Context<{ Bindings: { Token: string; }; }, "/on/10", {}>.var: Readonly<ContextVariableMap>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
) } ) it('Should return the correct response - no-path', async () => { let res = await
ts const result = c.var.client.oneMethod()
app
let res: Response
.request('/no-path/1')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/no-path/2')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/no-path/3')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/no-path/4')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3hello4')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/no-path/5')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3hello4hello5')
let res: Response
}) it('Should return the correct response - path', async () => { let res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/path/1')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/path/2')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/path/3')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/path/4')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3hello4')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/path/5')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3hello4hello5')
let res: Response
}) it('Should return the correct response - on', async () => { let res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/on/1')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hello')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/on/2')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/on/3')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/on/4')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3hello4')
let res: Response
res = await
(method) Body.text(): Promise<string>
MDN Referenceapp
let res: Response
.request('/on/5')
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: {} | { Token: string; } | undefined, 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
expect(res.status).toBe(200)
let res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('hellohello2hello3hello4hello5')
let res: Response
}) it('Should not throw type errors', () => { const app = new
(method) Body.text(): Promise<string>
MDN ReferenceHono<{
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
(alias) new Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">(options?: HonoOptions<{ Variables: { hello: () => string; }; }>): Hono<...> import Hono
Creates an instance of the Hono class.@param
Variables: {options
— Optional configuration options for the Hono instance.hello: () => string
(property) Variables: { hello: () => string; }
} }>() app
(property) hello: () => string
.get
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
(mw())
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <string, {}, HandlerResponse<any>, { Variables: { echo: (str: string) => string; }; }>(handler: H<{ Variables: { echo: (str: string) => string; }; }, string, {}, HandlerResponse<...>>) => Hono<...> (+22 overloads)
app
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
.get
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
(mw(),
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <string, {}, {}, HandlerResponse<any>, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }>(handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
mw2())
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
app
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
.get
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
(mw(),
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <string, HandlerResponse<any>, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3())
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
app
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
.get
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
(mw(),
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <string, HandlerResponse<any>, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }, { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4())
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
app
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
.get
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
(mw(),
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <string, HandlerResponse<any>, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }>(handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5())
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
app
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
.get('/',
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
mw())
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, {}, { Variables: { echo: (str: string) => string; }; }>(path: "/", handler: H<{ Variables: { echo: (str: string) => string; }; }, "/", {}, HandlerResponse<...>>) => Hono<...> (+22 overloads)
app
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
.get('/',
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }>(path: "/", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
mw2())
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
app
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
.get('/',
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }>(path: "/", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3())
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
app
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
.get('/',
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }, { ...; }>(path: "/", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4())
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
app
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
.get('/',
const app: Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Variables: { hello: () => string; }; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, {}, {}, {}, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Variables: { echo2: (str: string) => string; }; }, { ...; }, { ...; }, { ...; }>(path: "/", handlers_0: H<...>, handlers_1: H<...>, handlers_2: H<...>, handlers_3: H<...>, handlers_4: H<...>) => Hono<...> (+22 overloads)
mw2(),
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
mw3(),
const mw2: () => MiddlewareHandler<{ Variables: { echo2: (str: string) => string; }; }>
mw4(),
const mw3: () => MiddlewareHandler<{ Variables: { echo3: (str: string) => string; }; }>
mw5())
const mw4: () => MiddlewareHandler<{ Variables: { echo4: (str: string) => string; }; }>
}) it('Should be a read-only', () => { expect(() => { app
const mw5: () => MiddlewareHandler<{ Variables: { echo5: (str: string) => string; }; }>
.get('/path/1',
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/path/1", "/path/1", Response & TypedResponse<string, StatusCode, "text">, {}, {}, { Variables: { echo: (str: string) => string; }; }, { ...; } & { Variables: { echo: (str: string) => string; }; }>(path: "/path/1", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
(c) => {
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
// @ts-expect-error c
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo = 'hello'
ts const result = c.var.client.oneMethod()
return c
(property) echo: any
.text
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>
(c
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <string, StatusCode>(text: string, status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<string, StatusCode, "text"> (+1 overload)
.var
(parameter) c: Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>
(property) Context<{ Bindings: { Token: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/path/1", {}>.var: Readonly<ContextVariableMap & { echo: (str: string) => string; }>
.var
can access the value of a variable.@see — https://hono.dev/docs/api/context#var
@example
.echo('hello'))
ts const result = c.var.client.oneMethod()
}) }).toThrow() }) it('Should not throw a type error', (c) => {
(property) echo: (str: string) => string
const app = new
(parameter) c: any
Hono<{
const app: Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">
(alias) new Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">(options?: HonoOptions<{ Bindings: { TOKEN: string; }; }>): Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
Bindings: {options
— Optional configuration options for the Hono instance.TOKEN: string
(property) Bindings: { TOKEN: string; }
} }>() app
(property) TOKEN: string
.get('/',
const app: Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">
poweredBy(), async
(property) Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, {}, {}, any, { Bindings: { TOKEN: string; }; }>(path: "/", handlers_0: H<any, "/", {}, any>, handlers_1: H<{ Bindings: { TOKEN: string; }; }, "/", {}, HandlerResponse<...>>) => Hono<...> (+22 overloads)
(c) => {
(alias) poweredBy(): MiddlewareHandler import poweredBy
expectTypeOf(c
(parameter) c: Context<{ Bindings: { TOKEN: string; }; }, "/", {}>
.env
(parameter) c: Context<{ Bindings: { TOKEN: string; }; }, "/", {}>
(property) Context<{ Bindings: { TOKEN: string; }; }, "/", {}>.env: { TOKEN: string; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
.TOKEN).toEqualTypeOf
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
() }) app
(property) TOKEN: string
.get('/', async
const app: Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">
(c,
(property) Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", HandlerResponse<any>, BlankInput, { Bindings: { TOKEN: string; }; }>(path: "/", handler: H<{ Bindings: { TOKEN: string; }; }, "/", BlankInput, HandlerResponse<...>>) => Hono<...> (+22 overloads)
next) => {
(parameter) c: Context<{ Bindings: { TOKEN: string; }; }, "/", BlankInput>
expectTypeOf(c
(parameter) next: Next
.env
(parameter) c: Context<{ Bindings: { TOKEN: string; }; }, "/", BlankInput>
(property) Context<{ Bindings: { TOKEN: string; }; }, "/", BlankInput>.env: { TOKEN: string; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
.TOKEN).toEqualTypeOf
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
() const mw =
(property) TOKEN: string
poweredBy()
const mw: MiddlewareHandler
await mw
(alias) poweredBy(): MiddlewareHandler import poweredBy
(c,
const mw: (c: Context<any, string, {}>, next: Next) => Promise<Response | void>
next)
(parameter) c: Context<{ Bindings: { TOKEN: string; }; }, "/", BlankInput>
}) app
(parameter) next: Next
.use
const app: Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">
(mw())
(property) Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <{ Variables: { echo: (str: string) => string; }; }>(...handlers: MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }, never, {}>[]) => Hono<...> (+20 overloads)
app
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
.use('*',
const app: Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">
mw())
(property) Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <"*", "*", { Variables: { echo: (str: string) => string; }; }>(path: "*", handler: MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }, "*", {}>) => Hono<...> (+20 overloads)
const route =
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
app
const route: Hono<{ Bindings: { TOKEN: string; }; }, { "/posts": { $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }; }, "/">
.get('/posts',
const app: Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">
mw(),
(property) Hono<{ Bindings: { TOKEN: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/posts", "/posts", JSONRespondReturn<0, StatusCode>, {}, {}, { Variables: { echo: (str: string) => string; }; }, { Bindings: { TOKEN: string; }; } & { Variables: { echo: (str: string) => string; }; }>(path: "/posts", handlers_0: H<...>, handlers_1: H<...>) => Hono<...> (+22 overloads)
(c) =>
const mw: () => MiddlewareHandler<{ Variables: { echo: (str: string) => string; }; }>
c
(parameter) c: Context<{ Bindings: { TOKEN: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/posts", {}>
.json(0))
(parameter) c: Context<{ Bindings: { TOKEN: string; }; } & { Variables: { echo: (str: string) => string; }; }, "/posts", {}>
const client =
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.json: JSONRespond <0, StatusCode>(object: 0, status?: StatusCode | undefined, headers?: HeaderRecord) => JSONRespondReturn<0, StatusCode> (+1 overload)
hc
const client: { posts: ClientRequest<{ $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }>; }
route>('/')
(alias) hc<Hono<{ Bindings: { TOKEN: string; }; }, { "/posts": { $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }; }, "/">>(baseUrl: string, options?: ClientRequestOptions): { ...; } import hc
type key = keyof typeof
const route: Hono<{ Bindings: { TOKEN: string; }; }, { "/posts": { $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }; }, "/">
client
type key = "posts"
type verify =
const client: { posts: ClientRequest<{ $get: { input: {}; output: 0; outputFormat: "json"; status: StatusCode; }; }>; }
Expect
type verify = true
(alias) type Expect<T extends true> = T import Expect
@module — Types utility.
<Equal<'posts',key>>
(alias) type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false import Equal
}) it('Should throw type errors', (c) => {
type key = "posts"
try { // @ts-expect-error app
(parameter) c: any
.get(['foo', 'bar'],
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
poweredBy())
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.get: HandlerInterface <string, BlankInput, {}, HandlerResponse<any>, { Bindings: { Token: string; }; }, any>(handlers_0: H<{ Bindings: { Token: string; }; }, string, BlankInput, any>, handlers_1: H<...>) => Hono<...> (+22 overloads)
// @ts-expect-error app
(alias) poweredBy(): MiddlewareHandler import poweredBy
.use(['foo', 'bar'],
const app: Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">
poweredBy())
(property) Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/">.use: MiddlewareHandlerInterface <any>(...handlers: MiddlewareHandler<any, never, {}>[]) => Hono<{ Bindings: { Token: string; }; }, BlankSchema, "/"> (+20 overloads)
} catch {} }) }) describe('Compatible with extended Hono classes, such Zod OpenAPI Hono.', () => { class ExtendedHono extends
(alias) poweredBy(): MiddlewareHandler import poweredBy
Hono {
class ExtendedHono
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
// @ts-ignore routeBasePath
— The base path type.
(method) ExtendedHono.route(path: string, app?: Hono): this
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
(path: string,app?:
(parameter) path: string
Hono) {
(parameter) app: Hono<BlankEnv, BlankSchema, "/"> | undefined
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> import Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
// @ts-ignore super.routeBasePath
— The base path type.
(method) Hono<BlankEnv, BlankSchema, "/">.route<string, BlankEnv, BlankSchema, "/">(path: string, app: Hono<BlankEnv, BlankSchema, "/">): Hono<BlankEnv, {}, "/">
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
(path,app)
(parameter) path: string
return this } // @ts-ignore basePath
(parameter) app: Hono<BlankEnv, BlankSchema, "/"> | undefined
(method) ExtendedHono.basePath(path: string): ExtendedHono
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
(path: string) {
ts const api = new Hono().basePath('/api')
return new ExtendedHono(super
(parameter) path: string
constructor ExtendedHono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): ExtendedHono
Creates an instance of the Hono class.@param
.basePathoptions
— Optional configuration options for the Hono instance.
(method) Hono<BlankEnv, BlankSchema, "/">.basePath<string>(path: string): Hono<BlankEnv, BlankSchema, string>
.basePath()
allows base paths to be specified.@see — https://hono.dev/docs/api/routing#base-path
@param
path
— base Path@returns — changed Hono instance
@example
(path))
ts const api = new Hono().basePath('/api')
} } const a = new
(parameter) path: string
ExtendedHono()
const a: ExtendedHono
constructor ExtendedHono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): ExtendedHono
Creates an instance of the Hono class.@param
const sub = newoptions
— Optional configuration options for the Hono instance.Hono()
const sub: Hono<BlankEnv, BlankSchema, "/">
(alias) new Hono<BlankEnv, BlankSchema, "/">(options?: HonoOptions<BlankEnv>): Hono<BlankEnv, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
suboptions
— Optional configuration options for the Hono instance..get('/foo',
const sub: Hono<BlankEnv, BlankSchema, "/">
(c) =>
(property) Hono<BlankEnv, BlankSchema, "/">.get: HandlerInterface <"/foo", "/foo", Response & TypedResponse<"foo", StatusCode, "text">, BlankInput, BlankEnv>(path: "/foo", handler: H<BlankEnv, "/foo", BlankInput, Response & TypedResponse<...>>) => Hono<...> (+22 overloads)
c
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
.text('foo'))
(parameter) c: Context<BlankEnv, "/foo", BlankInput>
a
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"foo", StatusCode>(text: "foo", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"foo", StatusCode, "text"> (+1 overload)
.route('/sub',
const a: ExtendedHono
(method) ExtendedHono.route(path: string, app?: Hono): ExtendedHono
.route()
allows grouping other Hono instance in routes.@see — https://hono.dev/docs/api/routing#grouping
@param
path
— base Path@param
app
— other Hono instance@returns — 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 ```
sub)it('Should return 200 response', async () => { const res = await
const sub: Hono<BlankEnv, BlankSchema, "/">
a
const res: Response
.request('/sub/foo')
const a: ExtendedHono
(property) Hono<BlankEnv, BlankSchema, "/">.request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: unknown, 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
expect(res.status).toBe(200)
const res: Response
}) }) describe('Generics for Bindings and Variables', () => { interface CloudflareBindings {
(property) Response.status: number
MDN ReferenceMY_VARIABLE: string
interface CloudflareBindings
} it('Should not throw type errors', () => { // @ts-expect-error Bindings should extend object new Hono<{
(property) CloudflareBindings.MY_VARIABLE: string
(alias) new Hono<{ Bindings: number; }, BlankSchema, "/">(options?: HonoOptions<{ Bindings: number; }>): Hono<{ Bindings: number; }, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
Bindings: numberoptions
— Optional configuration options for the Hono instance.}>() const appWithInterface = new
(property) Bindings: number
Hono<{
const appWithInterface: Hono<{ Bindings: CloudflareBindings; }, BlankSchema, "/">
(alias) new Hono<{ Bindings: CloudflareBindings; }, BlankSchema, "/">(options?: HonoOptions<{ Bindings: CloudflareBindings; }>): Hono<...> import Hono
Creates an instance of the Hono class.@param
Bindings:options
— Optional configuration options for the Hono instance.CloudflareBindings
(property) Bindings: CloudflareBindings
}>() appWithInterface
interface CloudflareBindings
.get('/',
const appWithInterface: Hono<{ Bindings: CloudflareBindings; }, BlankSchema, "/">
(c) => {
(property) Hono<{ Bindings: CloudflareBindings; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"/", StatusCode, "text">, BlankInput, { Bindings: CloudflareBindings; }>(path: "/", handler: H<...>) => Hono<...> (+22 overloads)
expectTypeOf(c
(parameter) c: Context<{ Bindings: CloudflareBindings; }, "/", BlankInput>
.env
(parameter) c: Context<{ Bindings: CloudflareBindings; }, "/", BlankInput>
(property) Context<{ Bindings: CloudflareBindings; }, "/", BlankInput>.env: CloudflareBindings
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
.MY_VARIABLE).toMatchTypeOf
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
() return c
(property) CloudflareBindings.MY_VARIABLE: string
.text('/')
(parameter) c: Context<{ Bindings: CloudflareBindings; }, "/", BlankInput>
}) const appWithType = new
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"/", StatusCode>(text: "/", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<"/", StatusCode, "text"> (+1 overload)
Hono<{
const appWithType: Hono<{ Bindings: { foo: string; }; }, BlankSchema, "/">
(alias) new Hono<{ Bindings: { foo: string; }; }, BlankSchema, "/">(options?: HonoOptions<{ Bindings: { foo: string; }; }>): Hono<{ Bindings: { foo: string; }; }, BlankSchema, "/"> import Hono
Creates an instance of the Hono class.@param
Bindings: {options
— Optional configuration options for the Hono instance.foo: string
(property) Bindings: { foo: string; }
} }>() appWithType
(property) foo: string
.get('/',
const appWithType: Hono<{ Bindings: { foo: string; }; }, BlankSchema, "/">
(c) => {
(property) Hono<{ Bindings: { foo: string; }; }, BlankSchema, "/">.get: HandlerInterface <"/", "/", Response & TypedResponse<"Hello Hono!", StatusCode, "text">, BlankInput, { Bindings: { foo: string; }; }>(path: "/", handler: H<...>) => Hono<...> (+22 overloads)
expectTypeOf(c
(parameter) c: Context<{ Bindings: { foo: string; }; }, "/", BlankInput>
.env
(parameter) c: Context<{ Bindings: { foo: string; }; }, "/", BlankInput>
(property) Context<{ Bindings: { foo: string; }; }, "/", BlankInput>.env: { foo: string; }
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.@see — https://hono.dev/docs/api/context#env
@example
.foo).toMatchTypeOf
ts // Environment object for Cloudflare Workers app.get('*', async c => { const counter = c.env.COUNTER })
() return c
(property) foo: string
.text('Hello Hono!')
(parameter) c: Context<{ Bindings: { foo: string; }; }, "/", BlankInput>
}) }) })
(property) Context<E extends Env = any, P extends string = any, I extends Input = {}>.text: TextRespond <"Hello Hono!", StatusCode>(text: "Hello Hono!", status?: StatusCode | undefined, headers?: HeaderRecord) => Response & TypedResponse<...> (+1 overload)
import { HonoBase } from './hono-base' import type { HonoOptions } from './hono-base' import { RegExpRouter } from './router/reg-exp-router' import { SmartRouter } from './router/smart-router' import { TrieRouter } from './router/trie-router' import type { BlankEnv, BlankSchema, Env, Schema } from './types' /** * The Hono class extends the functionality of the HonoBase class. * It sets up routing and allows for custom options to be passed. * * @template E - The environment type. * @template S - The schema type. * @template BasePath - The base path type. */ export class Hono<
class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/">
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
E extendsBasePath
— The base path type.
(type parameter) E in Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/">
- The environment type.@template
Env =E
— The environment type.BlankEnv,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } import Env
S extends
(alias) type BlankEnv = {} import BlankEnv
(type parameter) S in Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/">
- The schema type.@template
Schema =S
— The schema type.BlankSchema,
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } import Schema
BasePath extends string = '/'
(alias) type BlankSchema = {} import BlankSchema
(type parameter) BasePath in Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/">
- The base path type.@template
> extends HonoBaseBasePath
— The base path type.<E,
(alias) class HonoBase<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/"> import HonoBase
(type parameter) E in Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/">
- The environment type.@template
S,E
— The environment type.
(type parameter) S in Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/">
- The schema type.@template
BasePath> {S
— The schema type.
(type parameter) BasePath in Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/">
- The base path type.@template
/** * Creates an instance of the Hono class. * * @param options - Optional configuration options for the Hono instance. */ constructor(options:BasePath
— The base path type.
(parameter) options: HonoOptions<E>
- Optional configuration options for the Hono instance.@param
HonoOptionsoptions
— Optional configuration options for the Hono instance.<E> = {}) {
(alias) type HonoOptions<E extends Env> = { strict?: boolean; router?: Router<[H, RouterRoute]>; getPath?: GetPath<E>; } import HonoOptions
(type parameter) E in Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/">
- The environment type.@template
super(options)E
— The environment type.
(parameter) options: HonoOptions<E>
- Optional configuration options for the Hono instance.@param
this.router =options
— Optional configuration options for the Hono instance.options
(property) Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">.router: Router<[H, RouterRoute]>
(parameter) options: HonoOptions<E>
- Optional configuration options for the Hono instance.@param
.router ??options
— Optional configuration options for the Hono instance.
(property) router?: Router<[H, RouterRoute]> | undefined
router
option specifices which router to use.@see — https://hono.dev/docs/api/hono#router-option
@example
new SmartRouter({
ts const app = new Hono({ router: new RegExpRouter() })
routers: [new
(alias) new SmartRouter<[H, RouterRoute]>(init: Pick<SmartRouter<[H, RouterRoute]>, "routers">): SmartRouter<[H, RouterRoute]> import SmartRouter
RegExpRouter(), new
(property) routers: Router<[H, RouterRoute]>[]
TrieRouter()],
(alias) new RegExpRouter<[H, RouterRoute]>(): RegExpRouter<[H, RouterRoute]> import RegExpRouter
}) } }
(alias) new TrieRouter<[H, RouterRoute]>(): TrieRouter<[H, RouterRoute]> import TrieRouter
import { HTTPException } from './http-exception' describe('HTTPException', () => { it('Should be 401 HTTP exception object', async () => { // We should throw an exception if is not authorized // because next handlers should not be fired. const exception = newHTTPException(401, {
const exception: HTTPException
(alias) new HTTPException(status?: StatusCode, options?: HTTPExceptionOptions): HTTPException import HTTPException
Creates an instance ofHTTPException
.@param
status
— HTTP status code for the exception. Defaults to 500.@param
message: 'Unauthorized',options
— Additional options for the exception.}) const res =
(property) message?: string | undefined
exception
const res: Response
.getResponse()
const exception: HTTPException
(method) HTTPException.getResponse(): Response
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.
expect(res.status).toBe(401)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Unauthorized')
const res: Response
expect(exception
(method) Body.text(): Promise<string>
MDN Reference.status).toBe(401)
const exception: HTTPException
expect(exception
(property) HTTPException.status: StatusCode
.message).toBe('Unauthorized')
const exception: HTTPException
}) it('Should be accessible to the object causing the exception', async () => { // We should pass the cause of the error to the cause option // because it makes debugging easier. const error = new
(property) Error.message: string
Error('Server Error')
const error: Error
const exception = new
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
HTTPException(500, {
const exception: HTTPException
(alias) new HTTPException(status?: StatusCode, options?: HTTPExceptionOptions): HTTPException import HTTPException
Creates an instance ofHTTPException
.@param
status
— HTTP status code for the exception. Defaults to 500.@param
message: 'Internal Server Error',options
— Additional options for the exception.cause:
(property) message?: string | undefined
error,
(property) cause?: unknown
}) const res =
const error: Error
exception
const res: Response
.getResponse()
const exception: HTTPException
(method) HTTPException.getResponse(): Response
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.
expect(res.status).toBe(500)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('Internal Server Error')
const res: Response
expect(exception
(method) Body.text(): Promise<string>
MDN Reference.status).toBe(500)
const exception: HTTPException
expect(exception
(property) HTTPException.status: StatusCode
.message).toBe('Internal Server Error')
const exception: HTTPException
expect(exception
(property) Error.message: string
.cause).toBe
const exception: HTTPException
(error)
(property) Error.cause?: unknown
}) it('Should prioritize the status code over the code in the response', async () => { const exception = new
const error: Error
HTTPException(400, {
const exception: HTTPException
(alias) new HTTPException(status?: StatusCode, options?: HTTPExceptionOptions): HTTPException import HTTPException
Creates an instance ofHTTPException
.@param
status
— HTTP status code for the exception. Defaults to 500.@param
res: newoptions
— Additional options for the exception.Response('An exception', {
(property) res?: Response | undefined
status: 200,
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.}), }) const res =
(property) ResponseInit.status?: number | undefined
exception
const res: Response
.getResponse()
const exception: HTTPException
(method) HTTPException.getResponse(): Response
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.
expect(res.status).toBe(400)
const res: Response
expect(await res
(property) Response.status: number
MDN Reference.text()).toBe('An exception')
const res: Response
}) })
(method) Body.text(): Promise<string>
MDN Reference
/** * @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 = {
type HTTPExceptionOptions = { res?: Response; message?: string; cause?: unknown; }
Options for creating anHTTPException
.@property — res - Optional response object to use.
@property — message - Optional custom error message.
@property — cause - Optional cause of the error.
res?:Response
(property) res?: Response | undefined
message?: string
interface Response
This Fetch API interface represents the response to a request.cause?: unknown
(property) message?: string | undefined
} /** * `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 class HTTPException extends
(property) cause?: unknown
class HTTPException
HTTPException
must be used when a fatal error such as authentication failure occurs.@see — https://hono.dev/docs/api/exception
@param
status
— status code of HTTPException@param
options
— options of HTTPException@param
options.res
— response of options of HTTPException@param
options.message
— message of options of HTTPException@param
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() }) ```
Error {readonly res?:
var Error: ErrorConstructor
Response
(property) HTTPException.res?: Response | undefined
readonly status:
interface Response
This Fetch API interface represents the response to a request.StatusCode
(property) HTTPException.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:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.
(parameter) status: StatusCode
- HTTP status code for the exception. Defaults to 500.@param
StatusCode = 500,status
— HTTP status code for the exception. Defaults to 500.options?:
(alias) type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | -1 import StatusCode
If you want to use an unofficial status, useUnofficialStatusCode
.
(parameter) options: HTTPExceptionOptions | undefined
- Additional options for the exception.@param
HTTPExceptionOptions) {options
— Additional options for the exception.
type HTTPExceptionOptions = { res?: Response; message?: string; cause?: unknown; }
Options for creating anHTTPException
.@property — res - Optional response object to use.
@property — message - Optional custom error message.
@property — cause - Optional cause of the error.
super(options?
(parameter) options: HTTPExceptionOptions | undefined
- Additional options for the exception.@param
.message, {options
— Additional options for the exception.cause:
(property) message?: string | undefined
options?
(property) ErrorOptions.cause?: unknown
(parameter) options: HTTPExceptionOptions | undefined
- Additional options for the exception.@param
.cause })options
— Additional options for the exception.this.res =
(property) cause?: unknown
options?
(property) HTTPException.res?: Response | undefined
(parameter) options: HTTPExceptionOptions | undefined
- Additional options for the exception.@param
.resoptions
— Additional options for the exception.this.status =
(property) res?: Response | undefined
status
(property) HTTPException.status: StatusCode
(parameter) status: StatusCode
- HTTP status code for the exception. Defaults to 500.@param
} /** * 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():status
— HTTP status code for the exception. Defaults to 500.
(method) HTTPException.getResponse(): Response
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.
Response {if (this.res) {
interface Response
This Fetch API interface represents the response to a request.const newResponse = new
(property) HTTPException.res?: Response | undefined
Response(this
const newResponse: Response
.res
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request..body, {
(property) HTTPException.res?: Response
status: this
(property) Body.body: ReadableStream<Uint8Array> | null
MDN Reference.status,
(property) ResponseInit.status?: number | undefined
headers: this
(property) HTTPException.status: StatusCode
.res
(property) ResponseInit.headers?: HeadersInit | undefined
.headers,
(property) HTTPException.res?: Response
}) return newResponse
(property) Response.headers: Headers
MDN Reference} return new Response(this
const newResponse: Response
.message, {
var Response: new (body?: BodyInit | null, init?: ResponseInit) => Response
This Fetch API interface represents the response to a request.status: this
(property) Error.message: string
.status,
(property) ResponseInit.status?: number | undefined
}) } }
(property) HTTPException.status: StatusCode
/** * @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,
(alias) type Env = { Bindings?: Bindings; Variables?: Variables; } export Env
Handler,
(alias) type ErrorHandler<E extends Env = any> = (err: Error | HTTPResponseError, c: Context<E>) => Response | Promise<Response> export ErrorHandler
MiddlewareHandler,
(alias) 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 Handler
Next,
(alias) type MiddlewareHandler<E extends Env = any, P extends string = string, I extends Input = {}> = (c: Context<E, P, I>, next: Next) => Promise<Response | void> export MiddlewareHandler
NotFoundHandler,
(alias) type Next = () => Promise<void> export Next
ValidationTargets,
(alias) type NotFoundHandler<E extends Env = any> = (c: Context<E>) => Response | Promise<Response> export NotFoundHandler
Input,
(alias) 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<string, string>; cookie: Record<string, string>; } export ValidationTargets
Schema,
(alias) type Input = { in?: {}; out?: {}; outputFormat?: ResponseFormat; } export Input
ToSchema,
(alias) type Schema = { [Path: string]: { [Method: `$${Lowercase<string>}`]: Endpoint; }; } export Schema
TypedResponse,
(alias) type ToSchema<M extends string, P extends string, I extends Input | Input["in"], RorO> = { [KeyType in keyof { [K in P]: { [K2 in M as `$${Lowercase<K2>}`]: { [KeyType in keyof ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))]: ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))[KeyType]; }; }; }]: { [K in P]: { [K2 in M as `$${Lowercase<K2>}`]: { [KeyType in keyof ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))]: ({ input: AddParam<ExtractInput<I>, P>; } & (IsAny<RorO> extends true ? { ...; } : RorO extends TypedResponse<...> ? { ...; } : { ...; }))[KeyType]; }; }; }[KeyType]; } export ToSchema
} from './types' /** * Types for context, context variable map, context renderer, and execution context. */ export type { Context,
(alias) type TypedResponse<T = unknown, U extends StatusCode = StatusCode, F extends ResponseFormat = T extends string ? "text" : T extends JSONValue ? "json" : string> = { _data: T; _status: U; _format: F; } export TypedResponse
ContextVariableMap,
(alias) class Context<E extends Env = any, P extends string = any, I extends Input = {}> export Context
ContextRenderer,
(alias) interface ContextVariableMap export ContextVariableMap
Interface for context variable mapping.ExecutionContext } from './context'
(alias) interface ContextRenderer export ContextRenderer
Interface for context renderer./** * Type for HonoRequest. */ export type { HonoRequest } from './request'
(alias) interface ExecutionContext export ExecutionContext
Interface for the execution context in a web worker or similar environment./** * Types for inferring request and response types and client request options. */ export type { InferRequestType,
(alias) class HonoRequest<P extends string = "/", I extends Input["out"] = {}> export HonoRequest
InferResponseType,
(alias) type InferRequestType<T> = T extends (args: infer R, options: any | undefined) => Promise<ClientResponse<unknown>> ? NonNullable<R> : never export InferRequestType
ClientRequestOptions } from './client'
(alias) type InferResponseType<T, U extends StatusCode = StatusCode> = InferEndpointType<T> extends { output: infer O; status: infer S; } ? S extends U ? O : never : never export InferResponseType
/** * Hono framework for building web applications. */ export { Hono }
(alias) type ClientRequestOptions<T = unknown> = { fetch?: typeof fetch | ((input: RequestInfo | URL, requestInit?: RequestInit, Env?: any, executionCtx?: ExecutionContext) => Response | Promise<Response>); webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket; init?: RequestInit; } & (keyof T extends never ? { ...; } : { ...; }) export ClientRequestOptions
(alias) class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> export Hono
The Hono class extends the functionality of the HonoBase class. It sets up routing and allows for custom options to be passed.@template
E
— The environment type.@template
S
— The schema type.@template
BasePath
— The base path type.
import { raw } from '../helper/html' import { escapeToBuffer, resolveCallbackSync, stringBufferToString } from '../utils/html' import type { HtmlEscaped, HtmlEscapedString, StringBufferWithCallbacks } from '../utils/html' import { DOM_RENDERER } from './constants' import type { Context } from './context' import { createContext, globalContexts, useContext } from './context' import { domRenderers } from './intrinsic-element/common' import * as intrinsicElementTags from './intrinsic-element/components' import type { JSX as HonoJSX, IntrinsicElements as IntrinsicElementsDefined, } from './intrinsic-elements' import { normalizeIntrinsicElementKey, styleObjectForEach } from './utils' // eslint-disable-next-line @typescript-eslint/no-explicit-any export type Props =Record
type Props = { [x: string]: any; }
export type FC
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T<P =
type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; }
Props> = {
(type parameter) P in type FC<P = Props>
(props:
type Props = { [x: string]: any; }
P):
(parameter) props: P = Props
HtmlEscapedString |
(type parameter) P in type FC<P = Props>
Promise
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
<HtmlEscapedString> | null
interface Promise<T>
Represents the completion of an asynchronous operationdefaultProps?:
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
Partial
(property) defaultProps?: Partial<P> | undefined
<P> | undefined
type Partial<T> = { [P in keyof T]?: T[P] | undefined; }
Make all properties in T optionaldisplayName?: string | undefined
(type parameter) P in type FC<P = Props>
} export type DOMAttributes =
(property) displayName?: string | undefined
HonoJSX
type DOMAttributes = HonoJSX.HTMLAttributes
.HTMLAttributes
(alias) namespace HonoJSX import HonoJSX
This code is based on React. https://github.com/facebook/react MIT License Copyright (c) Meta Platforms, Inc. and affiliates.// eslint-disable-next-line @typescript-eslint/no-namespace export namespace JSX {
interface JSX.HTMLAttributes
export type Element =
namespace JSX
HtmlEscapedString |
type JSX.Element = HtmlEscapedString | Promise<HtmlEscapedString>
Promise
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
<HtmlEscapedString>
interface Promise<T>
Represents the completion of an asynchronous operationexport interface ElementChildrenAttribute {
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
children:
interface JSX.ElementChildrenAttribute
Child
(property) JSX.ElementChildrenAttribute.children: Child
} export interface IntrinsicElements extends
type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
IntrinsicElementsDefined {
interface JSX.IntrinsicElements
[tagName: string]:
(alias) interface IntrinsicElementsDefined import IntrinsicElementsDefined
Props
(parameter) tagName: string
} export interface IntrinsicAttributes {
type Props = { [x: string]: any; }
key?: string | number | bigint | null | undefined
interface JSX.IntrinsicAttributes
} } let nameSpaceContext:
(property) JSX.IntrinsicAttributes.key?: string | number | bigint | null | undefined
Context
let nameSpaceContext: Context<string> | undefined
| undefined = undefined export const getNameSpaceContext = () =>
(alias) interface Context<T> import Context
nameSpaceContext
const getNameSpaceContext: () => Context<string> | undefined
const toSVGAttributeName =
let nameSpaceContext: Context<string> | undefined
(key: string): string =>
const toSVGAttributeName: (key: string) => string
/[A-Z]/.test
(parameter) key: string
(method) RegExp.test(string: string): boolean
Returns a Boolean value that indicates whether or not a pattern exists in a searched string.@param
(key) &&string
— String on which to perform the search.// Presentation attributes are findable in style object. "clip-path", "font-size", "stroke-width", etc. // Or other un-deprecated kebab-case attributes. "overline-position", "paint-order", "strikethrough-position", etc. key
(parameter) key: string
.match(
(parameter) key: string
(method) String.match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null (+1 overload)
Matches a string or an object that supports being matched against, and returns an array containing the results of that search, or null if no matches are found.@param
/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/ ) ? keymatcher
— An object that supports being matched against..replace(/([A-Z])/g, '-$1')
(parameter) key: string
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
.toLowerCase()replaceValue
— The replacement text.: key
(method) String.toLowerCase(): string
Converts all the alphabetic characters in a string to lowercase.const emptyTags = [
(parameter) key: string
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr', ] export const booleanAttributes = [
const emptyTags: string[]
'allowfullscreen', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'inert', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', ] const childrenToStringToBuffer =
const booleanAttributes: string[]
(children:
const childrenToStringToBuffer: (children: Child[], buffer: StringBufferWithCallbacks) => void
Child[],
(parameter) children: Child[]
buffer:
type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
StringBufferWithCallbacks): void => {
(parameter) buffer: StringBufferWithCallbacks
for (let i = 0,
(alias) type StringBufferWithCallbacks = StringBuffer & { callbacks: HtmlEscapedCallback[]; } import StringBufferWithCallbacks
len =
let i: number
children
let len: number
.length;
(parameter) children: Child[]
i <
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.len;
let i: number
i++) {
let len: number
const child =
let i: number
children
const child: Child
[i]
(parameter) children: Child[]
if (typeof child === 'string') {
let i: number
escapeToBuffer
const child: Child
(child,
(alias) escapeToBuffer(str: string, buffer: StringBuffer): void import escapeToBuffer
buffer)
const child: string
} else if (typeof child === 'boolean' ||
(parameter) buffer: StringBufferWithCallbacks
child === null ||
const child: number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
child === undefined) {
const child: number | Promise<string> | JSXNode | Child[] | null | undefined
continue } else if (child instanceof
const child: number | Promise<string> | JSXNode | Child[] | undefined
JSXNode) {
const child: number | Promise<string> | JSXNode | Child[]
child
class JSXNode
.toStringToBuffer
const child: JSXNode
(buffer)
(method) JSXNode.toStringToBuffer(buffer: StringBufferWithCallbacks): void
} else if ( typeof child === 'number' ||
(parameter) buffer: StringBufferWithCallbacks
(child as unknown as {
const child: number | Promise<string> | Child[]
isEscaped: boolean })
const child: Promise<string> | Child[]
.isEscaped
(property) isEscaped: boolean
) { ;(buffer[0] as string) +=
(property) isEscaped: boolean
child
(parameter) buffer: StringBufferWithCallbacks
} else if (child instanceof
const child: number | Promise<string> | Child[]
Promise) {
const child: Promise<string> | Child[]
buffer
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.unshift('',
(parameter) buffer: StringBufferWithCallbacks
(method) Array<string | Promise<string>>.unshift(...items: (string | Promise<string>)[]): number
Inserts new elements at the start of an array, and returns the new length of the array.@param
child)items
— Elements to insert at the start of the array.} else { // `child` type is `Child[]`, so stringify recursively childrenToStringToBuffer
const child: Promise<string>
(child,
const childrenToStringToBuffer: (children: Child[], buffer: StringBufferWithCallbacks) => void
buffer)
const child: Child[]
} } } type LocalContexts =
(parameter) buffer: StringBufferWithCallbacks
[Context
type LocalContexts = [Context<unknown>, unknown][]
, unknown][] export type Child =
(alias) interface Context<T> import Context
| string | Promise
type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
| number | JSXNode
interface Promise<T>
Represents the completion of an asynchronous operation| null | undefined | boolean | Child[]
class JSXNode
export class JSXNode implements
type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
HtmlEscaped {
class JSXNode
tag: string |
(alias) type HtmlEscaped = { isEscaped: true; callbacks?: HtmlEscapedCallback[]; } import HtmlEscaped
Function
(property) JSXNode.tag: string | Function
props:
interface Function
Creates a new function.Props
(property) JSXNode.props: Props
key?: string
type Props = { [x: string]: any; }
children:
(property) JSXNode.key?: string | undefined
Child[]
(property) JSXNode.children: Child[]
isEscaped: true = true as
type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
const
(property) JSXNode.isEscaped: true
localContexts?:
type const = true
LocalContexts
(property) JSXNode.localContexts?: LocalContexts | undefined
constructor(tag: string |
type LocalContexts = [Context<unknown>, unknown][]
Function,
(parameter) tag: string | Function
props:
interface Function
Creates a new function.Props,
(parameter) props: Props
children:
type Props = { [x: string]: any; }
Child[]) {
(parameter) children: Child[]
this.tag =
type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
tag
(property) JSXNode.tag: string | Function
this.props =
(parameter) tag: string | Function
props
(property) JSXNode.props: Props
this.children =
(parameter) props: Props
children
(property) JSXNode.children: Child[]
} get type(): string |
(parameter) children: Child[]
Function {
(getter) JSXNode.type: string | Function
return this.tag as string
interface Function
Creates a new function.} // Added for compatibility with libraries that rely on React's internal structure // eslint-disable-next-line @typescript-eslint/no-explicit-any get ref(): any {
(property) JSXNode.tag: string | Function
return this.props.ref || null
(getter) JSXNode.ref: any
} toString(): string |
(property) JSXNode.props: Props
Promise
(method) JSXNode.toString(): string | Promise<string>
Returns a string representation of an object.{ const buffer:
interface Promise<T>
Represents the completion of an asynchronous operationStringBufferWithCallbacks = [''] as
const buffer: StringBufferWithCallbacks
StringBufferWithCallbacks
(alias) type StringBufferWithCallbacks = StringBuffer & { callbacks: HtmlEscapedCallback[]; } import StringBufferWithCallbacks
this.localContexts?
(alias) type StringBufferWithCallbacks = StringBuffer & { callbacks: HtmlEscapedCallback[]; } import StringBufferWithCallbacks
.forEach((
(property) JSXNode.localContexts?: LocalContexts | undefined
(method) Array<[Context<unknown>, unknown]>.forEach(callbackfn: (value: [Context<unknown>, unknown], index: number, array: [Context<unknown>, unknown][]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
[context,thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.value]) => {
(parameter) context: Context<unknown>
context
(parameter) value: unknown
.values
(parameter) context: Context<unknown>
.push
(property) Context<unknown>.values: unknown[]
(method) Array<unknown>.push(...items: unknown[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(value)items
— New elements to add to the array.}) try { this.toStringToBuffer
(parameter) value: unknown
(buffer)
(method) JSXNode.toStringToBuffer(buffer: StringBufferWithCallbacks): void
} finally { this.localContexts?
const buffer: StringBufferWithCallbacks
.forEach((
(property) JSXNode.localContexts?: LocalContexts | undefined
(method) Array<[Context<unknown>, unknown]>.forEach(callbackfn: (value: [Context<unknown>, unknown], index: number, array: [Context<unknown>, unknown][]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
[context]) => {thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.context
(parameter) context: Context<unknown>
.values
(parameter) context: Context<unknown>
.pop()
(property) Context<unknown>.values: unknown[]
}) } return buffer
(method) Array<unknown>.pop(): unknown
Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified..length === 1
const buffer: StringBufferWithCallbacks
? 'callbacks' in buffer
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.? resolveCallbackSync
const buffer: StringBufferWithCallbacks
(raw
(alias) resolveCallbackSync(str: string | HtmlEscapedString): string import resolveCallbackSync
(buffer[0],
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
buffer
const buffer: StringBufferWithCallbacks
.callbacks))
const buffer: StringBufferWithCallbacks
.toString()
(property) callbacks: HtmlEscapedCallback[]
: buffer[0]
(method) String.toString(): string
Returns a string representation of a string.: stringBufferToString
const buffer: never
(buffer,
(alias) stringBufferToString(buffer: StringBuffer, callbacks: HtmlEscapedCallback[] | undefined): Promise<HtmlEscapedString> import stringBufferToString
buffer
const buffer: StringBufferWithCallbacks
.callbacks)
const buffer: StringBufferWithCallbacks
} toStringToBuffer
(property) callbacks: HtmlEscapedCallback[]
(buffer:
(method) JSXNode.toStringToBuffer(buffer: StringBufferWithCallbacks): void
StringBufferWithCallbacks): void {
(parameter) buffer: StringBufferWithCallbacks
const tag = this
(alias) type StringBufferWithCallbacks = StringBuffer & { callbacks: HtmlEscapedCallback[]; } import StringBufferWithCallbacks
.tag as string
const tag: string
const props = this
(property) JSXNode.tag: string | Function
.props
const props: Props
let { children } = this
(property) JSXNode.props: Props
buffer[0] += `<$
let children: Child[]
{tag}`
(parameter) buffer: StringBufferWithCallbacks
const normalizeKey:
const tag: string
(key: string) => string =
const normalizeKey: (key: string) => string
nameSpaceContext &&
(parameter) key: string
useContext
let nameSpaceContext: Context<string> | undefined
(nameSpaceContext) === 'svg'
(alias) useContext<string>(context: Context<string>): string import useContext
? (key) =>
let nameSpaceContext: Context<string>
toSVGAttributeName
(parameter) key: string
(normalizeIntrinsicElementKey
const toSVGAttributeName: (key: string) => string
(key))
(alias) normalizeIntrinsicElementKey(key: string): string import normalizeIntrinsicElementKey
: (key) =>
(parameter) key: string
normalizeIntrinsicElementKey
(parameter) key: string
(key)
(alias) normalizeIntrinsicElementKey(key: string): string import normalizeIntrinsicElementKey
for (let [key,
(parameter) key: string
v] of
let key: string
Object
let v: any
.entries
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.entries<any>(o: { [s: string]: any; } | ArrayLike<any>): [string, any][] (+1 overload)
Returns an array of key/values of the enumerable own properties of an object@param
(props)) {o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.key =
const props: Props
normalizeKey
let key: string
(key)
const normalizeKey: (key: string) => string
if (key === 'children') {
let key: string
// skip children } else if (key === 'style' && typeof
let key: string
v === 'object') {
let key: string
// object to style strings let styleStr = ''
let v: any
styleObjectForEach
let styleStr: string
(v,
(alias) styleObjectForEach(style: Record<string, string | number>, fn: (key: string, value: string | null) => void): void import styleObjectForEach
(property,
let v: any
value) => {
(parameter) property: string
if (value != null) {
(parameter) value: string | null
styleStr += `$
(parameter) value: string | null
{styleStr ? ';' : ''}$
let styleStr: string
{property}:$
let styleStr: string
{value}`
(parameter) property: string
} }) buffer[0] += ' style="'
(parameter) value: string
escapeToBuffer
(parameter) buffer: StringBufferWithCallbacks
(styleStr,
(alias) escapeToBuffer(str: string, buffer: StringBuffer): void import escapeToBuffer
buffer)
let styleStr: string
buffer[0] += '"'
(parameter) buffer: StringBufferWithCallbacks
} else if (typeof v === 'string') {
(parameter) buffer: StringBufferWithCallbacks
buffer[0] += ` $
let v: any
{key}="`
(parameter) buffer: StringBufferWithCallbacks
escapeToBuffer
let key: string
(v,
(alias) escapeToBuffer(str: string, buffer: StringBuffer): void import escapeToBuffer
buffer)
let v: string
buffer[0] += '"'
(parameter) buffer: StringBufferWithCallbacks
} else if (v === null ||
(parameter) buffer: StringBufferWithCallbacks
v === undefined) {
let v: any
// Do nothing } else if (typeof v === 'number' ||
let v: any
(v as
let v: any
HtmlEscaped)
let v: any
.isEscaped) {
(alias) type HtmlEscaped = { isEscaped: true; callbacks?: HtmlEscapedCallback[]; } import HtmlEscaped
buffer[0] += ` $
(property) isEscaped: true
{key}="$
(parameter) buffer: StringBufferWithCallbacks
{v}"`
let key: string
} else if (typeof v === 'boolean' &&
let v: any
booleanAttributes
let v: any
.includes
const booleanAttributes: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
(key)) {fromIndex
— The position in this array at which to begin searching for searchElement.if (v) {
let key: string
buffer[0] += ` $
let v: boolean
{key}=""`
(parameter) buffer: StringBufferWithCallbacks
} } else if (key === 'dangerouslySetInnerHTML') {
let key: string
if (children
let key: string
.length > 0) {
let children: Child[]
throw 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.' } children =
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.[raw
let children: Child[]
(v.__html)]
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
} else if (v instanceof
let v: any
Promise) {
let v: any
buffer[0] += ` $
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation{key}="`
(parameter) buffer: StringBufferWithCallbacks
buffer
let key: string
.unshift('"',
(parameter) buffer: StringBufferWithCallbacks
(method) Array<string | Promise<string>>.unshift(...items: (string | Promise<string>)[]): number
Inserts new elements at the start of an array, and returns the new length of the array.@param
v)items
— Elements to insert at the start of the array.} else if (typeof v === 'function') {
let v: Promise<any>
if (!key
let v: any
.startsWith('on')) {
let key: string
throw `Invalid prop '${key}' of type 'function' supplied to '$
(method) String.startsWith(searchString: string, position?: number): boolean
Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false.{tag}'.`
let key: string
} // maybe event handler for client components, just ignore in server components } else { buffer[0] += ` $
const tag: string
{key}="`
(parameter) buffer: StringBufferWithCallbacks
escapeToBuffer
let key: string
(v.toString(),
(alias) escapeToBuffer(str: string, buffer: StringBuffer): void import escapeToBuffer
buffer)
let v: any
buffer[0] += '"'
(parameter) buffer: StringBufferWithCallbacks
} } if (emptyTags
(parameter) buffer: StringBufferWithCallbacks
.includes
const emptyTags: string[]
(method) Array<string>.includes(searchElement: string, fromIndex?: number): boolean
Determines whether an array includes a certain element, returning true or false as appropriate.@param
searchElement
— The element to search for.@param
(tag as string) &&fromIndex
— The position in this array at which to begin searching for searchElement.children
const tag: string
.length === 0) {
let children: Child[]
buffer[0] += '/>'
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.return } buffer[0] += '>'
(parameter) buffer: StringBufferWithCallbacks
childrenToStringToBuffer
(parameter) buffer: StringBufferWithCallbacks
(children,
const childrenToStringToBuffer: (children: Child[], buffer: StringBufferWithCallbacks) => void
buffer)
let children: Child[]
buffer[0] += `$
(parameter) buffer: StringBufferWithCallbacks
{tag}>`
(parameter) buffer: StringBufferWithCallbacks
} } class JSXFunctionNode extends
const tag: string
JSXNode {
class JSXFunctionNode
toStringToBuffer
class JSXNode
(buffer:
(method) JSXFunctionNode.toStringToBuffer(buffer: StringBufferWithCallbacks): void
StringBufferWithCallbacks): void {
(parameter) buffer: StringBufferWithCallbacks
const { children } = this
(alias) type StringBufferWithCallbacks = StringBuffer & { callbacks: HtmlEscapedCallback[]; } import StringBufferWithCallbacks
const res = (this
const children: Child[]
.tag as
const res: any
Function)
(property) JSXNode.tag: string | Function
.call(null, {
interface Function
Creates a new function.
(method) Function.call(this: Function, thisArg: any, ...argArray: any[]): any
Calls a method of an object, substituting another object for the current object.@param
thisArg
— The object to be used as the current object.@param
...this.props,argArray
— A list of arguments to be passed to the method.children:
(property) JSXNode.props: Props
children
(property) children: Child
.length <= 1 ?
const children: Child[]
children[0] :
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.children,
const children: Child[]
}) if (typeof res === 'boolean' ||
const children: Child[]
res == null) {
const res: any
// boolean or null or undefined return } else if (res instanceof
const res: any
Promise) {
const res: any
if (globalContexts
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.length === 0) {
(alias) const globalContexts: Context<unknown>[] import globalContexts
buffer
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array..unshift('',
(parameter) buffer: StringBufferWithCallbacks
(method) Array<string | Promise<string>>.unshift(...items: (string | Promise<string>)[]): number
Inserts new elements at the start of an array, and returns the new length of the array.@param
res)items
— Elements to insert at the start of the array.} else { // save current contexts for resuming const currentContexts:
const res: Promise<any>
LocalContexts =
const currentContexts: LocalContexts
globalContexts
type LocalContexts = [Context<unknown>, unknown][]
.map(
(alias) const globalContexts: Context<unknown>[] import globalContexts
(method) Array<Context<unknown>>.map<[Context<unknown>, unknown]>(callbackfn: (value: Context<unknown>, index: number, array: Context<unknown>[]) => [Context<unknown>, unknown], thisArg?: any): [Context<unknown>, unknown][]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(c) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.[c,
(parameter) c: Context<unknown>
c
(parameter) c: Context<unknown>
.values
(parameter) c: Context<unknown>
.at(-1)])
(property) Context<unknown>.values: unknown[]
(method) Array<unknown>.at(index: number): unknown
Returns the item located at the specified index.@param
bufferindex
— The zero-based index of the desired code unit. A negative index will count back from the last item..unshift(
(parameter) buffer: StringBufferWithCallbacks
(method) Array<string | Promise<string>>.unshift(...items: (string | Promise<string>)[]): number
Inserts new elements at the start of an array, and returns the new length of the array.@param
'', resitems
— Elements to insert at the start of the array..then(
const res: Promise<any>
(method) Promise<any>.then<any, string>(onfulfilled?: ((value: any) => any) | null | undefined, onrejected?: ((reason: any) => string | PromiseLike<string>) | null | undefined): Promise<any>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(childRes) => {if (childRes instanceof
(parameter) childRes: any
JSXNode) {
(parameter) childRes: any
childRes
class JSXNode
.localContexts =
(parameter) childRes: JSXNode
currentContexts
(property) JSXNode.localContexts?: LocalContexts | undefined
} return childRes
const currentContexts: LocalContexts
}) ) } } else if (res instanceof
(parameter) childRes: any
JSXNode) {
const res: any
res
class JSXNode
.toStringToBuffer
const res: JSXNode
(buffer)
(method) JSXNode.toStringToBuffer(buffer: StringBufferWithCallbacks): void
} else if (typeof res === 'number' ||
(parameter) buffer: StringBufferWithCallbacks
(res as
const res: any
HtmlEscaped)
const res: any
.isEscaped) {
(alias) type HtmlEscaped = { isEscaped: true; callbacks?: HtmlEscapedCallback[]; } import HtmlEscaped
buffer[0] +=
(property) isEscaped: true
res
(parameter) buffer: StringBufferWithCallbacks
if (res.callbacks) {
const res: any
buffer
const res: any
.callbacks ||= []
(parameter) buffer: StringBufferWithCallbacks
buffer
(property) callbacks: HtmlEscapedCallback[]
.callbacks
(parameter) buffer: StringBufferWithCallbacks
.push(..
(property) callbacks: HtmlEscapedCallback[]
(method) Array<HtmlEscapedCallback>.push(...items: HtmlEscapedCallback[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
.res.callbacks)items
— New elements to add to the array.} } else { escapeToBuffer
const res: any
(res,
(alias) escapeToBuffer(str: string, buffer: StringBuffer): void import escapeToBuffer
buffer)
const res: any
} } } export class JSXFragmentNode extends
(parameter) buffer: StringBufferWithCallbacks
JSXNode {
class JSXFragmentNode
toStringToBuffer
class JSXNode
(buffer:
(method) JSXFragmentNode.toStringToBuffer(buffer: StringBufferWithCallbacks): void
StringBufferWithCallbacks): void {
(parameter) buffer: StringBufferWithCallbacks
childrenToStringToBuffer(this
(alias) type StringBufferWithCallbacks = StringBuffer & { callbacks: HtmlEscapedCallback[]; } import StringBufferWithCallbacks
.children,
const childrenToStringToBuffer: (children: Child[], buffer: StringBufferWithCallbacks) => void
buffer)
(property) JSXNode.children: Child[]
} } export const jsx = (
(parameter) buffer: StringBufferWithCallbacks
tag: string |
const jsx: (tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]) => JSXNode
Function,
(parameter) tag: string | Function
props:
interface Function
Creates a new function.Props | null,
(parameter) props: Props | null
...children: (string | number |
type Props = { [x: string]: any; }
HtmlEscapedString)[]
(parameter) children: (string | number | HtmlEscapedString)[]
): JSXNode => {
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
props ??= {}
class JSXNode
if (children
(parameter) props: Props | null
.length) {
(parameter) children: (string | number | HtmlEscapedString)[]
props.children =
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.children
(parameter) props: Props
.length === 1 ?
(parameter) children: (string | number | HtmlEscapedString)[]
children[0] :
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.children
(parameter) children: (string | number | HtmlEscapedString)[]
} const key =
(parameter) children: (string | number | HtmlEscapedString)[]
props.key
const key: any
delete props['key']
(parameter) props: Props
const node =
(parameter) props: Props
jsxFn
const node: JSXNode
(tag,
const jsxFn: (tag: string | Function, props: Props, children: (string | number | HtmlEscapedString)[]) => JSXNode
props,
(parameter) tag: string | Function
children)
(parameter) props: Props
node
(parameter) children: (string | number | HtmlEscapedString)[]
.key =
const node: JSXNode
key
(property) JSXNode.key?: string | undefined
return node
const key: any
} let initDomRenderer = false
const node: JSXNode
export const jsxFn = (
let initDomRenderer: boolean
tag: string |
const jsxFn: (tag: string | Function, props: Props, children: (string | number | HtmlEscapedString)[]) => JSXNode
Function,
(parameter) tag: string | Function
props:
interface Function
Creates a new function.Props,
(parameter) props: Props
children: (string | number |
type Props = { [x: string]: any; }
HtmlEscapedString)[]
(parameter) children: (string | number | HtmlEscapedString)[]
): JSXNode => {
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
if (!initDomRenderer) {
class JSXNode
for (const k in
let initDomRenderer: boolean
domRenderers) {
const k: string
// eslint-disable-next-line @typescript-eslint/no-explicit-any ;(intrinsicElementTags[k as keyof typeof intrinsicElementTags] as any)
(alias) const domRenderers: Record<string, Function> import domRenderers
[DOM_RENDERER] =
const k: string
domRenderers
(alias) const DOM_RENDERER: typeof DOM_RENDERER import DOM_RENDERER
[k]
(alias) const domRenderers: Record<string, Function> import domRenderers
} initDomRenderer = true
const k: string
} if (typeof tag === 'function') {
let initDomRenderer: boolean
return new JSXFunctionNode
(parameter) tag: string | Function
(tag,
constructor JSXFunctionNode(tag: string | Function, props: Props, children: Child[]): JSXFunctionNode
props,
(parameter) tag: Function
children)
(parameter) props: Props
} else if (intrinsicElementTags[tag as keyof typeof intrinsicElementTags]) {
(parameter) children: (string | number | HtmlEscapedString)[]
return new JSXFunctionNode(
(parameter) tag: string
intrinsicElementTags[tag as keyof typeof intrinsicElementTags],
constructor JSXFunctionNode(tag: string | Function, props: Props, children: Child[]): JSXFunctionNode
props,
(parameter) tag: string
children
(parameter) props: Props
) } else if (tag === 'svg' ||
(parameter) children: (string | number | HtmlEscapedString)[]
tag === 'head') {
(parameter) tag: string
nameSpaceContext ||=
(parameter) tag: string
createContext('')
let nameSpaceContext: Context<string> | undefined
return new JSXNode
(alias) createContext<string>(defaultValue: string): Context<string> import createContext
(tag,
constructor JSXNode(tag: string | Function, props: Props, children: Child[]): JSXNode
props, [
(parameter) tag: "head" | "svg"
new JSXFunctionNode(
(parameter) props: Props
nameSpaceContext,
constructor JSXFunctionNode(tag: string | Function, props: Props, children: Child[]): JSXFunctionNode
{ value:
let nameSpaceContext: Context<string>
tag,
(property) value: string
}, children
(parameter) tag: "head" | "svg"
), ]) } else { return new JSXNode
(parameter) children: (string | number | HtmlEscapedString)[]
(tag,
constructor JSXNode(tag: string | Function, props: Props, children: Child[]): JSXNode
props,
(parameter) tag: string
children)
(parameter) props: Props
} } const shallowEqual =
(parameter) children: (string | number | HtmlEscapedString)[]
(a:
const shallowEqual: (a: Props, b: Props) => boolean
Props,
(parameter) a: Props
b:
type Props = { [x: string]: any; }
Props): boolean => {
(parameter) b: Props
if (a ===
type Props = { [x: string]: any; }
b) {
(parameter) a: Props
return true } const aKeys =
(parameter) b: Props
Object
const aKeys: string[]
.keys
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.keys(o: {}): string[] (+1 overload)
Returns the names of the enumerable string properties and methods of an object.@param
(a)o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..sort()
(parameter) a: Props
(method) Array<string>.sort(compareFn?: ((a: string, b: string) => number) | undefined): string[]
Sorts an array in place. This method mutates the array and returns a reference to the same array.@param
const bKeys =compareFn
Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.ts [11,2,22,1].sort((a, b) => a - b)
Object
const bKeys: string[]
.keys
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.keys(o: {}): string[] (+1 overload)
Returns the names of the enumerable string properties and methods of an object.@param
(b)o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object..sort()
(parameter) b: Props
(method) Array<string>.sort(compareFn?: ((a: string, b: string) => number) | undefined): string[]
Sorts an array in place. This method mutates the array and returns a reference to the same array.@param
if (aKeyscompareFn
Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.ts [11,2,22,1].sort((a, b) => a - b)
.length !==
const aKeys: string[]
bKeys
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array..length) {
const bKeys: string[]
return false } for (let i = 0,
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.len =
let i: number
aKeys
let len: number
.length;
const aKeys: string[]
i <
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.len;
let i: number
i++) {
let len: number
if ( aKeys
let i: number
[i] === 'children' &&
const aKeys: string[]
bKeys
let i: number
[i] === 'children' &&
const bKeys: string[]
!a.children?.length &&
let i: number
!b.children?.length
(parameter) a: Props
) { continue } else if (a
(parameter) b: Props
[aKeys
(parameter) a: Props
[i]] !==
const aKeys: string[]
b
let i: number
[aKeys
(parameter) b: Props
[i]]) {
const aKeys: string[]
return false } } return true } export const memo =
let i: number
<T>(
const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>
component:
(type parameter) T in <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean): FC<T>
FC
(parameter) component: FC<T>
<T>,
type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; }
propsAreEqual:
(type parameter) T in <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean): FC<T>
(prevProps:
(parameter) propsAreEqual: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean
Readonly
(parameter) prevProps: Readonly<T>
<T>,
type Readonly<T> = { readonly [P in keyof T]: T[P]; }
Make all properties in T readonlynextProps:
(type parameter) T in <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean): FC<T>
Readonly
(parameter) nextProps: Readonly<T>
<T>) => boolean =
type Readonly<T> = { readonly [P in keyof T]: T[P]; }
Make all properties in T readonlyshallowEqual
(type parameter) T in <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean): FC<T>
): FC
const shallowEqual: (a: Props, b: Props) => boolean
<T> => {
type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; }
let computed:
(type parameter) T in <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean): FC<T>
ReturnType
let computed: HtmlEscapedString | Promise<HtmlEscapedString> | null
<FC
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any
Obtain the return type of a function type<T>> = null
type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; }
let prevProps:
(type parameter) T in <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean): FC<T>
T | undefined = undefined
let prevProps: T | undefined
return ((props) => {
(type parameter) T in <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean): FC<T>
if (prevProps &&
(parameter) props: T
!propsAreEqual
let prevProps: T | undefined
(prevProps,
(parameter) propsAreEqual: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean
props)) {
let prevProps: NonNullable<T>
computed = null
(parameter) props: T
} prevProps =
let computed: HtmlEscapedString | Promise<HtmlEscapedString> | null
props
let prevProps: T | undefined
return (computed ||=
(parameter) props: T
component
let computed: HtmlEscapedString | Promise<HtmlEscapedString> | null
(props))
(parameter) component: (props: T) => HtmlEscapedString | Promise<HtmlEscapedString> | null
}) as FC
(parameter) props: T
<T>
type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; }
} export const Fragment = ({
(type parameter) T in <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean): FC<T>
children,
const Fragment: ({ children, }: { key?: string; children?: Child | HtmlEscapedString; }) => HtmlEscapedString
}: { key?: string
(parameter) children: Child | HtmlEscapedString
children?:
(property) key?: string | undefined
Child |
(property) children?: Child | HtmlEscapedString
HtmlEscapedString
type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
}): HtmlEscapedString => {
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
return new JSXFragmentNode(
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
'', { children,
constructor JSXFragmentNode(tag: string | Function, props: Props, children: Child[]): JSXFragmentNode
}, Array
(property) children: Child | HtmlEscapedString
.isArray
var Array: ArrayConstructor
(children) ?
(method) ArrayConstructor.isArray(arg: any): arg is any[]
children :
(parameter) children: Child | HtmlEscapedString
children ?
(parameter) children: Child[]
[children] : []
(parameter) children: string | number | boolean | Promise<string> | JSXNode | HtmlEscapedString | null | undefined
) as never } export const isValidElement =
(parameter) children: string | number | true | Promise<string> | JSXNode | HtmlEscapedString
(element: unknown):
const isValidElement: (element: unknown) => element is JSXNode
element is
(parameter) element: unknown
JSXNode => {
(parameter) element: unknown
return !!(element && typeof
class JSXNode
element === 'object' && 'tag' in
(parameter) element: unknown
element && 'props' in
(parameter) element: {}
element)
(parameter) element: object
} export const cloneElement =
(parameter) element: object & Record<"tag", unknown>
<T extends
const cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Partial<Props>, ...children: Child[]) => T
JSXNode |
(type parameter) T in <T extends JSXNode | JSX.Element>(element: T, props: Partial<Props>, ...children: Child[]): T
JSX
class JSXNode
.Element>(
namespace JSX
element:
type JSX.Element = HtmlEscapedString | Promise<HtmlEscapedString>
T,
(parameter) element: T extends JSXNode | JSX.Element
props:
(type parameter) T in <T extends JSXNode | JSX.Element>(element: T, props: Partial<Props>, ...children: Child[]): T
Partial
(parameter) props: Partial<Props>
<Props>,
type Partial<T> = { [P in keyof T]?: T[P] | undefined; }
Make all properties in T optional...children:
type Props = { [x: string]: any; }
Child[]
(parameter) children: Child[]
): T => {
type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined
return jsx(
(type parameter) T in <T extends JSXNode | JSX.Element>(element: T, props: Partial<Props>, ...children: Child[]): T
(element as
const jsx: (tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]) => JSXNode
JSXNode)
(parameter) element: JSXNode | JSX.Element
.tag,
class JSXNode
{ ...(element as
(property) JSXNode.tag: string | Function
JSXNode)
(parameter) element: JSXNode | JSX.Element
.props, ..
class JSXNode
.props },
(property) JSXNode.props: Props
...(children as (string | number |
(parameter) props: Partial<Props>
HtmlEscapedString)[])
(parameter) children: Child[]
) as T
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
} export const reactAPICompatVersion = '19.0.0-hono-jsx'
(type parameter) T in <T extends JSXNode | JSX.Element>(element: T, props: Partial<Props>, ...children: Child[]): T
const reactAPICompatVersion: "19.0.0-hono-jsx"
import { Children } from './children' import { createElement } from '.' describe('map', () => { it('should map children', () => { const element =createElement('div', null, 1, 2, 3)
const element: JSXNode
const result =
(alias) createElement(tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]): JSXNode import createElement
Children
const result: Child[]
.map
(alias) const 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[]; } import Children
(element
(property) map: (children: Child[], fn: (child: Child, index: number) => Child) => Child[]
.children,
const element: JSXNode
(child) =>
(property) JSXNode.children: Child[]
(child as number) * 2)
(parameter) child: Child
expect(result).toEqual([2, 4, 6])
(parameter) child: Child
}) }) describe('forEach', () => { it('should iterate children', () => { const element =
const result: Child[]
createElement('div', null, 1, 2, 3)
const element: JSXNode
const result: number[] = []
(alias) createElement(tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]): JSXNode import createElement
Children
const result: number[]
.forEach
(alias) const 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[]; } import Children
(element
(property) forEach: (children: Child[], fn: (child: Child, index: number) => void) => void
.children,
const element: JSXNode
(child) => {
(property) JSXNode.children: Child[]
result
(parameter) child: Child
.push
const result: number[]
(method) Array<number>.push(...items: number[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(child as number)items
— New elements to add to the array.}) expect(result).toEqual([1, 2, 3])
(parameter) child: Child
}) }) describe('count', () => { it('should count children', () => { const element =
const result: number[]
createElement('div', null, 1, 2, 3)
const element: JSXNode
const result =
(alias) createElement(tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]): JSXNode import createElement
Children
const result: number
.count
(alias) const 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[]; } import Children
(element
(property) count: (children: Child[]) => number
.children)
const element: JSXNode
expect(result).toBe(3)
(property) JSXNode.children: Child[]
}) }) describe('only', () => { it('should return the only child', () => { const element =
const result: number
createElement('div', null, 1)
const element: JSXNode
const result =
(alias) createElement(tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]): JSXNode import createElement
Children
const result: Child
.only
(alias) const 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[]; } import Children
(element
(property) only: (_children: Child[]) => Child
.children)
const element: JSXNode
expect(result).toBe(1)
(property) JSXNode.children: Child[]
}) it('should throw an error if there are multiple children', () => { const element =
const result: Child
createElement('div', null, 1, 2)
const element: JSXNode
expect(() => Children
(alias) createElement(tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]): JSXNode import createElement
.only
(alias) const 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[]; } import Children
(element
(property) only: (_children: Child[]) => Child
.children)).toThrowError(
const element: JSXNode
'Children.only() expects only one child' ) }) }) describe('toArray', () => { it('should convert children to an array', () => { const element =
(property) JSXNode.children: Child[]
createElement('div', null, 1, 2, 3)
const element: JSXNode
const result =
(alias) createElement(tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]): JSXNode import createElement
Children
const result: Child[]
.toArray
(alias) const 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[]; } import Children
(element
(property) toArray: (children: Child) => Child[]
.children)
const element: JSXNode
expect(result).toEqual([1, 2, 3])
(property) JSXNode.children: Child[]
}) })
const result: Child[]
import type { Child } from './base' export const toArray =(children:
const toArray: (children: Child) => Child[]
Child):
(parameter) children: Child
Child[] =>
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
Array
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
.isArray
var Array: ArrayConstructor
(children) ?
(method) ArrayConstructor.isArray(arg: any): arg is any[]
children :
(parameter) children: Child
[children]
(parameter) children: Child[]
export const Children = {
(parameter) children: string | number | boolean | Promise<string> | JSXNode | null | undefined
map:
const 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[]; }
(children:
(property) map: (children: Child[], fn: (child: Child, index: number) => Child) => Child[]
Child[],
(parameter) children: Child[]
fn:
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
(child:
(parameter) fn: (child: Child, index: number) => Child
Child,
(parameter) child: Child
index: number) =>
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
Child):
(parameter) index: number
Child[] =>
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
toArray
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
(children)
const toArray: (children: Child) => Child[]
.map
(parameter) children: Child[]
(method) Array<Child>.map<Child>(callbackfn: (value: Child, index: number, array: Child[]) => Child, thisArg?: any): Child[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(fn),thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.forEach:
(parameter) fn: (child: Child, index: number) => Child
(children:
(property) forEach: (children: Child[], fn: (child: Child, index: number) => void) => void
Child[],
(parameter) children: Child[]
fn:
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
(child:
(parameter) fn: (child: Child, index: number) => void
Child,
(parameter) child: Child
index: number) => void): void => {
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
toArray
(parameter) index: number
(children)
const toArray: (children: Child) => Child[]
.forEach
(parameter) children: Child[]
(method) Array<Child>.forEach(callbackfn: (value: Child, index: number, array: Child[]) => void, thisArg?: any): void
Performs the specified action for each element in an array.@param
callbackfn
— A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.@param
(fn)thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.}, count:
(parameter) fn: (child: Child, index: number) => void
(children:
(property) count: (children: Child[]) => number
Child[]): number =>
(parameter) children: Child[]
toArray
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
(children)
const toArray: (children: Child) => Child[]
.length,
(parameter) children: Child[]
only:
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.(_children:
(property) only: (_children: Child[]) => Child
Child[]):
(parameter) _children: Child[]
Child => {
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
const children =
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
toArray
const children: Child[]
(_children)
const toArray: (children: Child) => Child[]
if (children
(parameter) _children: Child[]
.length !== 1) {
const children: Child[]
throw new Error('Children.only() expects only one child')
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.} return children[0]
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
}, toArray,
const children: Child[]
}
(property) toArray: (children: Child) => Child[]
import { raw } from '../helper/html' import type { HtmlEscapedCallback, HtmlEscapedString } from '../utils/html' import { HtmlEscapedCallbackPhase, resolveCallback } from '../utils/html' import { DOM_RENDERER } from './constants' import { ErrorBoundary as ErrorBoundaryDomRenderer } from './dom/components' import type { HasRenderToDom } from './dom/render' import type { Child, FC, PropsWithChildren } from './' let errorBoundaryCounter = 0export const childrenToString = async
let errorBoundaryCounter: number
(children:
const childrenToString: (children: Child[]) => Promise<HtmlEscapedString[]>
Child[]):
(parameter) children: Child[]
Promise
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
<HtmlEscapedString[]> => {
interface Promise<T>
Represents the completion of an asynchronous operationtry { return children
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
.flat()
(parameter) children: Child[]
(method) Array<Child>.flat<Child[], 1>(this: Child[], depth?: 1 | undefined): Child[]
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.@param
.map(depth
— The maximum recursion depth
(method) Array<Child>.map<string | Promise<string>>(callbackfn: (value: Child, index: number, array: Child[]) => string | Promise<string>, thisArg?: any): (string | Promise<...>)[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(c) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.(c == null || typeof
(parameter) c: Child
c === 'boolean' ? '' :
(parameter) c: Child
c
(parameter) c: string | number | boolean | Promise<string> | JSXNode | Child[]
.toString())) as
(parameter) c: string | number | Promise<string> | JSXNode | Child[]
HtmlEscapedString[]
(method) toString(): string | Promise<string> (+1 overload)
Returns a string representation of a string.} catch (e) {
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
if (e instanceof
(local var) e: unknown
Promise) {
(local var) e: unknown
await e
var Promise: PromiseConstructor
Represents the completion of an asynchronous operationreturn childrenToString
(local var) e: Promise<any>
(children)
const childrenToString: (children: Child[]) => Promise<HtmlEscapedString[]>
} else { throw e
(parameter) children: Child[]
} } } export type ErrorHandler =
(local var) e: unknown
(error:
type ErrorHandler = (error: Error) => void
Error) => void
(parameter) error: Error
export type FallbackRender =
interface Error
(error:
type FallbackRender = (error: Error) => Child
Error) =>
(parameter) error: Error
Child
interface Error
/** * @experimental * `ErrorBoundary` is an experimental feature. * The API might be changed. */ export const ErrorBoundary:
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
const ErrorBoundary: FC<PropsWithChildren<{ fallback?: Child; fallbackRender?: FallbackRender; onError?: ErrorHandler; }>>
@experimental
FC<
ErrorBoundary
is an experimental feature. The API might be changed.PropsWithChildren<{
(alias) type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; } import FC
fallback?:
(alias) type PropsWithChildren<P = unknown> = P & { children?: Child | undefined; } import PropsWithChildren
Child
(property) fallback?: Child
fallbackRender?:
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
FallbackRender
(property) fallbackRender?: FallbackRender | undefined
onError?:
type FallbackRender = (error: Error) => Child
ErrorHandler
(property) onError?: ErrorHandler | undefined
}> > = async ({ children,
type ErrorHandler = (error: Error) => void
fallback,
(parameter) children: Child
fallbackRender,
(parameter) fallback: Child
onError }) => {
(parameter) fallbackRender: FallbackRender | undefined
if (!children) {
(parameter) onError: ErrorHandler | undefined
return raw('')
(parameter) children: Child
} if (!Array
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
.isArray
var Array: ArrayConstructor
(children)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
children =
(parameter) children: string | number | true | Promise<string> | JSXNode | Child[]
[children]
(parameter) children: Child
} let fallbackStr: string | undefined
(parameter) children: string | number | true | Promise<string> | JSXNode
const fallbackRes =
let fallbackStr: string | undefined
(error:
const fallbackRes: (error: Error) => HtmlEscapedString
Error):
(parameter) error: Error
HtmlEscapedString => {
interface Error
onError?.
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
(error)
(parameter) onError: ErrorHandler | undefined
return (fallbackStr ||
(parameter) error: Error
fallbackRender?.
let fallbackStr: string | undefined
(error) || '')
(parameter) fallbackRender: FallbackRender | undefined
.toString() as
(parameter) error: Error
HtmlEscapedString
(method) toString(): string | Promise<string> (+1 overload)
Returns a string representation of a string.} let resArray:
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
HtmlEscapedString[] |
let resArray: HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]
Promise
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
<HtmlEscapedString[]>[] = []
interface Promise<T>
Represents the completion of an asynchronous operationtry { resArray =
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
children
let resArray: HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]
.map(
(parameter) children: Child[]
(method) Array<Child>.map<string | Promise<string>>(callbackfn: (value: Child, index: number, array: Child[]) => string | Promise<string>, thisArg?: any): (string | Promise<...>)[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(c) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.c == null || typeof
(parameter) c: Child
c === 'boolean' ? '' :
(parameter) c: Child
c
(parameter) c: string | number | boolean | Promise<string> | JSXNode | Child[]
.toString()
(parameter) c: string | number | Promise<string> | JSXNode | Child[]
) as HtmlEscapedString[]
(method) toString(): string | Promise<string> (+1 overload)
Returns a string representation of a string.} catch (e) {
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
fallbackStr = await
(local var) e: unknown
fallback?
let fallbackStr: string | undefined
.toString()
(parameter) fallback: Child
if (e instanceof
(method) toString(): string | Promise<string> (+1 overload)
Returns a string representation of a string.Promise) {
(local var) e: unknown
resArray = [
var Promise: PromiseConstructor
Represents the completion of an asynchronous operatione
let resArray: HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]
.then(() =>
(local var) e: Promise<any>
(method) Promise<any>.then<HtmlEscapedString[], never>(onfulfilled?: ((value: any) => HtmlEscapedString[] | PromiseLike<HtmlEscapedString[]>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<...>) | ... 1 more ... | undefined): Promise<...>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
childrenToString(children as
const childrenToString: (children: Child[]) => Promise<HtmlEscapedString[]>
Child[]))
(parameter) children: Child[]
.catch(
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
(method) Promise<HtmlEscapedString[]>.catch<HtmlEscapedString>(onrejected?: ((reason: any) => HtmlEscapedString | PromiseLike<HtmlEscapedString>) | null | undefined): Promise<...>
Attaches a callback for only the rejection of the Promise.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of the callback.
(e) =>fallbackRes
(parameter) e: any
(e)),
const fallbackRes: (error: Error) => HtmlEscapedString
] as Promise
(parameter) e: any
<HtmlEscapedString[]>[]
interface Promise<T>
Represents the completion of an asynchronous operation} else { resArray =
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
[fallbackRes
let resArray: HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]
(e as
const fallbackRes: (error: Error) => HtmlEscapedString
Error)]
(local var) e: unknown
} } if (resArray
interface Error
.some(
let resArray: HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]
(method) Array<T>.some(predicate: ((value: HtmlEscapedString, index: number, array: HtmlEscapedString[]) => unknown) & ((value: Promise<HtmlEscapedString[]>, index: number, array: Promise<...>[]) => unknown), thisArg?: any): boolean
Determines whether the specified callback function returns true for any element of an array.@param
predicate
A function that accepts up to three arguments. The some method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value true, or until the end of the array.@param
(res) =>thisArg
An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.(res as {}) instanceof
(parameter) res: HtmlEscapedString | Promise<HtmlEscapedString[]>
Promise)) {
(parameter) res: HtmlEscapedString | Promise<HtmlEscapedString[]>
fallbackStr ||= await
var Promise: PromiseConstructor
Represents the completion of an asynchronous operationfallback?
let fallbackStr: string | undefined
.toString()
(parameter) fallback: Child
const index =
(method) toString(): string | Promise<string> (+1 overload)
Returns a string representation of a string.errorBoundaryCounter++
const index: number
const replaceRe =
let errorBoundaryCounter: number
RegExp(`(
const replaceRe: RegExp
{index}">.*?)(.*?)()`)
var RegExp: RegExpConstructor (pattern: RegExp | string, flags?: string) => RegExp (+2 overloads)
const caught = false
const index: number
const catchCallback = ({
const caught: false
error,
const catchCallback: ({ error, buffer }: { error: Error; buffer?: [string]; }) => string
buffer }: {
(parameter) error: Error
error:
(parameter) buffer: [string] | undefined
Error;
(property) error: Error
buffer?: [string] }) => {
interface Error
if (caught) {
(property) buffer?: [string] | undefined
return '' } const fallbackResString =
const caught: false
fallbackRes
const fallbackResString: HtmlEscapedString
(error)
const fallbackRes: (error: Error) => HtmlEscapedString
if (buffer) {
(parameter) error: Error
buffer[0] =
(parameter) buffer: [string] | undefined
buffer[0]
(parameter) buffer: [string]
.replace
(parameter) buffer: [string]
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
(replaceRe,replaceValue
— The replacement text.fallbackResString)
const replaceRe: RegExp
} return buffer
const fallbackResString: HtmlEscapedString
? '' : `index}">$
(parameter) buffer: [string] | undefined
{fallbackResString}` } let error: unknown
const index: number
const promiseAll =
let error: unknown
Promise
const promiseAll: Promise<any>
.all
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
(method) PromiseConstructor.all<HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]>(values: HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]): Promise<...> (+1 overload)
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.@param
values
— An array of Promises.@returns — A new Promise.
(resArray).catch(
let resArray: HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]
(method) Promise<HtmlEscapedString[] | HtmlEscapedString[][]>.catch<any>(onrejected?: ((reason: any) => any) | null | undefined): Promise<any>
Attaches a callback for only the rejection of the Promise.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of the callback.
(e) =>(error =
(parameter) e: any
e))
let error: unknown
return raw(`
(parameter) e: any
{index}">`, [
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
({ phase,
const index: number
buffer,
(parameter) phase: 2 | 1 | 3
context }) => {
(parameter) buffer: [string] | undefined
if (phase ===
(parameter) context: object
HtmlEscapedCallbackPhase
(parameter) phase: 2 | 1 | 3
(alias) const HtmlEscapedCallbackPhase: { readonly Stringify: 1; readonly BeforeStream: 2; readonly Stream: 3; } import HtmlEscapedCallbackPhase
@module — HTML utility.
.BeforeStream) {return } return promiseAll
(property) BeforeStream: 2
.then(async
const promiseAll: Promise<any>
(method) Promise<any>.then<string, never>(onfulfilled?: ((value: any) => string | PromiseLike<string>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<never>) | null | undefined): Promise<...>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(htmlArray:HtmlEscapedString[]) => {
(parameter) htmlArray: HtmlEscapedString[]
if (error) {
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
throw error
let error: unknown
} htmlArray =
let error: {}
htmlArray
(parameter) htmlArray: HtmlEscapedString[]
.flat()
(parameter) htmlArray: HtmlEscapedString[]
(method) Array<HtmlEscapedString>.flat<HtmlEscapedString[], 1>(this: HtmlEscapedString[], depth?: 1 | undefined): HtmlEscapedString[]
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.@param
const content =depth
— The maximum recursion depthhtmlArray
const content: string
.join('')
(parameter) htmlArray: HtmlEscapedString[]
(method) Array<HtmlEscapedString>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
let html =separator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.buffer
let html: string
? '' : `index}">$
(parameter) buffer: [string] | undefined
{content}` if (htmlArray
const index: number
.every(
(parameter) htmlArray: HtmlEscapedString[]
(method) Array<HtmlEscapedString>.every(predicate: (value: HtmlEscapedString, index: number, array: HtmlEscapedString[]) => unknown, thisArg?: any): boolean (+1 overload)
Determines whether all the members of an array satisfy the specified test.@param
predicate
A function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.@param
(html) => !thisArg
An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.(html as
(parameter) html: HtmlEscapedString
HtmlEscapedString)
(parameter) html: HtmlEscapedString
.callbacks?
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
.length)) {
(property) callbacks?: HtmlEscapedCallback[] | undefined
if (buffer) {
(property) Array<T>.length: number | undefined
Gets or sets the length of the array. This is a number one higher than the highest index in the array.buffer[0] =
(parameter) buffer: [string] | undefined
buffer[0]
(parameter) buffer: [string]
.replace
(parameter) buffer: [string]
(method) String.replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string (+3 overloads)
Passes a string andreplaceValue
to the[Symbol.replace]
method onsearchValue
. This method is expected to implement its own replacement algorithm.@param
searchValue
— An object that supports searching for and replacing matches within a string.@param
(replaceRe,replaceValue
— The replacement text.content)
const replaceRe: RegExp
} return html
const content: string
} if (buffer) {
let html: string
buffer[0] =
(parameter) buffer: [string] | undefined
buffer[0]
(parameter) buffer: [string]
.replace(
(parameter) buffer: [string]
(method) String.replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string (+3 overloads)
Replaces text in a string, using an object that supports replacement within a string.@param
searchValue
— A object can search for and replace matches within a string.@param
replaceRe,replacer
— A function that returns the replacement text.(_all,
const replaceRe: RegExp
pre,
(parameter) _all: string
_,
(parameter) pre: any
post) => `$
(parameter) _: any
{pre}$
(parameter) post: any
{content}$
(parameter) pre: any
{post}`
const content: string
) } const callbacks =
(parameter) post: any
htmlArray
const callbacks: HtmlEscapedCallback[]
.map(
(parameter) htmlArray: HtmlEscapedString[]
(method) Array<HtmlEscapedString>.map<HtmlEscapedCallback[]>(callbackfn: (value: HtmlEscapedString, index: number, array: HtmlEscapedString[]) => HtmlEscapedCallback[], thisArg?: any): HtmlEscapedCallback[][]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
(html) =>thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.(html as
(parameter) html: HtmlEscapedString
HtmlEscapedString)
(parameter) html: HtmlEscapedString
.callbacks || [])
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
.flat()
(property) callbacks?: HtmlEscapedCallback[] | undefined
(method) Array<HtmlEscapedCallback[]>.flat<HtmlEscapedCallback[][], 1>(this: HtmlEscapedCallback[][], depth?: 1 | undefined): HtmlEscapedCallback[]
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.@param
if (phase ===depth
— The maximum recursion depthHtmlEscapedCallbackPhase
(parameter) phase: 1 | 3
(alias) const HtmlEscapedCallbackPhase: { readonly Stringify: 1; readonly BeforeStream: 2; readonly Stream: 3; } import HtmlEscapedCallbackPhase
@module — HTML utility.
.Stream) {html = await
(property) Stream: 3
resolveCallback(
let html: string
html,
(alias) resolveCallback(str: string | HtmlEscapedString | Promise<string>, phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase], preserveCallbacks: boolean, context: object, buffer?: [string]): Promise<string> import resolveCallback
HtmlEscapedCallbackPhase
let html: string
(alias) const HtmlEscapedCallbackPhase: { readonly Stringify: 1; readonly BeforeStream: 2; readonly Stream: 3; } import HtmlEscapedCallbackPhase
@module — HTML utility.
.BeforeStream,true, context
(property) BeforeStream: 2
) } let resolvedCount = 0
(parameter) context: object
const promises =
let resolvedCount: number
callbacks
const promises: HtmlEscapedCallback[]
.map
const callbacks: HtmlEscapedCallback[]
(method) Array<HtmlEscapedCallback>.map<HtmlEscapedCallback>(callbackfn: (value: HtmlEscapedCallback, index: number, array: HtmlEscapedCallback[]) => HtmlEscapedCallback, thisArg?: any): HtmlEscapedCallback[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.@param
callbackfn
— A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.@param
<HtmlEscapedCallback>(thisArg
— An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.(c) =>
(alias) type HtmlEscapedCallback = (opts: HtmlEscapedCallbackOpts) => Promise<string> | undefined import HtmlEscapedCallback
(...args) =>
(parameter) c: HtmlEscapedCallback
c(..
(parameter) args: [opts: HtmlEscapedCallbackOpts]
.args)
(parameter) c: (opts: HtmlEscapedCallbackOpts) => Promise<string> | undefined
?.then(
(parameter) args: [opts: HtmlEscapedCallbackOpts]
(method) Promise<string>.then<TResult1, TResult2>(onfulfilled?: ((value: string) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | null | undefined): Promise<...>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(content) => {resolvedCount++
(parameter) content: string
if (buffer) {
let resolvedCount: number
if (resolvedCount ===
(parameter) buffer: [string] | undefined
callbacks
let resolvedCount: number
.length) {
const callbacks: HtmlEscapedCallback[]
buffer[0] =
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.buffer[0]
(parameter) buffer: [string]
.replace
(parameter) buffer: [string]
(method) String.replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string (+3 overloads)
Replaces text in a string, using an object that supports replacement within a string.@param
searchValue
— A object can search for and replace matches within a string.@param
(replaceRe,replacer
— A function that returns the replacement text.(_all,
const replaceRe: RegExp
_pre,
(parameter) _all: string
content) =>
(parameter) _pre: any
content)
(parameter) content: any
} buffer[0] +=
(parameter) content: any
content
(parameter) buffer: [string]
return raw('',
(parameter) content: string
(content as
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
HtmlEscapedString)
(parameter) content: string
.callbacks)
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
} return raw(
(property) callbacks?: HtmlEscapedCallback[] | undefined
content +
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
(resolvedCount !==
(parameter) content: string
callbacks
let resolvedCount: number
.length
const callbacks: HtmlEscapedCallback[]
? '' : ` ((d,c,n) => { d=d.getElementById('E:${index}')
(property) Array<T>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.if(!d)return n=d.nextSibling while(n.nodeType!=8||n.nodeValue!='E:${index}'){n=n.nextSibling}
const index: number
n.remove() d.remove() })(document) `), (content as
const index: number
HtmlEscapedString)
(parameter) content: string
.callbacks
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
) }) .catch(
(property) callbacks?: HtmlEscapedCallback[] | undefined
(method) Promise<HtmlEscapedString>.catch<TResult>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<HtmlEscapedString | TResult>
Attaches a callback for only the rejection of the Promise.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of the callback.
(error) =>catchCallback({
(parameter) error: any
error,
const catchCallback: ({ error, buffer }: { error: Error; buffer?: [string]; }) => string
buffer }))
(property) error: Error
) // eslint-disable-next-line @typescript-eslint/no-explicit-any return raw
(property) buffer?: [string] | undefined
(html,
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
promises as any)
let html: string
}) .catch(
const promises: HtmlEscapedCallback[]
(method) Promise<string>.catch<string>(onrejected?: ((reason: any) => string | PromiseLike<string>) | null | undefined): Promise<string>
Attaches a callback for only the rejection of the Promise.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of the callback.
(error) =>catchCallback({
(parameter) error: any
error,
const catchCallback: ({ error, buffer }: { error: Error; buffer?: [string]; }) => string
buffer }))
(property) error: Error
}, ]) } else { return raw
(property) buffer?: [string] | undefined
(resArray
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
.join(''))
let resArray: HtmlEscapedString[] | Promise<HtmlEscapedString[]>[]
(method) Array<T>.join(separator?: string): string
Adds all the elements of an array into a string, separated by the specified separator string.@param
} } ;(ErrorBoundary asseparator
— A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.
const ErrorBoundary: FC<PropsWithChildren<{ fallback?: Child; fallbackRender?: FallbackRender; onError?: ErrorHandler; }>>
@experimental
HasRenderToDom)
ErrorBoundary
is an experimental feature. The API might be changed.[DOM_RENDERER] =
(alias) type HasRenderToDom = FC<any> & { [DOM_RENDERER]: FC<any>; } import HasRenderToDom
ErrorBoundaryDomRenderer
(alias) const DOM_RENDERER: typeof DOM_RENDERER import DOM_RENDERER
(alias) const ErrorBoundaryDomRenderer: FC<PropsWithChildren<{ fallback?: Child; fallbackRender?: FallbackRender; onError?: ErrorHandler; }>> import ErrorBoundaryDomRenderer
export const DOM_RENDERER =Symbol('RENDERER')
const DOM_RENDERER: typeof DOM_RENDERER
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export const DOM_ERROR_HANDLER =description
— Description of the new Symbol object.Symbol('ERROR_HANDLER')
const DOM_ERROR_HANDLER: typeof DOM_ERROR_HANDLER
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export const DOM_STASH =description
— Description of the new Symbol object.Symbol('STASH')
const DOM_STASH: typeof DOM_STASH
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export const DOM_INTERNAL_TAG =description
— Description of the new Symbol object.Symbol('INTERNAL')
const DOM_INTERNAL_TAG: typeof DOM_INTERNAL_TAG
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
export const PERMALINK =description
— Description of the new Symbol object.Symbol('PERMALINK')
const PERMALINK: typeof PERMALINK
var Symbol: SymbolConstructor (description?: string | number) => symbol
Returns a new unique Symbol value.@param
description
— Description of the new Symbol object.
import { raw } from '../helper/html' import type { HtmlEscapedString } from '../utils/html' import { JSXFragmentNode } from './base' import { DOM_RENDERER } from './constants' import { createContextProviderFunction } from './dom/context' import type { FC, PropsWithChildren } from './' export interface Context<T> extends
interface Context<T>
FC
(type parameter) T in Context<T>
<PropsWithChildren<{
(alias) type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; } import FC
value:
(alias) type PropsWithChildren<P = unknown> = P & { children?: Child | undefined; } import PropsWithChildren
T }>> {
(property) value: T
values:
(type parameter) T in Context<T>
T[]
(property) Context<T>.values: T[]
Provider:
(type parameter) T in Context<T>
FC
(property) Context<T>.Provider: FC<PropsWithChildren<{ value: T; }>>
<PropsWithChildren<{
(alias) type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; } import FC
value:
(alias) type PropsWithChildren<P = unknown> = P & { children?: Child | undefined; } import PropsWithChildren
T }>>
(property) value: T
} export const globalContexts:
(type parameter) T in Context<T>
Context
const globalContexts: Context<unknown>[]
[] = [] export const createContext =
interface Context<T>
<T>
const createContext: <T>(defaultValue: T) => Context<T>
(defaultValue:
(type parameter) T in <T>(defaultValue: T): Context<T>
T):
(parameter) defaultValue: T
Context
(type parameter) T in <T>(defaultValue: T): Context<T>
<T> => {
interface Context<T>
const values =
(type parameter) T in <T>(defaultValue: T): Context<T>
[defaultValue]
const values: T[]
const context:
(parameter) defaultValue: T
Context
const context: Context<T>
<T> = (
interface Context<T>
(props):
(type parameter) T in <T>(defaultValue: T): Context<T>
HtmlEscapedString |
(parameter) props: PropsWithChildren<{ value: T; }>
Promise
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
<HtmlEscapedString> => {
interface Promise<T>
Represents the completion of an asynchronous operationvalues
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
.push
const values: T[]
(method) Array<T>.push(...items: T[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(propsitems
— New elements to add to the array..value)
(parameter) props: PropsWithChildren<{ value: T; }>
let string
(property) value: T
try { string =
let string: any
props
let string: any
.children
(parameter) props: PropsWithChildren<{ value: T; }>
? (Array
(property) children?: Child
.isArray
var Array: ArrayConstructor
(props
(method) ArrayConstructor.isArray(arg: any): arg is any[]
.children)
(parameter) props: PropsWithChildren<{ value: T; }>
? new JSXFragmentNode('', {},
(property) children?: string | number | true | Promise<string> | JSXNode | Child[]
props
(alias) new JSXFragmentNode(tag: string | Function, props: Props, children: Child[]): JSXFragmentNode import JSXFragmentNode
.children)
(parameter) props: PropsWithChildren<{ value: T; }>
: props
(property) children?: Child[]
.children
(parameter) props: PropsWithChildren<{ value: T; }>
).toString()
(property) children?: string | number | true | Promise<string> | JSXNode
: '' } finally { values
(method) toString(): string | Promise<string> (+1 overload)
Returns a string representation of a string..pop()
const values: T[]
} if (string instanceof
(method) Array<T>.pop(): T | undefined
Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.Promise) {
let string: string | Promise<string>
return string
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation.then(
let string: Promise<string>
(method) Promise<string>.then<HtmlEscapedString, HtmlEscapedString>(onfulfilled?: ((value: string) => HtmlEscapedString | PromiseLike<HtmlEscapedString>) | null | undefined, onrejected?: ((reason: any) => HtmlEscapedString | PromiseLike<...>) | ... 1 more ... | undefined): Promise<...>
Attaches callbacks for the resolution and/or rejection of the Promise.@param
onfulfilled
— The callback to execute when the Promise is resolved.@param
onrejected
— The callback to execute when the Promise is rejected.@returns — A Promise for the completion of which ever callback is executed.
(resString) =>raw
(parameter) resString: string
(resString,
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
(resString as
(parameter) resString: string
HtmlEscapedString)
(parameter) resString: string
.callbacks))
(alias) type HtmlEscapedString = string & HtmlEscaped import HtmlEscapedString
} else { return raw
(property) callbacks?: HtmlEscapedCallback[] | undefined
(string)
(alias) raw(value: unknown, callbacks?: HtmlEscapedCallback[]): HtmlEscapedString import raw
} }) as Context
let string: string
<T>
interface Context<T>
context
(type parameter) T in <T>(defaultValue: T): Context<T>
.values =
const context: Context<T>
values
(property) Context<T>.values: T[]
context
const values: T[]
.Provider =
const context: Context<T>
context
(property) Context<T>.Provider: FC<PropsWithChildren<{ value: T; }>>
// eslint-disable-next-line @typescript-eslint/no-explicit-any ;(context as any)
const context: Context<T>
[DOM_RENDERER] =
const context: Context<T>
createContextProviderFunction
(alias) const DOM_RENDERER: typeof DOM_RENDERER import DOM_RENDERER
(values)
(alias) createContextProviderFunction<T>(values: T[]): Function import createContextProviderFunction
globalContexts
const values: T[]
.push
const globalContexts: Context<unknown>[]
(method) Array<Context<unknown>>.push(...items: Context<unknown>[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(context asitems
— New elements to add to the array.Context
const context: Context<T>
) return context
interface Context<T>
} export const useContext =
const context: Context<T>
<T>
const useContext: <T>(context: Context<T>) => T
(context:
(type parameter) T in <T>(context: Context<T>): T
Context
(parameter) context: Context<T>
<T>):
interface Context<T>
T => {
(type parameter) T in <T>(context: Context<T>): T
return context
(type parameter) T in <T>(context: Context<T>): T
.values
(parameter) context: Context<T>
.at(-1) as
(property) Context<T>.values: T[]
(method) Array<T>.at(index: number): T | undefined
Returns the item located at the specified index.@param
Tindex
— The zero-based index of the desired code unit. A negative index will count back from the last item.}
(type parameter) T in <T>(context: Context<T>): T
/** * @module * This module provides APIs for `hono/jsx/dom/client`, which is compatible with `react-dom/client`. */ import type { Child } from '../base' import { useState } from '../hooks' import { buildNode, renderNode } from './render' import type { NodeObject } from './render' export interface Root {render
interface Root
(children:
(method) Root.render(children: Child): void
Child): void
(parameter) children: Child
unmount(): void
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
} export type RootOptions =
(method) Root.unmount(): void
Record
type RootOptions = { [x: 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 const createRoot = (
type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T
const createRoot: (element: HTMLElement | DocumentFragment, options?: RootOptions) => Root
Create a root object for rendering@param
element
— Render target@param
options
— Options for createRoot (not supported yet)@returns — Root object has
element:render
andunmount
methods
(parameter) element: HTMLElement | DocumentFragment
Render target@param
HTMLElement |element
— Render targetDocumentFragment,
interface HTMLElement
Any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it.options:
interface DocumentFragment
A minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is that because the document fragment isn't part of the active document tree structure, changes made to the fragment don't affect the document, cause reflow, or incur any performance impact that can occur when changes are made.
(parameter) options: RootOptions
Options for createRoot (not supported yet)@param
RootOptions = {}options
— Options for createRoot (not supported yet)): Root => {
type RootOptions = { [x: string]: unknown; }
let setJsxNode:
interface Root
| undefined // initial state | ((jsxNode: unknown) => void) // rendered
let setJsxNode: ((jsxNode: unknown) => void) | null | undefined
| null = // unmounted undefined if (Object
(parameter) jsxNode: unknown
.keys
var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
(method) ObjectConstructor.keys(o: {}): string[] (+1 overload)
Returns the names of the enumerable string properties and methods of an object.@param
(options)o
— Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
(parameter) options: RootOptions
Options for createRoot (not supported yet)@param
.length > 0) {options
— Options for createRoot (not supported yet)console
(property) Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array..warn('createRoot options are not supported yet')
var console: Console
} return { render
(method) Console.warn(...data: any[]): void
MDN Reference(jsxNode: unknown) {
(method) Root.render(children: Child): void
if (setJsxNode === null) {
(parameter) jsxNode: unknown
// unmounted throw new Error('Cannot update an unmounted root')
let setJsxNode: ((jsxNode: unknown) => void) | null | undefined
} if (setJsxNode) {
var Error: ErrorConstructor new (message?: string, options?: ErrorOptions) => Error (+1 overload)
// rendered setJsxNode
let setJsxNode: ((jsxNode: unknown) => void) | undefined
(jsxNode)
let setJsxNode: (jsxNode: unknown) => void
} else { renderNode(
(parameter) jsxNode: unknown
buildNode({
(alias) renderNode(node: NodeObject, container: Container): void import renderNode
tag: () => {
(alias) buildNode(node: Child): Node | undefined import buildNode
const [_jsxNode,
(property) tag: () => unknown
_setJsxNode] =
const _jsxNode: unknown
useState
const _setJsxNode: UpdateStateFunction<unknown>
(jsxNode)
(alias) useState<unknown>(initialState: unknown): [unknown, UpdateStateFunction<unknown>] (+1 overload) import useState
setJsxNode =
(parameter) jsxNode: unknown
_setJsxNode
let setJsxNode: ((jsxNode: unknown) => void) | null | undefined
return _jsxNode
const _setJsxNode: UpdateStateFunction<unknown>
}, props: {},
const _jsxNode: unknown
// eslint-disable-next-line @typescript-eslint/no-explicit-any } as any) as NodeObject,
(property) props: {}
element
(alias) type NodeObject = { pP: Props | undefined; nN: Node | undefined; vC: Node[]; pC?: Node[]; vR: Node[]; n?: string; f?: boolean; s?: boolean; c: Container | undefined; e: SupportedElement | Text | undefined; p?: PreserveNodeType; a?: boolean; [DOM_STASH]: [number, any[][], LocalJSXContexts, [Context, Function, NodeObject]] | [number, any[][]]; } & JSXNode import NodeObject
(parameter) element: HTMLElement | DocumentFragment
Render target@param
) } }, unmount() {element
— Render targetsetJsxNode?.(null)
(method) Root.unmount(): void
setJsxNode = null
let setJsxNode: ((jsxNode: unknown) => void) | null | undefined
}, } } /** * 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 const hydrateRoot = (
let setJsxNode: ((jsxNode: unknown) => void) | null | undefined
const hydrateRoot: (element: HTMLElement | DocumentFragment, reactNode: Child, 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
element:render
andunmount
methods
(parameter) element: HTMLElement | DocumentFragment
Render target@param
HTMLElement |element
— Render targetDocumentFragment,
interface HTMLElement
Any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it.reactNode:
interface DocumentFragment
A minimal document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document. The key difference is that because the document fragment isn't part of the active document tree structure, changes made to the fragment don't affect the document, cause reflow, or incur any performance impact that can occur when changes are made.
(parameter) reactNode: Child
A JSXNode to render@param
Child,reactNode
— A JSXNode to renderoptions:
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
(parameter) options: RootOptions
Options for createRoot (not supported yet)@param
RootOptions = {}options
— Options for createRoot (not supported yet)): Root => {
type RootOptions = { [x: string]: unknown; }
const root =
interface Root
createRoot
const root: Root
const createRoot: (element: HTMLElement | DocumentFragment, options?: RootOptions) => Root
Create a root object for rendering@param
element
— Render target@param
options
— Options for createRoot (not supported yet)@returns — Root object has
(element,render
andunmount
methods
(parameter) element: HTMLElement | DocumentFragment
Render target@param
options)element
— Render target
(parameter) options: RootOptions
Options for createRoot (not supported yet)@param
rootoptions
— Options for createRoot (not supported yet).render
const root: Root
(reactNode)
(method) Root.render(children: Child): void
(parameter) reactNode: Child
A JSXNode to render@param
return rootreactNode
— A JSXNode to render} export default { createRoot,
const root: Root
hydrateRoot,
(property) createRoot: (element: HTMLElement | DocumentFragment, options?: RootOptions) => Root
}
(property) hydrateRoot: (element: HTMLElement | DocumentFragment, reactNode: Child, options?: RootOptions) => Root
import type { Child, FC, PropsWithChildren } from '../' import type { ErrorHandler, FallbackRender } from '../components' import { DOM_ERROR_HANDLER } from '../constants' import { Fragment } from './jsx-runtime' /* eslint-disable @typescript-eslint/no-explicit-any */ export const ErrorBoundary:FC<
const ErrorBoundary: FC<PropsWithChildren<{ fallback?: Child; fallbackRender?: FallbackRender; onError?: ErrorHandler; }>>
PropsWithChildren<{
(alias) type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; } import FC
fallback?:
(alias) type PropsWithChildren<P = unknown> = P & { children?: Child | undefined; } import PropsWithChildren
Child
(property) fallback?: Child
fallbackRender?:
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
FallbackRender
(property) fallbackRender?: FallbackRender | undefined
onError?:
(alias) type FallbackRender = (error: Error) => Child import FallbackRender
ErrorHandler
(property) onError?: ErrorHandler | undefined
}> > = (({ children,
(alias) type ErrorHandler = (error: Error) => void import ErrorHandler
fallback,
(parameter) children: any
fallbackRender,
(parameter) fallback: any
onError }: any) => {
(parameter) fallbackRender: any
const res =
(parameter) onError: any
Fragment({
const res: JSXNode
children })
(alias) Fragment(props: Record<string, unknown>): JSXNode import Fragment
;(res as any)
(property) children: any
[DOM_ERROR_HANDLER] =
const res: JSXNode
(err: any) => {
(alias) const DOM_ERROR_HANDLER: typeof DOM_ERROR_HANDLER import DOM_ERROR_HANDLER
if (err instanceof
(parameter) err: any
Promise) {
(parameter) err: any
throw err
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation} onError?.
(parameter) err: Promise<any>
(err)
(parameter) onError: any
return fallbackRender?.
(parameter) err: any
(err) ||
(parameter) fallbackRender: any
fallback
(parameter) err: any
} return res
(parameter) fallback: any
}) as any export const Suspense:
const res: JSXNode
FC
const Suspense: FC<PropsWithChildren<{ fallback: any; }>>
<PropsWithChildren<{
(alias) type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; } import FC
fallback: any }>> = (({
(alias) type PropsWithChildren<P = unknown> = P & { children?: Child | undefined; } import PropsWithChildren
children,
(property) fallback: any
fallback,
(parameter) children: any
}: any) => { const res =
(parameter) fallback: any
Fragment({
const res: JSXNode
children })
(alias) Fragment(props: Record<string, unknown>): JSXNode import Fragment
;(res as any)
(property) children: any
[DOM_ERROR_HANDLER] =
const res: JSXNode
(err: any,
(alias) const DOM_ERROR_HANDLER: typeof DOM_ERROR_HANDLER import DOM_ERROR_HANDLER
retry: () => void) => {
(parameter) err: any
if (!(err instanceof
(parameter) retry: () => void
Promise)) {
(parameter) err: any
throw err
var Promise: PromiseConstructor
Represents the completion of an asynchronous operation} err
(parameter) err: any
.finally
(parameter) err: Promise<any>
(method) Promise<any>.finally(onfinally?: (() => void) | null | undefined): Promise<any>
Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.@param
onfinally
— The callback to execute when the Promise is settled (fulfilled or rejected).@returns — A Promise for the completion of the callback.
(retry)return fallback
(parameter) retry: () => void
} return res
(parameter) fallback: any
}) as any /* eslint-enable @typescript-eslint/no-explicit-any */
const res: JSXNode
import type { Child } from '../base' import { DOM_ERROR_HANDLER } from '../constants' import type { Context } from '../context' import { globalContexts } from '../context' import { setInternalTagFlag } from './utils' export const createContextProviderFunction =<T>
const createContextProviderFunction: <T>(values: T[]) => Function
(values:
(type parameter) T in <T>(values: T[]): Function
T[]):
(parameter) values: T[]
Function =>
(type parameter) T in <T>(values: T[]): Function
({ value,
interface Function
Creates a new function.children }: {
(parameter) value: T
value:
(parameter) children: Child[]
T;
(property) value: T
children:
(type parameter) T in <T>(values: T[]): Function
Child[] }) => {
(property) children: Child[]
if (!children) {
(alias) type Child = string | number | boolean | Promise<string> | JSXNode | Child[] | null | undefined import Child
return undefined } // eslint-disable-next-line @typescript-eslint/no-explicit-any const props: {
(parameter) children: Child[]
children: any } = {
const props: { children: any; }
children: [
(property) children: any
{ tag:
(property) children: any
setInternalTagFlag(() => {
(property) tag: Function
values
(alias) setInternalTagFlag(fn: Function): Function import setInternalTagFlag
.push
(parameter) values: T[]
(method) Array<T>.push(...items: T[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(value)items
— New elements to add to the array.}), props: {},
(parameter) value: T
}, ], } if (Array
(property) props: {}
.isArray
var Array: ArrayConstructor
(children)) {
(method) ArrayConstructor.isArray(arg: any): arg is any[]
props
(parameter) children: Child[]
.children.push(..
const props: { children: any; }
.children
(property) children: any
.flat())
(parameter) children: Child[]
(method) Array<Child>.flat<Child[], 1>(this: Child[], depth?: 1 | undefined): Child[]
Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.@param
} else { propsdepth
— The maximum recursion depth.children.push
const props: { children: any; }
(children)
(property) children: any
} props
(parameter) children: never
.children.push({
const props: { children: any; }
tag:
(property) children: any
setInternalTagFlag(() => {
(property) tag: Function
values
(alias) setInternalTagFlag(fn: Function): Function import setInternalTagFlag
.pop()
(parameter) values: T[]
}), props: {},
(method) Array<T>.pop(): T | undefined
Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.}) const res = {
(property) props: {}
tag: '',
const res: { tag: string; props: { children: any; }; type: string; }
props,
(property) tag: string
type: '' }
(property) props: { children: any; }
// eslint-disable-next-line @typescript-eslint/no-explicit-any ;(res as any)
(property) type: string
[DOM_ERROR_HANDLER] =
const res: { tag: string; props: { children: any; }; type: string; }
(err: unknown) => {
(alias) const DOM_ERROR_HANDLER: typeof DOM_ERROR_HANDLER import DOM_ERROR_HANDLER
values
(parameter) err: unknown
.pop()
(parameter) values: T[]
throw err
(method) Array<T>.pop(): T | undefined
Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.} return res
(parameter) err: unknown
} export const createContext =
const res: { tag: string; props: { children: any; }; type: string; }
<T>
const createContext: <T>(defaultValue: T) => Context<T>
(defaultValue:
(type parameter) T in <T>(defaultValue: T): Context<T>
T):
(parameter) defaultValue: T
Context
(type parameter) T in <T>(defaultValue: T): Context<T>
<T> => {
(alias) interface Context<T> import Context
const values =
(type parameter) T in <T>(defaultValue: T): Context<T>
[defaultValue]
const values: T[]
const context:
(parameter) defaultValue: T
Context
const context: Context<T>
<T> =
(alias) interface Context<T> import Context
createContextProviderFunction
(type parameter) T in <T>(defaultValue: T): Context<T>
(values) as
const createContextProviderFunction: <T>(values: T[]) => Function
Context
const values: T[]
<T>
(alias) interface Context<T> import Context
context
(type parameter) T in <T>(defaultValue: T): Context<T>
.values =
const context: Context<T>
values
(property) Context<T>.values: T[]
context
const values: T[]
.Provider =
const context: Context<T>
context
(property) Context<T>.Provider: FC<PropsWithChildren<{ value: T; }>>
globalContexts
const context: Context<T>
.push
(alias) const globalContexts: Context<unknown>[] import globalContexts
(method) Array<Context<unknown>>.push(...items: Context<unknown>[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(context asitems
— New elements to add to the array.Context
const context: Context<T>
) return context
(alias) interface Context<T> import Context
}
const context: Context<T>
/** * @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' import { CLASS_NAME, DEFAULT_STYLE_ID, PSEUDO_GLOBAL_SELECTOR, SELECTOR, SELECTORS, STYLE_STRING, cssCommon, cxCommon, keyframesCommon, viewTransitionCommon, } from '../../helper/css/common' export { rawCssString } from '../../helper/css/common'
(alias) const rawCssString: (value: string) => CssEscapedString export rawCssString
@experimental
const splitRule =
rawCssString
is an experimental feature. The API might be changed.(rule: string): string[] => {
const splitRule: (rule: string) => string[]
const result: string[] = []
(parameter) rule: string
let startPos = 0
const result: string[]
let depth = 0
let startPos: number
for (let i = 0,
let depth: number
len =
let i: number
rule
let len: number
.length;
(parameter) rule: string
i <
(property) String.length: number
Returns the length of a String object.len;
let i: number
i++) {
let len: number
const char =
let i: number
rule
const char: string
[i]
(parameter) rule: string
// consume quote // eslint-disable-next-line quotes if (char === "'" ||
let i: number
char === '"') {
const char: string
const quote =
const char: string
char
const quote: "\"" | "'"
i++
const char: "\"" | "'"
for (; i <
let i: number
len;
let i: number
i++) {
let len: number
if (rule
let i: number
[i] === '\\') {
(parameter) rule: string
i++
let i: number
continue } if (rule
let i: number
[i] ===
(parameter) rule: string
quote) {
let i: number
break } } continue } // comments are removed from the rule in advance if (char === '{') {
const quote: "\"" | "'"
depth++
const char: string
continue } if (char === '}') {
let depth: number
depth--
const char: string
if (depth === 0) {
let depth: number
result
let depth: number
.push
const result: string[]
(method) Array<string>.push(...items: string[]): number
Appends new elements to the end of an array, and returns the new length of the array.@param
(ruleitems
— New elements to add to the array..slice
(parameter) rule: string
(method) String.slice(start?: number, end?: number): string
Returns a section of a string.@param
start
— The index to the beginning of the specified portion of stringObj.@param
(startPos,end
The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of stringObj.i + 1))
let startPos: number
startPos =
let i: number
i + 1
let startPos: number
} continue } } return result
let i: number
} interface CreateCssJsxDomObjectsType {
const result: string[]
(args: {
interface CreateCssJsxDomObjectsType
id:
(parameter) args: { id: Readonly<string>; }
Readonly
(property) id: string
}): readonly [ { toString
type Readonly<T> = { readonly [P in keyof T]: T[P]; }
Make all properties in T readonly(this:
(method) toString(this: CssClassName): string
CssClassName): string
(parameter) this: CssClassName
}, FC
(alias) interface CssClassName import CssClassName
<PropsWithChildren
(alias) type FC<P = Props> = { (props: P): HtmlEscapedString | Promise<HtmlEscapedString> | null; defaultProps?: Partial<P> | undefined; displayName?: string | undefined; } import FC
> ] } export const createCssJsxDomObjects:
(alias) type PropsWithChildren<P = unknown> = P & { children?: Child | undefined; } import PropsWithChildren
CreateCssJsxDomObjectsType = ({
const createCssJsxDomObjects: CreateCssJsxDomObjectsType
id }) => {
interface CreateCssJsxDomObjectsType
let styleSheet:
(parameter) id: string
CSSStyleSheet | null | undefined = undefined
let styleSheet: CSSStyleSheet | null | undefined
const findStyleSheet = ():
interface CSSStyleSheet
A single CSS style sheet. It inherits properties and methods from its parent, StyleSheet.[CSSStyleSheet,
const findStyleSheet: () => [CSSStyleSheet, Set<string>] | []
Set
interface CSSStyleSheet
A single CSS style sheet. It inherits properties and methods from its parent, StyleSheet.] | [] => { if (!styleSheet) {
interface Set<T>
styleSheet =
let styleSheet: CSSStyleSheet | null | undefined
document
let styleSheet: CSSStyleSheet | null | undefined
.querySelector
var document: Document
MDN Reference<HTMLStyleElement>(`style#$
(method) ParentNode.querySelector<HTMLStyleElement>(selectors: string): HTMLStyleElement | null (+4 overloads)
Returns the first element that is a descendant of node that matches selectors.
interface HTMLStyleElement
A