Skip to main content
Module

x/cav/endpoint.ts>ResolveArg

A server framework for Deno
Go to Latest
interface ResolveArg
import { type ResolveArg } from "https://deno.land/x/cav@0.2.0-alpha.7/endpoint.ts";

Arguments available to the resolve of an endpoint.

Type Parameters

Param extends EndpointSchema["param"]
Ctx extends EndpointSchema["ctx"]
Query extends EndpointSchema["query"]
Body extends EndpointSchema["body"]

Properties

req: Request

The Request being handled.

res: ResponseInit & { headers: Headers; }

A ResponseInit applied to the endpoint response after resolving and packing the value to send to the client. The Headers object is always available.

url: URL

new URL(req.url)

conn: http.ConnInfo

Connection information provided by Deno.

path: string

The path that matched the endpoint's path schema option.

param: EndpointSchema["param"] extends Param ? ParamRecord : ParserOutput<Param>

The parsed path parameters captured while routing the request.

ctx: EndpointSchema["ctx"] extends Ctx ? undefined : ParserOutput<Ctx>

The context created after the endpoint matched the Request.

query: EndpointSchema["query"] extends Query ? QueryRecord : ParserOutput<Query>

The parsed query string parameters.

body: EndpointSchema["body"] extends Body ? undefined : ParserOutput<Body>

The parsed Request body, if any.

bundle: (opt: ServeBundleOptions) => Promise<Response>

Returns a TypeScript/JavaScript bundle as a response. The bundle is cached into memory and, if possible, watched and rebundled whenever updated.

asset: (opt?: ServeAssetOptions) => Promise<Response>

Returns a Response created using an asset from an assets directory.

redirect: (to: string, status?: number) => Response

Returns a redirect Response. If the redirect path doesn't specify an origin, the origin of the current request is used. If the path starts with a ".", it is joined with the pathname of the Request url to get the final redirect path. The default status is 302.