Class: NodeAPI

NodeAPI

new NodeAPI(port, store) → {NodeAPI|Error}

Create an instance of the Node API.
Parameters:
Name Type Description
port number Port number of which to run the API. Expected to be an integer.
store NodeStore Store containing access to the details of the node.
Source:
Returns:
Creates a NodeAPI or returns an error.
Type
NodeAPI | Error

Methods

getPort() → {Number}

Returns the port that this Node API is configured to use.
Source:
Returns:
Port for this node API.
Type
Number

getStore() → {NodeStore}

Returns the store used to produce results.
Source:
Returns:
Store backing this Node API.
Type
NodeStore

init() → {NodeAPI}

Initialise the Node APIs routing table.
Source:
Returns:
Returns this object with the routing table initialised and ready to NodeAPI#start.
Type
NodeAPI

setStore(replacementStore) → {Error|null}

Replace the store set for this API.
Parameters:
Name Type Description
replacementStore NodeAPI Store to use to replace the current one.
Source:
Returns:
Error if a problem, otherwise null for success.
Type
Error | null

start(cbopt) → {NodeAPI}

Start the Node API server. If the port is already in use, the server will be closed.
Parameters:
Name Type Attributes Description
cb NodeAPI~trackStatus <optional>
Optional callback to track API starting or errors.
Source:
Returns:
This object with an asynchronous request to start the server.
Type
NodeAPI

stop(cbopt) → {NodeAPI}

Stop the server running the Node API.
Parameters:
Name Type Attributes Description
cb NodeAPI~trackStatus <optional>
Optional callback that tracks when the server is stopped.
Source:
Returns:
This object with an asynchronous request to stop the server.
Type
NodeAPI