Module: x2node-ws

Central module for building RESTful web services.

Requires

Classes

BasicAuthenticator
BearerAuthenticator
CachingActorsRegistry

Methods


<static> createApplication( [options])

Create application the represents the web service. The application must be configured before it's run and starts responding to the incoming requests.
Parameters:
Name Type Argument Description
options module:x2node-ws~ApplicationOptions <optional>
Application configuration options.
Returns:
The application.
Type
module:x2node-ws~Application

<static> createResponse(statusCode)

Create new empty response object.
Parameters:
Name Type Description
statusCode number HTTP response status code.
Returns:
Service response object.
Type
module:x2node-ws~ServiceResponse

<static> isResponse(obj)

Tell if the provided object is response object (that is an instance of ServiceResponse).
Parameters:
Name Type Description
obj * Object to test.
Returns:
true if response object.
Type
boolean

<static> TEXT_DESERIALIZER()

Simple binary to string deserializer function implementation for use with handler requestEntityParsers property.

Type Definitions


ApplicationOptions

Application configuration options.
Type:
  • Object
Properties:
Name Type Description
apiVersion string Version of the API exposed by the application. If not specified, NODE_ENV environment variable is examined. If its value is "development", the version is set to the current timestamp so that it changes each time the application is restarted. Otherwise, the version is read from the main module's package.json.
connectionIdleTimeout number Timeout in milliseconds for inactivity on the HTTP connection when activity is expected from the client. If the timeout occurs before the server starts sending the response, a 408 (Request Timeout) response is sent and the connection is closed. If timeout happens after the response headers have been sent, the connection is quitely closed. The default is 30 seconds.
maxRequestHeadersCount number Maximum allowed number of incoming HTTP request headers. The default is 50.
maxRequestSize number Maximum allowed size of request payload in bytes. The default is 2048.
allowedOrigins string | Array.<string> List (comma-separated string or an array) of allowed CORS origins. If not provided, the default is to allow any origin.
corsPreflightMaxAge number Maximum age in seconds for caching CORS preflight responses on the client. The default is 20 days.