Skip to main content

QContext

@quik/http


@quik/http / QContext

Abstract Class: QContext<TRequest, TResponse, TUser>

Defined in: http/src/router/endpoint/QContext.ts:63

Base HTTP context wrapping the underlying request and response objects.

Extends

  • QObject

Type Parameters

TRequest

TRequest extends http.IncomingMessage

TResponse

TResponse extends http.ServerResponse

TUser

TUser extends IQUser = IQUser

Implements

Constructors

Constructor

new QContext<TRequest, TResponse, TUser>(request, response): QContext<TRequest, TResponse, TUser>

Defined in: http/src/router/endpoint/QContext.ts:72

Create a new request context wrapper.

Parameters

request

TRequest

response

TResponse

Returns

QContext<TRequest, TResponse, TUser>

Overrides

QObject.constructor

Properties

_authorization?

protected optional _authorization?: IQAuthorizationInformation

Defined in: http/src/router/endpoint/QContext.ts:173


_body

protected _body: ObjectLiteral

Defined in: http/src/router/endpoint/QContext.ts:135


_custom

protected _custom: Record<string, any> = {}

Defined in: http/src/router/endpoint/QContext.ts:67


_files

protected _files: Record<string, ObjectLiteral[]>

Defined in: http/src/router/endpoint/QContext.ts:145


_headers

protected _headers: Record<string, string> = {}

Defined in: http/src/router/endpoint/QContext.ts:105


_ip

protected _ip: string

Defined in: http/src/router/endpoint/QContext.ts:211


_language

protected _language: string

Defined in: http/src/router/endpoint/QContext.ts:201


_method

protected _method: string

Defined in: http/src/router/endpoint/QContext.ts:95


_path

protected _path: Record<string, string>

Defined in: http/src/router/endpoint/QContext.ts:159


_query

protected _query: Record<string, string | string[]>

Defined in: http/src/router/endpoint/QContext.ts:125


_request

protected _request: TRequest

Defined in: http/src/router/endpoint/QContext.ts:231


_requestId

protected _requestId: string

Defined in: http/src/router/endpoint/QContext.ts:115


_response

protected _response: TResponse

Defined in: http/src/router/endpoint/QContext.ts:241


_url

protected _url: URL

Defined in: http/src/router/endpoint/QContext.ts:251


_user

protected _user: TUser

Defined in: http/src/router/endpoint/QContext.ts:183


_userAgent

protected _userAgent: string

Defined in: http/src/router/endpoint/QContext.ts:221

Accessors

authorization

Get Signature

get authorization(): IQAuthorizationInformation

Defined in: http/src/router/endpoint/QContext.ts:175

Returns

IQAuthorizationInformation

Set Signature

set authorization(value): void

Defined in: http/src/router/endpoint/QContext.ts:179

Parameters
value

IQAuthorizationInformation

Returns

void

Implementation of

IQContext.authorization


body

Get Signature

get body(): ObjectLiteral

Defined in: http/src/router/endpoint/QContext.ts:137

Returns

ObjectLiteral

Set Signature

set body(body): void

Defined in: http/src/router/endpoint/QContext.ts:141

Parameters
body

ObjectLiteral

Returns

void

Implementation of

IQContext.body


files

Get Signature

get files(): Record<string, ObjectLiteral[]>

Defined in: http/src/router/endpoint/QContext.ts:147

Returns

Record<string, ObjectLiteral[]>

Set Signature

set files(files): void

Defined in: http/src/router/endpoint/QContext.ts:155

Parameters
files

Record<string, ObjectLiteral[]>

Returns

void

Implementation of

IQContext.files


headers

Get Signature

get headers(): Record<string, string>

Defined in: http/src/router/endpoint/QContext.ts:107

Returns

Record<string, string>

Set Signature

set headers(value): void

Defined in: http/src/router/endpoint/QContext.ts:111

Parameters
value

Record<string, string>

Returns

void

Implementation of

IQContext.headers


ip

Get Signature

get ip(): string

Defined in: http/src/router/endpoint/QContext.ts:213

Returns

string

Set Signature

set ip(value): void

Defined in: http/src/router/endpoint/QContext.ts:217

Parameters
value

string

Returns

void

Implementation of

IQContext.ip


language

Get Signature

get language(): string

Defined in: http/src/router/endpoint/QContext.ts:203

Returns

string

Set Signature

set language(lang): void

Defined in: http/src/router/endpoint/QContext.ts:207

Parameters
lang

string

Returns

void

Implementation of

IQContext.language


logger

Get Signature

get protected logger(): IQLogger

Defined in: core/src/QObject.ts:15

The logger getter for the object.

Returns

IQLogger

Inherited from

QObject.logger


method

Get Signature

get method(): string

Defined in: http/src/router/endpoint/QContext.ts:97

Returns

string

Set Signature

set method(value): void

Defined in: http/src/router/endpoint/QContext.ts:101

Parameters
value

string

Returns

void

Implementation of

IQContext.method


name

Get Signature

get name(): string

Defined in: core/src/QObject.ts:8

Returns

string

Inherited from

QObject.name


page

Get Signature

get page(): string

Defined in: http/src/router/endpoint/QContext.ts:169

Returns

string

Implementation of

IQContext.page


path

Get Signature

get path(): Record<string, string>

Defined in: http/src/router/endpoint/QContext.ts:161

Returns

Record<string, string>

Set Signature

set path(path): void

Defined in: http/src/router/endpoint/QContext.ts:165

Parameters
path

Record<string, string>

Returns

void

Implementation of

IQContext.path


query

Get Signature

get query(): Record<string, string | string[]>

Defined in: http/src/router/endpoint/QContext.ts:127

Returns

Record<string, string | string[]>

Set Signature

set query(value): void

Defined in: http/src/router/endpoint/QContext.ts:131

Parameters
value

Record<string, string | string[]>

Returns

void

Implementation of

IQContext.query


request

Get Signature

get protected request(): TRequest

Defined in: http/src/router/endpoint/QContext.ts:233

Returns

TRequest

Set Signature

set protected request(request): void

Defined in: http/src/router/endpoint/QContext.ts:237

Parameters
request

TRequest

Returns

void


requestId

Get Signature

get requestId(): string

Defined in: http/src/router/endpoint/QContext.ts:117

Returns

string

Set Signature

set requestId(value): void

Defined in: http/src/router/endpoint/QContext.ts:121

Parameters
value

string

Returns

void

Implementation of

IQContext.requestId


response

Get Signature

get protected response(): TResponse

Defined in: http/src/router/endpoint/QContext.ts:243

Returns

TResponse

Set Signature

set protected response(response): void

Defined in: http/src/router/endpoint/QContext.ts:247

Parameters
response

TResponse

Returns

void


scheme

Get Signature

get scheme(): string

Defined in: http/src/router/endpoint/QContext.ts:197

Returns

string

Implementation of

IQContext.scheme


token

Get Signature

get token(): string

Defined in: http/src/router/endpoint/QContext.ts:193

Returns

string

Implementation of

IQContext.token


url

Get Signature

get protected url(): URL

Defined in: http/src/router/endpoint/QContext.ts:253

Returns

URL

Set Signature

set protected url(value): void

Defined in: http/src/router/endpoint/QContext.ts:257

Parameters
value

URL

Returns

void


user

Get Signature

get user(): TUser

Defined in: http/src/router/endpoint/QContext.ts:185

Returns

TUser

Set Signature

set user(user): void

Defined in: http/src/router/endpoint/QContext.ts:189

Parameters
user

TUser

Returns

void

Implementation of

IQContext.user


userAgent

Get Signature

get userAgent(): string

Defined in: http/src/router/endpoint/QContext.ts:223

Returns

string

Set Signature

set userAgent(value): void

Defined in: http/src/router/endpoint/QContext.ts:227

Parameters
value

string

Returns

void

Implementation of

IQContext.userAgent

Methods

clearCookie()

abstract clearCookie(cookieName, options?): void

Defined in: http/src/router/endpoint/QContext.ts:316

Remove a cookie from the current response.

Parameters

cookieName

string

Cookie name to remove

options?

IQCookieOptions

Cookie options applied by the HTTP adapter

Returns

void

Implementation of

IQContext.clearCookie


endSpan()

protected endSpan(span): void

Defined in: core/src/QObject.ts:35

End a span returned by startSpan.

Parameters

span

TelemetrySpan

The span to end.

Returns

void

Inherited from

QObject.endSpan


getCookie()

abstract getCookie(cookieName): string

Defined in: http/src/router/endpoint/QContext.ts:299

Read a cookie value from the current request.

Parameters

cookieName

string

Cookie name to read

Returns

string

Implementation of

IQContext.getCookie


getObject()

getObject<T>(key): T

Defined in: http/src/router/endpoint/QContext.ts:283

Retrieve a custom object stored on the request.

Type Parameters

T

T = any

Parameters

key

string

Returns

T

Implementation of

IQContext.getObject


init()

abstract protected init(): void

Defined in: http/src/router/endpoint/QContext.ts:318

Returns

void


logout()

logout(): void

Defined in: http/src/router/endpoint/QContext.ts:271

Log out the current user if possible.

Returns

void

Implementation of

IQContext.logout


recordSpanError()

protected recordSpanError(span, err): void

Defined in: core/src/QObject.ts:45

Record an exception on an active span.

Parameters

span

TelemetrySpan

The span to record the error on.

err

unknown

The error to record.

Returns

void

Inherited from

QObject.recordSpanError


setCookie()

abstract setCookie(cookieName, cookieValue, options?): void

Defined in: http/src/router/endpoint/QContext.ts:308

Add a cookie to the current response.

Parameters

cookieName

string

Cookie name to write

cookieValue

string

Cookie value to write

options?

IQCookieOptions

Cookie options applied by the HTTP adapter

Returns

void

Implementation of

IQContext.setCookie


setObject()

setObject<T>(key, object): void

Defined in: http/src/router/endpoint/QContext.ts:290

Store a custom object on the request context.

Type Parameters

T

T = any

Parameters

key

string

object

T

Returns

void

Implementation of

IQContext.setObject


setSpanAttribute()

protected setSpanAttribute(span, key, value): void

Defined in: core/src/QObject.ts:64

Set a single attribute on an active span.

Parameters

span

TelemetrySpan

The span to update.

key

string

Attribute key.

value

string | number | boolean

Attribute value.

Returns

void

Inherited from

QObject.setSpanAttribute


startSpan()

protected startSpan(spanName, options?): TelemetrySpan

Defined in: core/src/QObject.ts:26

Start a telemetry span for the given operation name. Returns undefined when no telemetry provider is active.

Parameters

spanName

string

Name of the span.

options?

TelemetrySpanOptions

Optional span attributes and kind.

Returns

TelemetrySpan

Inherited from

QObject.startSpan


translate()

translate(key, parameters?): string

Defined in: http/src/router/endpoint/QContext.ts:264

Translate a key using the request bound translator or global i18n.

Parameters

key

string

parameters?

ObjectLiteral

Returns

string

Implementation of

IQContext.translate