Resgate configuration and command-line usage

Command-line Usage

Resgate can be started with optional flags. Command line options will override configuration file settings.

resgate [options]

Server options

Option Description Default value
-n, --nats <url> NATS Server URL nats://
-i, --addr <host> Bind to HOST address
-p, --port <port> HTTP port for client connections 8080
-w, --wspath <path> WebSocket path for clients /
-a, --apipath <path> Web resource path for clients /api/
-r, --reqtimeout <seconds> Timeout duration for NATS requests 5
-u, --headauth <method> Resource method for header authentication
--tls Enable TLS for HTTP false
--tlscert <file> HTTP server certificate file
--tlskey <file> Private key for HTTP server certificate
--apiencoding <type> Encoding for web resources: json, jsonflat json
--creds <file> NATS User Credentials file
-c, --config <file> Configuration file in JSON format

Logging options

Option Description
-D, --debug Enable debugging output
-V, --trace Enable trace logging
-DV Debug and trace

Common options

Option Description
-h, --help Show usage message
-v, --version Show version

Configuration file

The configuration file is a simple JSON file.

A new configuration file with default settings can be created by using the --config option, specifying a file path that does not yet exist.

resgate --config myconfig.json

Below is a list of available settings:

natsUrl (string)
NATS Server URL. Must be a valid URI using nats:// as schema.
Example: "nats://"

requestTimeout (number)
Timeout in milliseconds for NATS requests.
Example: 3000

addr (string)
Bind to HOST IPv4 or IPv6 address.
Empty string ("") means all IPv4 and IPv6 addresses.
Invalid or missing IP address defaults to
Example: ""

port (number)
Port for the http server to listen on.
If the port value is missing or 0, standard http(s) port is used.
Example: 8080

wsPath (string)
Path for accessing the RES API websocket.
Example: "/ws"

apiPath (string)
Path prefix for accessing web resources.
To access a resource, example.model, from a Resgate without TLS listening at (default), the URL would be<apiPath>/example/model.
Example: "/api/"

apiEncoding (string)
Encoding for web resources.
Available encodings are:

  • json - JSON encoding with resource reference meta data
  • jsonflat - JSON encoding without resource reference meta data

Example: "json"

headerAuth (string)
Header authentication resource method for web resources.
Prior to validating access permissions for the resource, this resource method will be called, allowing an auth service to set a token using information such as the request headers.
Missing value or null will disable header authentication.
Example: "authService.headerLogin"

tls (boolean)
Flag telling if tls encryption is enabled.
Example: false

tlsCert (string)
Certificate file path for tls encryption.
Example: "/etc/ssl/certs/ssl-cert.pem"

tlsKey (string)
Key file path for tls encryption.
Example: "/etc/ssl/private/ssl-cert.key"

wsCompression (boolean)
Flag telling if WebSocket per message compression (RFC 7692) is enabled.
Example: false

debug (boolean)
Flag telling if debug output is enabled.
Resgate will output additional output that may be relevant to debug issues.
Example: false

trace (boolean)
Flag telling if trace logging is enabled.
Logs all client connects and disconnects together with raw client and NATS traffic, including message payload.
Example: false