Classes
@system-inc/base-foundation · 515c140 · 3 symbols
HttpResponses
Class for creating common HTTP responses.
Members
static fromError(error:BaseError,responseInit?:ResponseInit):ResponseCreates a Response from a BaseError.
This response will be the same as if the BaseError was thrown, however it will not produce a stack trace in the logs, indicating that this was an expected error condition, which may be desired.
static fromJson(json:unknown,responseInit?:ResponseInit):ResponseCreates a Response from a JSON object.
static noContent(responseInit?:ResponseInit):ResponseCreates a status 204 No Content with null response body (required for no-content).
static ok(responseInit?:ResponseInit):ResponseCreates a empty response with status 200 OK.
This is used to signal a successful request or server processing to the client when no response body is required, desired or necessary.
static redirect(url:string | URL,status:HttpRedirectStatusCode):ResponseCreates a redirect Response.
RequestContextKey
A branded key for type-safe extension storage on RequestContext.
Modules create keys to store and retrieve per-request data without stringly-typed lookups:
Extends TypedKey with the 'request-context' scope brand so
request-context keys cannot be confused with environment, module, or
WebSocket keys at the type level.
Two keys with the same name would collide on the underlying
per-request Map and silently overwrite each other. create
enforces uniqueness at creation time and throws on duplicates, so
the failure surfaces at module load rather than as mysterious
read-wrong-value bugs at runtime. Define each key once at module
scope and import it where needed.
extends TypedKey<T, "request-context">
Members
_brand:Tphantom type brand — never assigned at runtime
_scope:"request-context"phantom scope brand — never assigned at runtime
name:stringstatic create(name:string):RequestContextKey<T>Creates a typed extension key for storing per-request data.
Throws if a
RequestContextKeywith the samenamehas already been created.
RequestOrigin
Members
acceptLanguageHeader:string | undefinedcity:string | undefinedcountry:string | undefinedlanguagePreferences:readonly LanguagePreference[]latitude:string | undefinedlongitude:string | undefinedregion:string | undefinedtimeZone:string | undefinedlocale:{ languageCode?: string; timezone?: string }location:stringpreferredLanguage:string | undefined