Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno_nest/modules/hono/mod.ts>HonoRequest

Refer to nestjs to realize some common functions for Deno, support hono and oak
Latest
class HonoRequest
import { HonoRequest } from "https://deno.land/x/deno_nest@v3.15.1/modules/hono/mod.ts";

Constructors

new
HonoRequest(
request: Request,
path?: string,
matchResult?: Result<[unknown, RouterRoute]>,
)

Type Parameters

optional
P extends string = "/"
optional
I extends Input["out"] = { }

Properties

private
cachedBody: (key: keyof Body) => unknown
bodyCache: BodyCache
readonly
matchedRoutes: RouterRoute[]

.matchedRoutes() can return a matched route in the handler

readonly
method: string

.method() can get the method name of the request.

path: string

.path can get the pathname of the request.

raw: Request

.raw can get the raw Request object.

routeIndex: number
readonly
routePath: string

routePath() can retrieve the path registered within the handler

readonly
url: string

.url() can get the request url strings.

Methods

private
getAllDecodedParams(): Record<string, string>
private
getDecodedParam(key: string): string | undefined
private
getParamValue(paramKey: any): string | undefined
addValidatedData(target: keyof ValidationTargets, data: { })
arrayBuffer(): Promise<ArrayBuffer>

.arrayBuffer() parse Request body as an ArrayBuffer

blob(): Promise<Blob>
formData(): Promise<FormData>
header(name: string): string | undefined

.header() can get the request header value.

header(): Record<string, string>
json<T = any>(): Promise<T>

.json() can parse Request body of type application/json

param<P2 extends ParamKeys<P> = ParamKeys<P>>(key: P2 extends `${infer _}?` ? never : P2): string

.req.param() gets the path parameters.

param<P2 extends RemoveQuestion<ParamKeys<P>> = RemoveQuestion<ParamKeys<P>>>(key: P2): string | undefined
param(key: string): string | undefined
param<P2 extends string = P>(): UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>
parseBody<T extends BodyData = BodyData>(options?: ParseBodyOptions): Promise<T>

.parseBody() can parse Request body of type multipart/form-data or application/x-www-form-urlencoded

queries(key: string): string[] | undefined

.queries() can get multiple querystring parameter values, e.g. /search?tags=A&tags=B

queries(): Record<string, string[]>
query(key: string): string | undefined

.query() can get querystring parameters.

query(): Record<string, string>
text(): Promise<string>

.text() can parse Request body of type text/plain

valid<T extends keyof I & keyof ValidationTargets>(target: T): InputToDataByTarget<I, T>