Class: OutgoingResponse
Class: OutgoingResponse
Class representing an OutgoingResponse.
Extends
Constructors
Constructor
protected new OutgoingResponse(options): OutgoingResponse;
Create an OutgoingResponse.
Parameters
options
The options to create an OutgoingResponse.
Returns
OutgoingResponse
Overrides
Properties
_content
protected _content: unknown;
The content of the response.
_statusCode?
protected optional _statusCode: number;
The status code of the response.
_statusMessage?
protected optional _statusMessage: string;
The status message of the response.
metadata
readonly metadata: Record<string, unknown>;
The metadata associated with the event.
Inherited from
originalContent
readonly originalContent: unknown;
The original content of the response.
prepared
protected prepared: boolean;
The prepared status of the response.
source?
readonly optional source: object;
The source of the event.
Inherited from
timeStamp
readonly timeStamp: number;
The timestamp of the event creation.
Inherited from
type
readonly type: string;
The type of the event.
Inherited from
Accessors
content
Get Signature
get content(): unknown;
Gets the content of the outgoing response.
Returns
unknown
The content of the outgoing response.
isPrepared
Get Signature
get isPrepared(): boolean;
Gets the prepared status of the outgoing response.
Returns
boolean
The prepared status of the response.
statusCode
Get Signature
get statusCode(): undefined | number;
Gets the status code of the outgoing response.
Returns
undefined
| number
The status code of the response, or undefined if not set.
statusMessage
Get Signature
get statusMessage(): undefined | string;
Gets the status message of the outgoing response.
Returns
undefined
| string
The status message of the response, or undefined if not set.
Methods
clone()
clone<T>(): T;
Return a cloned instance.
Type Parameters
T
T
extends OutgoingResponse
Returns
T
A cloned instance of the current class.
Inherited from
get()
Get data from metadata.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Call Signature
get<TReturn>(key): undefined | TReturn;
Get data from metadata.
Type Parameters
TReturn
TReturn
= unknown
Parameters
key
string
The key to retrieve from metadata.
Returns
undefined
| TReturn
The value associated with the key or the fallback.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Inherited from
Call Signature
get<TReturn>(key, fallback): TReturn;
Get data from metadata.
Type Parameters
TReturn
TReturn
= unknown
Parameters
key
string
The key to retrieve from metadata.
fallback
TReturn
The fallback value if the key is not found.
Returns
TReturn
The value associated with the key or the fallback.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Inherited from
getMetadataValue()
Get data from metadata.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Call Signature
getMetadataValue<TReturn>(key): undefined | TReturn;
Get data from metadata.
Type Parameters
TReturn
TReturn
= unknown
Parameters
key
string
The key to retrieve from metadata.
Returns
undefined
| TReturn
The value associated with the key or the fallback.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Inherited from
Call Signature
getMetadataValue<TReturn>(key, fallback): TReturn;
Get data from metadata.
Type Parameters
TReturn
TReturn
= unknown
Parameters
key
string
The key to retrieve from metadata.
fallback
TReturn
The fallback value if the key is not found.
Returns
TReturn
The value associated with the key or the fallback.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Inherited from
is()
is(key, value): boolean;
Check if the given value is equal to the specified value.
Parameters
key
string
The key to check.
value
unknown
The value to compare against.
Returns
boolean
True if the key's value is equal to the specified value, false otherwise.
Inherited from
prepare()
prepare(_event, _container?): Promiseable<OutgoingResponse>;
Prepare response before sending it.
Parameters
_event
The incoming event associated with this response.
_container?
Container
The container.
Returns
Promiseable
<OutgoingResponse
>
This OutgoingResponse instance.
setContent()
setContent(content): this;
Set the content of the response.
Parameters
content
unknown
The content to set.
Returns
this
This OutgoingResponse instance.
setMetadataValue()
setMetadataValue(key, value?): this;
Add data to metadata.
Parameters
key
The key or object to add to metadata.
string
| Record
<string
, unknown
>
value?
unknown
The value to associate with the key.
Returns
this
This Event instance.
Inherited from
setPrepared()
setPrepared(prepared): this;
Set the prepared status of the response.
Parameters
prepared
boolean
The prepared status to set.
Returns
this
This OutgoingResponse instance.
setStatus()
setStatus(code, text?): this;
Set the status code of the response.
Parameters
code
number
The status code.
text?
string
Optional status message.
Returns
this
This OutgoingResponse instance.
create()
static create(options): OutgoingResponse;
Create an OutgoingResponse.
Parameters
options
The options to create an OutgoingResponse.
Returns
OutgoingResponse
A new OutgoingResponse instance.
Events
OUTGOING_RESPONSE
static OUTGOING_RESPONSE: string = 'stonejs@outgoing_response';
OUTGOING_RESPONSE Event name, fires on response to the incoming event.
OutgoingResponse#OUTGOING_RESPONSE