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
-c, --config <file> Configuration file in JSON format
--debug Enable debug mode

Common Options

Option Description
-h, --help Show the usage message

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 mode is enabled.
Resgate running in debug mode logs all client and NATS traffic to output including any method parameters.
Example: false