diff --git a/README.md b/README.md index 69b1e5240a7..8350649134b 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Use the [autoconfigure tool][autoconfigure] to sync an uploader to your config. #### Core - * `DISPLAY_UNITS` (`mg/dl`) - Choices: `mg/dl` and `mmol`. Setting to `mmol` puts the entire server into `mmol` mode by default, no further settings needed. + * `DEFAULTS` - `Key=Value` pairs that can be used to set system options. Currently supported: `"display-units=mg/dl|mmol time-format=12|24"` * `MONGO_COLLECTION` (`entries`) - The collection used to store SGV, MBG, and CAL records from your CGM device * `MONGO_TREATMENTS_COLLECTION` (`treatments`) -The collection used to store treatments entered in the Care Portal, see the `ENABLE` env var above * `MONGO_DEVICESTATUS_COLLECTION`(`devicestatus`) - The collection used to store device status information such as uploader battery @@ -114,6 +114,10 @@ Use the [autoconfigure tool][autoconfigure] to sync an uploader to your config. * `SSL_CERT` - Path to your ssl cert file, so that ssl(https) can be enabled directly in node.js * `SSL_CA` - Path to your ssl ca file, so that ssl(https) can be enabled directly in node.js +#### Deprecated + * `DISPLAY_UNITS` (`mg/dl`) - **[Use `DEFAULTS` instead.]** Choices: `mg/dl` and `mmol`. Setting to `mmol` puts the entire server into `mmol` mode by default, no further settings needed. + + ## Setting environment variables Easy to emulate on the commandline: diff --git a/env.js b/env.js index 0218d69632a..9cd0c0132d8 100644 --- a/env.js +++ b/env.js @@ -35,7 +35,6 @@ function config ( ) { env.version = software.version; env.name = software.name; - env.DISPLAY_UNITS = readENV('DISPLAY_UNITS', 'mg/dl'); env.PORT = readENV('PORT', 1337); env.mongo = readENV('MONGO_CONNECTION') || readENV('MONGO') || readENV('MONGOLAB_URI'); env.mongo_collection = readENV('MONGO_COLLECTION', 'entries'); @@ -44,7 +43,12 @@ function config ( ) { env.devicestatus_collection = readENV('MONGO_DEVICESTATUS_COLLECTION', 'devicestatus'); env.enable = readENV('ENABLE'); - env.SSL_KEY = readENV('SSL_KEY'); + + //TODO: parse defaults here, expect format `key1=value1 key2=value2` split on space, ignore commas + // results should be an object something like env.defaults = {"DISPLAY_UNITS": "mg/dl", "TIME_FORMAT": "12"}; + env.defaults = readENV('DEFAULTS'); + + env.SSL_KEY = readENV('SSL_KEY'); env.SSL_CERT = readENV('SSL_CERT'); env.SSL_CA = readENV('SSL_CA'); env.ssl = false; @@ -58,6 +62,9 @@ function config ( ) { } } + //TODO: check if set by `ENABLE`, if not check old env + env.DISPLAY_UNITS = readENV('DISPLAY_UNITS', 'mg/dl'); + var shasum = crypto.createHash('sha1'); ///////////////////////////////////////////////////////////////// diff --git a/lib/api/index.js b/lib/api/index.js index 13ccb4c57ce..d3695e03d09 100644 --- a/lib/api/index.js +++ b/lib/api/index.js @@ -32,6 +32,8 @@ function create (env, entries, settings, treatments, devicestatus) { }); } + app.defaults = env.defaults || ''; + app.set('title', [app.get('name'), 'API', app.get('version')].join(' ')); app.thresholds = env.thresholds; diff --git a/lib/api/status.js b/lib/api/status.js index d1c038ad2d5..ec0b4452a3a 100644 --- a/lib/api/status.js +++ b/lib/api/status.js @@ -14,6 +14,7 @@ function configure (app, wares) { , apiEnabled: app.enabled('api') , careportalEnabled: app.enabled('api') && app.enabled('careportal') , enabledOptions: app.enabledOptions + , defaults: app.defaults , units: app.get('units') , head: wares.get_head( ) , version: app.get('version')