@@ -54,65 +54,25 @@ Run a WoT Servient in the current directory.
5454program . addHelpText (
5555 "after" ,
5656 `
57- wot-servient.conf.json syntax:
57+ Configuration
58+
59+ Settings can be applied through three methods, in order of precedence (highest to lowest):
60+
61+ 1. Command-Line Parameters (-p path.to.set=value)
62+ 2. Environment Variables (NODE_WOT_PATH_TO_SET=value) (supports .env files too)
63+ 3. Configuration File
64+
65+ For the complete list of available configuration fields and their data types, run:
66+
67+ wot-servient schema
68+
69+ In your configuration files you can the following to enable IDE config validation:
70+
5871{
59- "servient": {
60- "clientOnly": CLIENTONLY,
61- "staticAddress": STATIC,
62- "scriptAction": RUNSCRIPT
63- },
64- "http": {
65- "port": HPORT,
66- "address": HADDRESS,
67- "baseUri": HBASEURI,
68- "urlRewrite": HURLREWRITE,
69- "proxy": PROXY,
70- "allowSelfSigned": ALLOW
71- },
72- "mqtt" : {
73- "broker": BROKER-URL,
74- "username": BROKER-USERNAME,
75- "password": BROKER-PASSWORD,
76- "clientId": BROKER-UNIQUEID,
77- "protocolVersion": MQTT_VERSION
78- },
79- "credentials": {
80- THING_ID1: {
81- "token": TOKEN
82- },
83- THING_ID2: {
84- "username": USERNAME,
85- "password": PASSWORD
86- }
87- }
72+ "$schema": "./node_modules/@node-wot/cli/dist/wot-servient-schema.conf.json"
73+ ...
8874}
89-
90- wot-servient.conf.json fields:
91- CLIENTONLY : boolean setting if no servers shall be started (default=false)
92- STATIC : string with hostname or IP literal for static address config
93- RUNSCRIPT : boolean to activate the 'runScript' Action (default=false)
94- HPORT : integer defining the HTTP listening port
95- HADDRESS : string defining HTTP address
96- HBASEURI : string defining HTTP base URI
97- HURLREWRITE : map (from URL -> to URL) defining HTTP URL rewrites
98- PROXY : object with "href" field for the proxy URI,
99- "scheme" field for either "basic" or "bearer", and
100- corresponding credential fields as defined below
101- ALLOW : boolean whether self-signed certificates should be allowed
102- BROKER-URL : URL to an MQTT broker that publisher and subscribers will use
103- BROKER-UNIQUEID : unique id set by MQTT client while connecting to the broker
104- MQTT_VERSION : number indicating the MQTT protocol version to be used (3, 4, or 5)
105- THING_IDx : string with TD "id" for which credentials should be configured
106- TOKEN : string for providing a Bearer token
107- USERNAME : string for providing a Basic Auth username
108- PASSWORD : string for providing a Basic Auth password
109- ---------------------------------------------------------------------------
110-
111- Environment variables must be provided in a .env file in the current working directory.
112-
113- Example:
114- VAR1=Value1
115- VAR2=Value2`
75+ `
11676) ;
11777
11878// CLI options declaration
@@ -127,8 +87,10 @@ program
12787 "choose the desired log level. WARNING: if DEBUG env variable is specified this option gets overridden."
12888 ) . choices ( [ "debug" , "info" , "warn" , "error" ] )
12989 )
130- . option ( "-f, --config-file <file>" , "load configuration from specified file" , ( value , previous ) =>
131- parseConfigFile ( value , previous )
90+ . option (
91+ "-f, --config-file <file>" ,
92+ "load configuration from specified file (default: $(pwd)/wot-servient.conf.json" ,
93+ ( value , previous ) => parseConfigFile ( value , previous )
13294 )
13395 . option (
13496 "-p, --config-params <param...>" ,
@@ -144,6 +106,13 @@ program.addArgument(
144106 )
145107) ;
146108
109+ program
110+ . command ( "schema" )
111+ . description ( "prints the json schema for the configuration file" )
112+ . action ( ( ) => {
113+ console . log ( JSON . stringify ( ConfigSchema , null , 2 ) ) ;
114+ } ) ;
115+
147116program . action ( async function ( _ , options , cmd ) {
148117 // Allow user to personalized the env
149118 if ( process . env . DEBUG == null ) {
0 commit comments