QHTTPEngine
@quik/http / QHTTPEngine
Abstract Class: QHTTPEngine
Defined in: http/src/engine/QHTTPEngine.ts:17
Base class for HTTP engines providing common lifecycle helpers.
Extends
QObject
Implements
Constructors
Constructor
new QHTTPEngine():
QHTTPEngine
Returns
QHTTPEngine
Inherited from
QObject.constructor
Properties
_server
protected_server:Server
Defined in: http/src/engine/QHTTPEngine.ts:25
Instance of the node:http server.
_setupCompleted
protected_setupCompleted:boolean=false
Defined in: http/src/engine/QHTTPEngine.ts:18
Accessors
engine
Get Signature
get
abstractengine():string
Defined in: http/src/engine/QHTTPEngine.ts:20
Name of the underlying engine implementation.
Returns
string
Name of the underlying engine implementation.
Implementation of
host
Get Signature
get host():
string
Defined in: http/src/engine/QHTTPEngine.ts:51
Lists the host on which we expose the server.
Returns
string
Host on which the server listens.
Implementation of
isListening
Get Signature
get isListening():
boolean
Defined in: http/src/engine/QHTTPEngine.ts:37
Flag to let the user know that the server was started and listening for connections.
Returns
boolean
Indicates whether the server is listening.
Implementation of
isSetupCompleted
Get Signature
get
protectedisSetupCompleted():boolean
Defined in: http/src/engine/QHTTPEngine.ts:55
Returns
boolean
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
port
Get Signature
get port():
number
Defined in: http/src/engine/QHTTPEngine.ts:44
Lists the port on which we expose the server.
Returns
number
Port on which the server listens.
Implementation of
server
Get Signature
get server():
Server
Defined in: http/src/engine/QHTTPEngine.ts:30
Getter for the node:http server.
Returns
Server
Node HTTP server instance used by the engine.
Implementation of
staticContentDefinition
Get Signature
get
protectedstaticContentDefinition():QStaticContent
Defined in: http/src/engine/QHTTPEngine.ts:59
Returns
Methods
addResponseSpanAttributes()
protectedaddResponseSpanAttributes(span,response):void
Defined in: http/src/engine/QHTTPEngine.ts:275
Add response metadata to the telemetry span when available.
Parameters
span
TelemetrySpan
response
Returns
void
close()
abstractprotectedclose():Promise<void>
Defined in: http/src/engine/QHTTPEngine.ts:134
Close the underlying server.
Returns
Promise<void>
defaultErrorHandler()
protecteddefaultErrorHandler(serverError,translate?):IQErrorResponse
Defined in: http/src/engine/QHTTPEngine.ts:148
Default error handler used when the engine fails processing a request.
Parameters
serverError
Error
The thrown error instance.
translate?
QTranslatorFunction
Optional translation function.
Returns
endRequestSpan()
protectedendRequestSpan(span?):void
Defined in: http/src/engine/QHTTPEngine.ts:314
End the telemetry span when available.
Parameters
span?
TelemetrySpan
Returns
void
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
execute()
protectedexecute(event,route,endpoint):Promise<IQResponse<any>>
Defined in: http/src/engine/QHTTPEngine.ts:226
Parameters
event
route
endpoint
Returns
Promise<IQResponse<any>>
getPath()
protectedgetPath(...pathElements):string
Defined in: http/src/engine/QHTTPEngine.ts:222
Join multiple path elements using the framework utility.
Parameters
pathElements
...string[]
Returns
string
listen()
abstractprotectedlisten():Promise<void>
Defined in: http/src/engine/QHTTPEngine.ts:131
Listen for incoming connections.
Returns
Promise<void>
recordRequestSpanError()
protectedrecordRequestSpanError(span,err):void
Defined in: http/src/engine/QHTTPEngine.ts:325
Record an error on the telemetry span when available.
Parameters
span
TelemetrySpan
err
unknown
Returns
void
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
registerEndpoint()
abstractprotectedregisterEndpoint(route,endpoint):void
Defined in: http/src/engine/QHTTPEngine.ts:217
Register a single endpoint for the given route.
Parameters
route
The parent route.
endpoint
Endpoint definition to register.
Returns
void
registerErrorHandler()
abstractprotectedregisterErrorHandler():Promise<void>
Defined in: http/src/engine/QHTTPEngine.ts:140
Register the error handler for the engine.
Returns
Promise<void>
registerRoute()
protectedregisterRoute(route):void
Defined in: http/src/engine/QHTTPEngine.ts:202
Register all endpoints associated with a route.
Parameters
route
The route being registered.
Returns
void
registerRoutes()
protectedregisterRoutes():void
Defined in: http/src/engine/QHTTPEngine.ts:187
Register all routes available in the router.
Returns
void
registerStaticContent()
abstractprotectedregisterStaticContent():Promise<void>
Defined in: http/src/engine/QHTTPEngine.ts:137
Register static content handlers.
Returns
Promise<void>
reload()
reload():
Promise<void>
Defined in: http/src/engine/QHTTPEngine.ts:108
Stop the server, re-register all routes and static content, then restart listening. The error handler registered at startup is preserved across reloads.
Returns
Promise<void>
Implementation of
reset()
abstractprotectedreset():void
Defined in: http/src/engine/QHTTPEngine.ts:128
Reset the engine's internal routing state so that routes can be re-registered. Called by reload after the server is stopped.
Returns
void
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
setupCompleted()
protectedsetupCompleted():void
Defined in: http/src/engine/QHTTPEngine.ts:100
Mark the setup process as completed.
Returns
void
start()
start():
Promise<void>
Defined in: http/src/engine/QHTTPEngine.ts:66
Start the HTTP server and register routes when needed.
Returns
Promise<void>
Implementation of
startRequestSpan()
protectedstartRequestSpan(route,endpoint):TelemetrySpan
Defined in: http/src/engine/QHTTPEngine.ts:260
Start a telemetry span for the request pipeline when available.
Parameters
route
endpoint
Returns
TelemetrySpan
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
stop()
stop():
Promise<void>
Defined in: http/src/engine/QHTTPEngine.ts:87
Stop the HTTP server.
Returns
Promise<void>