Skip to content

Interface: ExpressResponder ​

How expressHTTPEntrypoint writes the results and the errors of the actions (its respond option). Implement it to give the responses another shape; JSONResponder is the default, jsonEnvelope wraps them in an envelope. The file results and the event streams are not written by the responder.

Methods ​

error() ​

error(response, error, request, origin?): void

Write an error: a failed action (validation, access control, its own exception), an error passed by an express middleware (next(error): an authenticator), or a request matching no route (RouteNotFoundException). Not called once the response headers are sent, nor after the client left.

Parameters ​

response ​

Response

The express response to write.

error ​

unknown

The thrown error.

request ​

Request

The express request being answered.

origin? ​

HTTPErrorOrigin

Where the error comes from: 'action' (the dispatch of an action failed) or 'request' (an express middleware, a route not found); see HTTPErrorOrigin.

Returns ​

void


success() ​

success(response, data, request): void

Write the result of an action. For a StatusResult, its status and headers are already set on the response and data is its payload.

Parameters ​

response ​

Response

The express response to write.

data ​

unknown

The action's result, undefined when it returned nothing.

request ​

Request

The express request being answered.

Returns ​

void

Released under the MIT License.