Interfaces
@system-inc/base-foundation · 515c140 · 13 symbols
BaseMiddleware
A class-based middleware. Runs for each request via run().
Prefer classes when you need dependency injection. Otherwise BaseMiddlewareFn is simpler.
Members
run(requestContext:RequestContext):void | Response | Promise<void | Response>
DeferredActions
Members
append(action:() => Promise<unknown>):void
HandlerMiddleware
A class-based handler-scoped middleware. Runs after the dispatcher
has resolved the handler, so rc.handler is guaranteed to be present.
Prefer classes when you need dependency injection.
Members
run(requestContext:HandlerRequestContext):void | Response | Promise<void | Response>
HandlerRequestContext
A RequestContext narrowed to guarantee the handler has been
resolved. Passed to handler-scoped middleware so implementations do
not have to null-check rc.handler — the dispatcher has already
established the invariant by the time handler middleware runs.
extends RequestContext
Members
configuration:BaseConfigurationThe application configuration.
container:BaseInjectionContainerThe dependency injection container scoped to this request.
cookies:Readonly<Record<string, string>>The parsed cookies from the incoming request.
deferred:DeferredActionsDeferred actions to run asynchronously after the response is sent.
eventBus:BaseEventBusEvent bus for emitting events related to this request.
graphql:Omit<GqlContext, "request"> | undefinedIf this request is a GraphQL request, the GraphQL context.
handler:BaseHandlerInformation about the handler method being invoked for this request. Undefined before dispatch or for framework routes that don't map to a handler (e.g., /__version).
headers:HeadersThe HTTP headers from the incoming request.
ipAddress?:stringThe IP address of the caller, if available.
isGraphQL:booleanWhether this request is a GraphQL request.
isInternal:booleanWhether this request originated from an internal (service-to-service) caller.
isRpc:booleanWhether this request is an RPC request.
method:stringThe HTTP method of the incoming request (GET, POST, etc.).
origin:RequestOriginGeographic and locale information derived from the request (country, timezone, language preferences, etc.).
platform:unknownPlatform-specific properties about/for the request.
requestId:stringUnique identifier for this request.
response:ResponseWriterResponse data that will be sent back to the client. Use this to set cookies or append headers to the response.
route:stringThe matched route path.
routing:RoutingInfoOrigin / routing information derived from the request.
rpc:string | undefinedIf this request is an RPC request, the name of the procedure being called.
stopWatch:StopWatchStop watch for the request.
url:stringThe full URL of the incoming request.
userAgent:stringThe user agent string of the caller.
get(key:RequestContextKey<T>):T | undefinedGet a typed extension value from this request context.
require(key:RequestContextKey<T>):TGet a typed extension value from this request context, throwing if it's not set.
set(key:RequestContextKey<T>,value:T):voidSet a typed extension value on this request context. Use this from middleware to attach per-request data.
HttpBodyOptions
Members
mode?:HttpBodyModeHow to parse the request body.
json(default): parses the body as JSONstream: provides the rawReadableStreambodyformData: parses the body as multipart/form-datatext: reads the body as a stringarrayBuffer: reads the body as an ArrayBufferblob: reads the body as a Blob
HttpPathOptions
Members
decode?:booleanWhether to URL decode the parameter value. Defaults to true.
HttpQueryOptions
Members
decode?:booleanWhether to URL decode the parameter value. Defaults to true.
RequestContext
The application-facing context for the current request.
RequestContext provides a safe, structured projection of the incoming
request. It exposes the metadata and capabilities that application code
typically needs — HTTP metadata, caller info, DI, and response
control — without exposing the raw Request body or stream methods
that could lead to accidental data leaks.
All framework-owned fields are readonly from the application's
perspective. The framework populates them on the underlying concrete
implementation; app code reads them and may only write to its own
typed-key extension bag via set, get, and
require.
Module-specific concerns (device ID, session, account, etc.) should be stored and retrieved via the typed extension mechanism using RequestContextKey.
Obtain an instance via the @InjectRequestContext() parameter decorator.
Members
configuration:BaseConfigurationThe application configuration.
container:BaseInjectionContainerThe dependency injection container scoped to this request.
cookies:Readonly<Record<string, string>>The parsed cookies from the incoming request.
deferred:DeferredActionsDeferred actions to run asynchronously after the response is sent.
eventBus:BaseEventBusEvent bus for emitting events related to this request.
graphql:Omit<GqlContext, "request"> | undefinedIf this request is a GraphQL request, the GraphQL context.
handler:BaseHandler | undefinedInformation about the handler method being invoked for this request. Undefined before dispatch or for framework routes that don't map to a handler (e.g., /__version).
headers:HeadersThe HTTP headers from the incoming request.
ipAddress?:stringThe IP address of the caller, if available.
isGraphQL:booleanWhether this request is a GraphQL request.
isInternal:booleanWhether this request originated from an internal (service-to-service) caller.
isRpc:booleanWhether this request is an RPC request.
method:stringThe HTTP method of the incoming request (GET, POST, etc.).
origin:RequestOriginGeographic and locale information derived from the request (country, timezone, language preferences, etc.).
platform:PlatformType | undefinedPlatform-specific properties about/for the request.
requestId:stringUnique identifier for this request.
response:ResponseWriterResponse data that will be sent back to the client. Use this to set cookies or append headers to the response.
route:stringThe matched route path.
routing:RoutingInfoOrigin / routing information derived from the request.
rpc:string | undefinedIf this request is an RPC request, the name of the procedure being called.
stopWatch:StopWatchStop watch for the request.
url:stringThe full URL of the incoming request.
userAgent:stringThe user agent string of the caller.
get(key:RequestContextKey<T>):T | undefinedGet a typed extension value from this request context.
require(key:RequestContextKey<T>):TGet a typed extension value from this request context, throwing if it's not set.
set(key:RequestContextKey<T>,value:T):voidSet a typed extension value on this request context. Use this from middleware to attach per-request data.
ResponseTransformer
Interface for response transformers.
Members
transformResponse(response:Response,request?:RequestContext<unknown>):Response | Promise<Response>Transforms the response from the route handler.
ResponseWriter
Members
appendHeader(name:string,value:string):voidsetCookie(cookieOptions:SetCookieOptions):void
RouterCorsSettings
Members
allowCredentials?:booleanWhether credentials are allowed.
allowedHeaders?:string[]The allowed headers.
allowedMethods?:string[]The allowed methods.
allowedOrigins?:NamedConfiguration<AllowedOrigin>The allowed origins.
exposedHeaders?:string[]The exposed headers.
maxAge?:numberThe max age of the request.
preflight?:booleanAllow preflight requests.
RouterSettings
Router settings for Base applications.
Members
cors?:RouterCorsSettingsCors settings for the router.
disableAccessLog?:boolean | string[]A map of routes that should not be logged or true to disable for all routes.
rewrite?:Record<string, string>A map of paths to rewrite to other paths.
RoutingInfo
Members
origin?:stringoriginType:"public" | "internal"