import { HonoBase } from "https://dotland.deno.dev/x/hono@v4.2.6/hono-base.ts";
Constructors
new
HonoBase(options?: HonoOptions<E>)Properties
private
errorHandler: ErrorHandlerprivate
notFoundHandler: NotFoundHandler.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.
readonly
getPath: GetPath<E>notFound: (handler: NotFoundHandler<E>) => unknown
.notFound()
allows you to customize a Not Found Response.
app.notFound((c) => {
return c.text('Custom 404 Message', 404)
})
onError: (handler: ErrorHandler<E>) => unknown
.onError()
handles an error and returns a customized Response.
app.onError((err, c) => {
console.error(`${err}`)
return c.text('Custom Error Message', 500)
})
request: () => unknown
input: RequestInfo | URL,
requestInit?: RequestInit,
Env?: E["Bindings"] | { },
executionCtx?: ExecutionContext,
.request()
is a useful method for testing.
You can pass a URL or pathname to send a GET request.
app will return a Response object.
test('GET /hello is ok', async () => {
const res = await app.request('/hello')
expect(res.status).toBe(200)
})
router: Router<[H, RouterRoute]>
routes: RouterRoute[]
Methods
private
dispatch(request: Request,
executionCtx: ExecutionContext | FetchEventLike | undefined,
env: E["Bindings"],
method: string,
private
handleError(err: unknown, c: Context<E>)private
matchRoute(method: string, path: string)