Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/bun_tea/core/context.ts>AppContext

Fast, Bun-powered, and Bun-only(for now) Web API framework with full Typescript support.
Latest
class AppContext
import { AppContext } from "https://deno.land/x/bun_tea@v0.0.1-alpha.20/core/context.ts";

Execution context for handlers and all the middlewares

Constructors

new
AppContext(req: Request, config: ZarfConfig<S>)

Type Parameters

optional
S extends Record<string, any> = { }

Properties

private
_code: number | undefined
private
_config: ZarfConfig<S>
private
_error: any
private
_isImmediate: boolean
private
_locals: S
private
_middlewares: Array<MiddlewareFunction<S>>
private
readonly
_request: Request | null
private
_response: Response | null
readonly
afterMiddlewares
body: ParsedBody | null
error

Get Error

readonly
headers: Request["headers"]
readonly
host: string | undefined
readonly
isImmediate
locals: S

Get available App-specific details

readonly
meta: ContextMeta
readonly
method: RouteMethod
readonly
path: string
readonly
query: URLSearchParams | undefined
readonly
request

Get the current request in the raw form

response

Get the Response if any

status: number

Get the current status code

readonly
url: URL

Methods

Use the settings from available Response details, if there's one (as an outcome of handler processing and middleware execution)

halt(statusCode: number, body: any): Promise<Response>

Halt flow, and return with currently provided status

Just return with head details

html(text: string, args?: ResponseInit): Response

Send the provided value as html

json(body: any, args?: ResponseInit): Response

Send the provided values as json

redirect(url: string, statusCode?: number): Response

Redirect to the given URL

send(body: any, args?: ResponseInit): Promise<Response>

Send the response as string, json, etc. - One sender to rule `em all!

setHeader(headerKey: string, headerVal: string)
setVary(...headerVals: Array<HeaderVaryContent>)
text(_text: string, args?: ResponseInit): Response

Send the provided value as text