Class: Server

Server(config)

Implementation of the server operations.

If the server against which this client will be used has security enabled, then it should be configured with the username and password in the ServerClientConfig. In this case a login attempt is made before any API method to be executed. Upon successful login an User which holds the credentials and the authorization token in the context of the client is created. In all consecutive API calls the authorization token is sent as a http header.

By default ServerClientConfig is configured with keepAlive = true which means that upon authorization token expiration current logged-in user would be re-logged automatically before next API call. This configuration can be changed within the configuration.

Constructor

new Server(config)

Parameters:
Name Type Description
config ServerClientConfig

for the server client.

Author:
  • Mihail Radkov
  • Svilen Velikov
  • Boyan Tonchev
Source:

Methods

execute(requestBuilder) → {Promise.<(HttpResponse|Error)>}

Executes http request wrapped in provided request builder. If the server config provides username and password, then a logging attempt is made. Upon successful login the auth data is stored for later requests.

Parameters:
Name Type Description
requestBuilder HttpRequestBuilder
Source:
Returns:

a promise which resolves to response wrapper or rejects with error if thrown during execution.

Type
Promise.<(HttpResponse|Error)>

getLoggedUser() → {User}

Logged user getter.

Source:
Returns:

user

Type
User

initHttpClient()

Initializes the http client.

Source:

initLogger()

Initializes the logger.

Source:

setLoggedUser(user) → {Server}

User setter

Parameters:
Name Type Description
user User
Source:
Returns:
Type
Server