interface IRequestContext
Since 0.1.0

Per-request context passed to middleware and route handlers. Each request gets a fresh context; request-scoped data lives here, never in globals.

Properties

readonly
id: string

Unique request ID (generated or propagated by middleware).

readonly
request: IRequest

The incoming request.

readonly
response: IResponse

The response builder.

readonly
services: IServiceRegistry

Service resolution (application-scoped plus request-scoped services).

readonly
params: Readonly<Record<string, string>>

Path parameters extracted by the router (e.g. :id).

readonly
query: Readonly<Record<string, string>>

Query string parameters.

readonly
state: Map<string, unknown>

Request-scoped state for passing data between middleware and handlers.

readonly
startTime: number

High-resolution timestamp captured when the context was created.

Since 0.2.0
readonly
signal: AbortSignal

An abort signal that fires when the underlying HTTP connection is severed (client disconnect, timeout). Populated by the kernel's request-context factory from the native Request.signal; falls back to a non-aborting sentinel so handlers always have a live signal to listen on.

Used by streaming producers (SSE heartbeats, channel cleanup) to stop work on client disconnect and avoid leaking producers.

Since 0.3.0
readonly
optional
raw: Request

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

Threaded from IRequest.raw by the kernel's request-context factory. Absent when the adapter did not provide one (injected or test requests).

Usage

import { type IRequestContext } from "react-router-plugin/src/index.ts";