QEvent
@quik/http / QEvent
Class: QEvent<TPathParameters, TQueryParameters, TBody, TUser>
Defined in: http/src/router/endpoint/QEvent.ts:159
Event wrapper used when executing an endpoint.
Extends
QObject
Type Parameters
TPathParameters
TPathParameters = ObjectLiteral
TQueryParameters
TQueryParameters = ObjectLiteral
TBody
TBody = ObjectLiteral
TUser
Implements
IQEvent<TPathParameters,TQueryParameters,TBody,TUser>
Constructors
Constructor
new QEvent<
TPathParameters,TQueryParameters,TBody,TUser>(context,parameters):QEvent<TPathParameters,TQueryParameters,TBody,TUser>
Defined in: http/src/router/endpoint/QEvent.ts:169
Create a new event associated with a context and parameter definition.
Parameters
context
IQContext<TUser>
Request context used by the endpoint event
parameters
Endpoint parameter definition used for entity initialization
Returns
QEvent<TPathParameters, TQueryParameters, TBody, TUser>
Overrides
QObject.constructor
Properties
_body
protected_body:TBody
Defined in: http/src/router/endpoint/QEvent.ts:188
_context
protected_context:IQContext<TUser>
Defined in: http/src/router/endpoint/QEvent.ts:263
_parameters
protected_parameters:EndpointParametersDefinition
Defined in: http/src/router/endpoint/QEvent.ts:283
_path
protected_path:TPathParameters
Defined in: http/src/router/endpoint/QEvent.ts:215
_query
protected_query:TQueryParameters
Defined in: http/src/router/endpoint/QEvent.ts:175
Accessors
body
Get Signature
get body():
TBody
Defined in: http/src/router/endpoint/QEvent.ts:193
Validated request body entity or object.
Returns
TBody
Set Signature
set body(
value):void
Defined in: http/src/router/endpoint/QEvent.ts:197
Validated request body entity or object.
Parameters
value
TBody
Returns
void
Validated request body entity or object.
Implementation of
context
Get Signature
get context():
IQContext<TUser>
Defined in: http/src/router/endpoint/QEvent.ts:268
Request context used by the endpoint event.
Returns
IQContext<TUser>
Set Signature
set context(
value):void
Defined in: http/src/router/endpoint/QEvent.ts:272
Parameters
value
IQContext<TUser>
Returns
void
files
Get Signature
get files():
Record<string,ObjectLiteral[]>
Defined in: http/src/router/endpoint/QEvent.ts:279
Uploaded files attached to the request body.
Returns
Record<string, ObjectLiteral[]>
ip
Get Signature
get ip():
string
Defined in: http/src/router/endpoint/QEvent.ts:245
Client IP address for the current request.
Returns
string
Client IP address for the current request.
Implementation of
language
Get Signature
get language():
string
Defined in: http/src/router/endpoint/QEvent.ts:204
Active request language.
Returns
string
Active request language.
Implementation of
logger
Get Signature
get
protectedlogger():IQLogger
Defined in: core/src/QObject.ts:15
The logger getter for the object.
Returns
IQLogger
Inherited from
QObject.logger
name
Get Signature
get name():
string
Defined in: core/src/QObject.ts:8
Returns
string
Inherited from
QObject.name
parameters
Get Signature
get
protectedparameters():EndpointParametersDefinition
Defined in: http/src/router/endpoint/QEvent.ts:285
Returns
Set Signature
set
protectedparameters(value):void
Defined in: http/src/router/endpoint/QEvent.ts:289
Parameters
value
Returns
void
path
Get Signature
get path():
TPathParameters
Defined in: http/src/router/endpoint/QEvent.ts:220
Validated path parameter entity or object.
Returns
TPathParameters
Set Signature
set path(
value):void
Defined in: http/src/router/endpoint/QEvent.ts:224
Validated path parameter entity or object.
Parameters
value
TPathParameters
Returns
void
Validated path parameter entity or object.
Implementation of
query
Get Signature
get query():
TQueryParameters
Defined in: http/src/router/endpoint/QEvent.ts:180
Validated query parameter entity or object.
Returns
TQueryParameters
Set Signature
set query(
value):void
Defined in: http/src/router/endpoint/QEvent.ts:184
Validated query parameter entity or object.
Parameters
value
TQueryParameters
Returns
void
Validated query parameter entity or object.
Implementation of
requestId
Get Signature
get requestId():
string
Defined in: http/src/router/endpoint/QEvent.ts:211
Request identifier used for tracing.
Returns
string
Request identifier used for tracing.
Implementation of
scheme
Get Signature
get scheme():
string
Defined in: http/src/router/endpoint/QEvent.ts:238
Authorization scheme extracted from the request.
Returns
string
Authorization scheme extracted from the request.
Implementation of
token
Get Signature
get token():
string
Defined in: http/src/router/endpoint/QEvent.ts:231
Authorization token extracted from the request.
Returns
string
Authorization token extracted from the request.
Implementation of
user
Get Signature
get user():
TUser
Defined in: http/src/router/endpoint/QEvent.ts:259
Authenticated user associated with the request.
Returns
TUser
Authenticated user associated with the request.
Implementation of
userAgent
Get Signature
get userAgent():
string
Defined in: http/src/router/endpoint/QEvent.ts:252
User agent header value for the current request.
Returns
string
User agent header value for the current request.
Implementation of
Methods
clearCookie()
clearCookie(
cookieName,options?):void
Defined in: http/src/router/endpoint/QEvent.ts:387
Remove a cookie from the current response.
Parameters
cookieName
string
Cookie name to remove
options?
Cookie options applied by the HTTP adapter
Returns
void
Implementation of
endSpan()
protectedendSpan(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
freeze()
freeze():
void
Defined in: http/src/router/endpoint/QEvent.ts:324
Freezes the current entity to the current values and properties list.
Returns
void
Implementation of
getCookie()
getCookie(
cookieName):string
Defined in: http/src/router/endpoint/QEvent.ts:366
Read a cookie value from the current request.
Parameters
cookieName
string
Cookie name to read
Returns
string
Implementation of
getObject()
getObject<
T>(key):T
Defined in: http/src/router/endpoint/QEvent.ts:307
Retrieve a custom object stored on the request context.
Type Parameters
T
T = any
Parameters
key
string
Object key to read
Returns
T
Implementation of
getParameter()
protectedgetParameter(type,data):Promise<QEntity|QEntity[]>
Defined in: http/src/router/endpoint/QEvent.ts:423
Initialize and validate a parameter entity from request data.
Parameters
type
"body" | "path" | "query"
Parameter source to initialize
data
any
Request data used to initialize the entity
Returns
Promise<QEntity | QEntity[]>
Throws
BodyValidationError If an array body is required or body validation fails.
header()
header(
headerName):string
Defined in: http/src/router/endpoint/QEvent.ts:298
Read a request header value.
Parameters
headerName
string
Header name to read
Returns
string
Implementation of
init()
init():
Promise<void>
Defined in: http/src/router/endpoint/QEvent.ts:333
Initialize configured endpoint parameters from the request context.
Returns
Promise<void>
Throws
BodyValidationError If the request body must be an array.
Implementation of
logout()
logout():
void
Defined in: http/src/router/endpoint/QEvent.ts:347
Log out the current user through the request context.
Returns
void
Implementation of
recordSpanError()
protectedrecordSpanError(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
service()
service<
T>(service):T
Defined in: http/src/router/endpoint/QEvent.ts:396
Resolve a service for the current event context.
Type Parameters
T
T extends QService = QService
Parameters
service
string | Constructor<T>
Service constructor or service name to resolve
Returns
T
setCookie()
setCookie(
cookieName,cookieValue,options?):void
Defined in: http/src/router/endpoint/QEvent.ts:377
Add a cookie to the current response.
Parameters
cookieName
string
Cookie name to write
cookieValue
string
Cookie value to write
options?
Cookie options applied by the HTTP adapter
Returns
void
Implementation of
setObject()
setObject<
T>(key,value):void
Defined in: http/src/router/endpoint/QEvent.ts:317
Store a custom object on the request context.
Type Parameters
T
T = any
Parameters
key
string
Object key to write
value
T
Object value to store
Returns
void
Implementation of
setSpanAttribute()
protectedsetSpanAttribute(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()
protectedstartSpan(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/QEvent.ts:357
Translate a key using the request context.
Parameters
key
string
Translation key to resolve
parameters?
ObjectLiteral
Translation interpolation parameters
Returns
string