Skip to content

ShokupanContext

Defined in: src/context.ts:28

State extends Record<string, any> = Record<string, any>

new ShokupanContext<State>(request, server?, state?, app?, signal?, enableMiddlewareTracking?): ShokupanContext<State>

Defined in: src/context.ts:39

any

Server

State

Shokupan

AbortSignal

boolean = false

ShokupanContext<State>

optional _debug: DebugCollector

Defined in: src/context.ts:35


optional _finalResponse: Response

Defined in: src/context.ts:36


optional _rawBody: string | ArrayBuffer | Uint8Array<ArrayBufferLike>

Defined in: src/context.ts:37


readonly optional app: Shokupan

Defined in: src/context.ts:43


handlerStack: HandlerStackItem[] = []

Defined in: src/context.ts:32


params: Record<string, string> = {}

Defined in: src/context.ts:30


optional renderer: JSXRenderer

Defined in: src/context.ts:408

JSX Rendering Function


readonly request: any

Defined in: src/context.ts:40


readonly response: ShokupanResponse

Defined in: src/context.ts:34


readonly optional server: Server

Defined in: src/context.ts:41


session: SessionData & object

Defined in: src/plugins/session.ts:200

id: string

destroy(callback): void

(err) => void

void

regenerate(callback): void

(err) => void

void

reload(callback): void

(err) => void

void

save(callback): void

(err) => void

void

touch(): void

void


sessionID: string

Defined in: src/plugins/session.ts:201


sessionStore: Store

Defined in: src/plugins/session.ts:202


readonly optional signal: AbortSignal

Defined in: src/context.ts:44


state: State

Defined in: src/context.ts:31

get headers(): any

Defined in: src/context.ts:167

Request headers

any


get host(): string

Defined in: src/context.ts:147

Request host (e.g. “localhost:3000”)

string


get hostname(): string

Defined in: src/context.ts:142

Request hostname (e.g. “localhost”)

string


get ip(): SocketAddress

Defined in: src/context.ts:137

Client IP address

SocketAddress


get method(): any

Defined in: src/context.ts:81

HTTP method

any


get origin(): string

Defined in: src/context.ts:162

Request origin (e.g. “http://localhost:3000”)

string


get path(): any

Defined in: src/context.ts:85

Request path

any


get protocol(): string

Defined in: src/context.ts:152

Request protocol (e.g. “http:”, “https:“)

string


get query(): Record<string, any>

Defined in: src/context.ts:120

Request query params

Record<string, any>


get req(): any

Defined in: src/context.ts:77

Base request

any


get res(): ShokupanResponse

Defined in: src/context.ts:178

Base response object

ShokupanResponse


get secure(): boolean

Defined in: src/context.ts:157

Whether request is secure (https)

boolean


get url(): URL

Defined in: src/context.ts:65

URL

body<T>(): Promise<T>

Defined in: src/context.ts:283

Read request body

T = any

Promise<T>


file(path, fileOptions?, responseOptions?): Promise<Response>

Defined in: src/context.ts:384

Respond with a file

string

BlobPropertyBag

ResponseInit

Promise<Response>


get(name): any

Defined in: src/context.ts:173

Get a request header

string

Header name

any


html(html, status?, headers?): Response

Defined in: src/context.ts:349

Respond with HTML content

string

number

HeadersInit

Response


json(data, status?, headers?): Response

Defined in: src/context.ts:298

Respond with a JSON object

any

number

HeadersInit

Response


jsx(element, args?, status?, headers?): Promise<Response>

Defined in: src/context.ts:416

Render a JSX element

any

JSX Element

unknown

number

HTTP Status

HeadersInit

HTTP Headers

Promise<Response>


redirect(url, status): Response

Defined in: src/context.ts:364

Respond with a redirect

string

number = 302

Response


send(body?, options?): Response

Defined in: src/context.ts:267

Send a response

BodyInit

Response body

ResponseInit

Response options

Response

Response


set(key, value): ShokupanContext<State>

Defined in: src/context.ts:185

Helper to set a header on the response

string

Header key

string

Header value

ShokupanContext<State>


setCookie(name, value, options): ShokupanContext<State>

Defined in: src/context.ts:196

Set a cookie

string

Cookie name

string

Cookie value

CookieOptions = {}

Cookie options

ShokupanContext<State>


status(status): Response

Defined in: src/context.ts:375

Respond with a status code DOES NOT CHAIN!

number

Response


text(data, status?, headers?): Response

Defined in: src/context.ts:324

Respond with a text string

string

number

HeadersInit

Response