RestCommander

RestCommander

A Commander client that controls a traffic light via a remote REST API. Communicates with a server started by the serve command.

Constructor

new RestCommander(optionsopt)

Description:
  • Creates a new RestCommander instance.

Source:
Parameters:
Name Type Attributes Description
options object <optional>

Options.

Properties
Name Type Attributes Default Description
host string <optional>
'http://localhost:9000'

The base URL of the remote server (e.g. http://localhost:9000).

logger object <optional>
console

A Console-like object for logging.

Methods

(async) cancel()

Description:
  • Cancels any currently executing command on the remote server.

Source:

close()

Description:
  • Closes this instance. No-op for REST client.

Source:

(async) fetchCommandNames() → {Promise.<Array.<string>>}

Description:
  • Fetches all available command names from the remote server.

Source:
Returns:

Array of command names.

Type
Promise.<Array.<string>>

(async) help(commandName)

Description:
  • Logs the help info for the given command name from the remote server.

Source:
Parameters:
Name Type Description
commandName string

Name of the command.

(async) logInfo()

Description:
  • Logs information about known traffic lights from the remote server.

Source:

(async) run(command, resetopt)

Description:
  • Executes a command on the remote server (fire-and-forget).

Source:
Parameters:
Name Type Attributes Default Description
command string

Command to execute.

reset boolean <optional>
false

Whether to reset the traffic light first.