reserve

Server events

🔝 REserve documentation

The REserve server object implements an interface that mimics the EventEmitter::on method and triggers events with parameters to 'notify' any listener of its activity.

When a request is processed, the following diagram illustrates the sequence of events that are emitted.

Events TAM State Diagram

Diagram of events emitted by REserve while processing a request

[!NOTE] These events are handled by the log helper.

Event
eventName
Parameters
...members
Description
'created' server: http.server | https.server
configuration: IConfiguration
Only available to listeners, this event is emitted after the HTTP(S) server is 'created' and before it accepts requests.
'ready' urlstring
portnumber
http2boolean
The server is listening and ready to receive requests.
url contains a valid address (for instance: 'http://192.168.4.1:8080/').
'incoming' methodstring (uppercase)
incomingUrlString
urlstring
headers{ [key: string]: string \| string[] }
startDate
idnumber
internal: boolean
New request received.
incomingUrl contains the original URL (before normalization).
url contains the URL to be matched.
id is a unique identifier allocated by REserve.
internal signals internally dispatched request (see configuration interface).

These members are also available for 'error', 'redirecting','redirected', 'aborted' and 'closed' events.
'error' reasonany An error occurred.
'error' ...'incoming'
reasonany
An error occurred while processing a request.
'redirecting' ...'incoming'
typestring
redirectstring | number
Request will be processed by a handler.
type contains the handler prefix.
redirect contains the redirection value.
'redirected' ...'incoming'
endDate
timeSpentnumber (ms)
statusCodenumber
Request is fully processed.
timeSpent is evaluated by comparing start and end (not a high resolution timer).
'aborted' ...'incoming' Request was aborted.
'closed' ...'incoming' Request was closed.