Skip to content

Commit

Permalink
initial ideas for a system defaults env var
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncalabrese committed Feb 26, 2015
1 parent d616b6c commit 120d46d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Expand Down
11 changes: 9 additions & 2 deletions env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;
Expand All @@ -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');

/////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions lib/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/api/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 120d46d

Please sign in to comment.