interface IRequest
Since 0.1.0

Runtime-agnostic view of an incoming HTTP request.

Properties

The HTTP method.

readonly
url: string

The full request URL.

readonly
path: string

The URL path component (no query string).

readonly
headers: Headers

Request headers (web-standard Headers).

readonly
optional
ip: string

Client IP address, when derivable.

optional
user: IPrincipal

The authenticated principal, populated by authentication middleware. Absent when the request is unauthenticated.

It accepts one implicit write per request; a second assignment throws so independent identity writers fail loudly. Use replacePrincipal for an intentional replacement such as step-up authentication. This is not an authorization control: a write before authentication is still the first write and is allowed.

optional
tenant: ITenant

The resolved tenant, populated by the multi-tenancy middleware. Absent when no tenant could be resolved or multi-tenancy is not enabled.

It accepts one implicit write per request; use replaceTenant for an intentional replacement. Like user, this detects late accidental overwrites and is not an authorization control.

An abort signal that fires when the underlying HTTP connection is severed (client disconnect, timeout). Populated by the HTTP adapter from the native Request.signal; optional because injected / test requests may not carry one.

When absent, the kernel's request-context factory falls back to a non-aborting sentinel so that producers reading IRequestContext.signal always have a live signal to listen on.

Since 0.3.0
readonly
optional
raw: Request

The undisturbed web-standard Request, preserved for WebSocket upgrade and gRPC dispatch after the middleware pipeline.

Populated by the HTTP adapter before the body is consumed by the framework mapping. Optional because injected or test requests may not carry one.

Methods

json<T = unknown>(): Promise<T>

Reads and parses the body as JSON.

text(): Promise<string>

Reads the body as text.

bytes(): Promise<Uint8Array>

Reads the body as raw bytes.

Since 0.5.0
optional
formData(): Promise<FormBody>

Reads the body as a form, for both application/x-www-form-urlencoded and multipart/form-data requests.

The parse is the shared parseFormBody, memoized exactly as json() is — the in-flight promise is cached (a rejection with it), so two middleware reading the same body trigger one parse, not two.

Optional on the signal? / fs? / raw? precedent: a custom IRequest implementor may omit it. Such a caller falls back to parseFormBody(await request.bytes(), request.headers.get('content-type')), the same common function the producers call — what the accessor adds over the fallback is the memoization.

Usage

import { type IRequest } from "common/src/index.ts";