Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandra255 authored Aug 16, 2018
2 parents 8dee107 + ca3f518 commit 3cd040f
Show file tree
Hide file tree
Showing 118 changed files with 13,734 additions and 7,169 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ coverage/
npm-debug.log
*.heapsnapshot

/tmp
/tmp
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.9.1
8.11.x
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
language: node_js
sudo: required
dist: trusty
os: osx
node_js:
- "8.9.1"
- "8"
before_install:
- if [[ `npm --version` != "5.8.0" ]]; then npm install -g npm@latest; npm --version; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
# https://github.com/Homebrew/homebrew-core/issues/26358
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew unlink python; fi
# "brew install" can succeed but return 1 if it has "caveats".
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install mongodb || true; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew services start mongodb; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install docker || true; fi
matrix:
fast_finish: true
services:
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Nightscout tests/builds/analysis
TESTS=tests/*.js
MONGO_CONNECTION?=mongodb://localhost/test_db
MONGO_CONNECTION?=mongodb://localhost:27017/test_db
CUSTOMCONNSTR_mongo_settings_collection?=test_settings
CUSTOMCONNSTR_mongo_collection?=test_sgvs
MONGO_SETTINGS=MONGO_CONNECTION=${MONGO_CONNECTION} \
Expand Down Expand Up @@ -40,12 +40,18 @@ report:
(npm install codacy-coverage && cat ${ANALYZED} | \
YOURPACKAGE_COVERAGE=1 ./node_modules/codacy-coverage/bin/codacy-coverage.js) || echo "NO COVERAGE"

test_onebyone:
python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
$(foreach var,$(wildcard tests/*.js),${MONGO_SETTINGS} ${MOCHA} --timeout 30000 --exit --bail -R tap $(var);)

test:
${MONGO_SETTINGS} ${MOCHA} --timeout 30000 -R tap ${TESTS}
${MONGO_SETTINGS} ${MOCHA} --timeout 30000 --exit --bail -R tap ${TESTS}

travis:
NODE_ENV=test ${MONGO_SETTINGS} \
${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 5000 -R tap ${TESTS}
python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
# NODE_ENV=test ${MONGO_SETTINGS} \
# ${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 5000 -R tap ${TESTS}
$(foreach var,$(wildcard tests/*.js),${MONGO_SETTINGS} ${MOCHA} --timeout 30000 --exit --bail -R tap $(var);)

docker_release:
# Get the version from the package.json file
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: ./node_modules/.bin/forever --minUptime 100 -c node server.js
web: node server.js
64 changes: 51 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ low values, which can be cleared by any watcher of the data.
Community maintained fork of the
[original cgm-remote-monitor][original].

[![Coverage Status](https://coveralls.io/repos/github/nightscout/cgm-remote-monitor/badge.svg?branch=dev)](https://coveralls.io/github/nightscout/cgm-remote-monitor?branch=dev)
[![Coverage Status](https://coveralls.io/repos/github/nightscout/cgm-remote-monitor/badge.svg?branch=master)](https://coveralls.io/github/nightscout/cgm-remote-monitor?branch=master)

[build-img]: https://img.shields.io/travis/nightscout/cgm-remote-monitor.svg
[build-url]: https://travis-ci.org/nightscout/cgm-remote-monitor
[dependency-img]: https://img.shields.io/david/nightscout/cgm-remote-monitor.svg
[dependency-url]: https://david-dm.org/nightscout/cgm-remote-monitor
[coverage-img]: https://img.shields.io/coveralls/nightscout/cgm-remote-monitor/dev.svg
[coverage-url]: https://coveralls.io/github/nightscout/cgm-remote-monitor?branch=dev
[coverage-url]: https://coveralls.io/github/nightscout/cgm-remote-monitor?branch=master
[codacy-img]: https://www.codacy.com/project/badge/f79327216860472dad9afda07de39d3b
[codacy-url]: https://www.codacy.com/app/Nightscout/cgm-remote-monitor
[gitter-img]: https://img.shields.io/badge/Gitter-Join%20Chat%20%E2%86%92-1dce73.svg
Expand All @@ -58,6 +58,7 @@ Community maintained fork of the
- [Alarms](#alarms)
- [Core](#core)
- [Predefined values for your browser settings (optional)](#predefined-values-for-your-browser-settings-optional)
- [Views](#views)
- [Plugins](#plugins)
- [Default Plugins](#default-plugins)
- [`delta` (BG Delta)](#delta-bg-delta)
Expand Down Expand Up @@ -87,6 +88,7 @@ Community maintained fork of the
- [`pump` (Pump Monitoring)](#pump-pump-monitoring)
- [`openaps` (OpenAPS)](#openaps-openaps)
- [`loop` (Loop)](#loop-loop)
- [`xdrip-js` (xDrip-js)](#xdrip-js-xdrip-js)
- [`alexa` (Amazon Alexa)](#alexa-amazon-alexa)
- [`cors` (CORS)](#cors-cors)
- [Extended Settings](#extended-settings)
Expand All @@ -95,25 +97,44 @@ Community maintained fork of the
- [Treatment Profile](#treatment-profile)
- [Setting environment variables](#setting-environment-variables)
- [Vagrant install](#vagrant-install)
- [Installation on Windows](#installation-on-windows)
- [More questions?](#more-questions)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# Install

Requirements:
Supported configurations:

- [Node.js](http://nodejs.org/) 8.9.0 LTS (use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)
If you plan to use Nightscout, we recommend using [Heroku](http://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/nightscout-setup.html#nightscout-setup-with-heroku), as Nightscout can reach the usage limits of the free Azure plan and cause it to shut down for hours or days. If you end up needing a paid tier, the $7/mo Heroku plan is also much cheaper than the first paid tier of Azure. Currently, the only added benefit to choosing the $7/mo Heroku plan vs the free Heroku plan is a section showing site use metrics for performance (such as response time). This has limited benefit to the average Nightscout user. In short, Heroku is the free and best option for Nightscout hosting.

Clone this repo then install dependencies into the root of the project:
- [Nightscout Setup with Heroku] (http://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/nightscout-setup.html#nightscout-setup-with-heroku) (recommended)
- [Nightscout Setup with Microsoft Azure] (http://www.nightscout.info/wiki/faqs-2/azure-2) (not recommended, please
[switch from Azure to Heroku](http://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/nightscout-setup.html#switching-from-azure-to-heroku) )
- Linux based install (Debian, Ubuntu, Raspbian) install with own Node.JS and MongoDB install (see software requirements below)
- Windows based install with own Node.JS and MongoDB install (see software requirements below)

Software requirements:

- [Node.js](http://nodejs.org/) Latest Node 8 LTS (Node 8.11.3 or later). Use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or use `setup.sh`)
- [MongoDB](https://www.mongodb.com/download-center?jmp=nav#community) 3.x or later. MongoDB 2.4 is only supported for Raspberry Pi.

As a non-root user clone this repo then install dependencies into the root of the project:

```bash
$ npm install
```

If deploying the software to Microsoft Azure, you must set *WEBSITE_NODE_DEFAULT_VERSION* in the app settings to *8.9.0* **before** you deploy the latest Nightscout or the site deployment will likely fail. Other hosting environments do not require this setting.
Installation notes for Microsoft Azure, Windows and Node 10:

- If deploying the software to Microsoft Azure, you must set ** in the app settings for *WEBSITE_NODE_DEFAULT_VERSION* and *SCM_COMMAND_IDLE_TIMEOUT* **before** you deploy the latest Nightscout or the site deployment will likely fail. Other hosting environments do not require this setting. Please use:
```
WEBSITE_NODE_DEFAULT_VERSION=8.11.1
SCM_COMMAND_IDLE_TIMEOUT=300
```
- See [install MongoDB, Node.js, and Nightscouton a single Windows system](https://github.com/jaylagorio/Nightscout-on-Windows-Server). if you want to host your Nightscout outside of the cloud. Although the instructions are intended for Windows Server the procedure is compatible with client versions of Windows such as Windows 7 and Windows 10.
- If you deploy to Windows and want to develop or test you need to install [Cygwin] (https://www.cygwin.com/) (use [setup-x86_64.exe] (https://www.cygwin.com/setup-x86_64.exe) and make sure to install `build-essential` package. Test your configuration by executing `make` and check if all tests are ok.
- There may be some issues with Node 10.6.0 or later with Nightscout. Node 10 support will be in the 0.11 release. Please don't use Nightscout with (Node 9 or) Node 10 at this moment.

# Usage

Expand Down Expand Up @@ -214,6 +235,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `MONGO_DEVICESTATUS_COLLECTION`(`devicestatus`) - The collection used to store device status information such as uploader battery
* `MONGO_PROFILE_COLLECTION`(`profile`) - The collection used to store your profiles
* `MONGO_FOOD_COLLECTION`(`food`) - The collection used to store your food database
* `MONGO_ACTIVITY_COLLECTION`(`activity`) - The collection used to store activity data
* `PORT` (`1337`) - The port that the node.js application will listen on.
* `HOSTNAME` - The hostname that the node.js application will listen on, null by default for any hostname for IPv6 you may need to use `::`.
* `SSL_KEY` - Path to your ssl key file, so that ssl(https) can be enabled directly in node.js
Expand All @@ -228,20 +250,28 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `NIGHT_MODE` (`off`) - possible values `on` or `off`
* `SHOW_RAWBG` (`never`) - possible values `always`, `never` or `noise`
* `CUSTOM_TITLE` (`Nightscout`) - Usually name of T1
* `THEME` (`default`) - possible values `default` or `colors`
* `THEME` (`default`) - possible values `default`, `colors`, or `colorblindfriendly`
* `ALARM_TIMEAGO_WARN` (`on`) - possible values `on` or `off`
* `ALARM_TIMEAGO_WARN_MINS` (`15`) - minutes since the last reading to trigger a warning
* `ALARM_TIMEAGO_URGENT` (`on`) - possible values `on` or `off`
* `ALARM_TIMEAGO_URGENT_MINS` (`30`) - minutes since the last reading to trigger a urgent alarm
* `SHOW_PLUGINS` - enabled plugins that should have their visualizations shown, defaults to all enabled
* `SHOW_FORECAST` (`ar2`) - plugin forecasts that should be shown by default, supports space delimited values such as `"ar2 openaps"`
* `LANGUAGE` (`en`) - language of Nightscout. If not available english is used
* Currently supported language codes are: bg (Български), cs (Čeština), de (Deutsch), dk (Dansk), el (Ελληνικά), en (English), es (Español), fi (Suomi), fr (Français), he (עברית), hr (Hrvatski), it (Italiano), ko (한국어), nb (Norsk (Bokmål)), nl (Nederlands), pl (Polski), pt (Português (Brasil)), ro (Română), ru (Русский), sk (Slovenčina), sv (Svenska), zh_cn (中文(简体)), zh_tw (中文(繁體))
* `SCALE_Y` (`log`) - The type of scaling used for the Y axis of the charts system wide.
* The default `log` (logarithmic) option will let you see more detail towards the lower range, while still showing the full CGM range.
* The `linear` option has equidistant tick marks, the range used is dynamic so that space at the top of chart isn't wasted.
* The `log-dynamic` is similar to the default `log` options, but uses the same dynamic range and the `linear` scale.
* `EDIT_MODE` (`on`) - possible values `on` or `off`. Enable or disable icon allowing enter treatments edit mode

### Views

There are a few alternate web views available that display a simplified BG stream. Append any of these to your Nightscout URL:
* `/clock.html` - Shows current BG. Grey text on a black background.
* `/bgclock.html` - Shows current BG, trend arrow, and time of day. Grey text on a black background.
* `/clock-color.html` - Shows current BG and trend arrow. White text on a background that changes color to indicate current BG threshold (green = in range; blue = below range; yellow = above range; red = urgent below/above).

### Plugins

Plugins are used extend the way information is displayed, how notifications are sent, alarms are triggered, and more.
Expand Down Expand Up @@ -377,7 +407,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
Generic Pump Monitoring for OpenAPS, MiniMed Connect, RileyLink, t:slim, with more on the way
* Requires `DEVICESTATUS_ADVANCED="true"` to be set
* `PUMP_ENABLE_ALERTS` (`false`) - Set to `true` to enable notifications for Pump battery and reservoir.
* `PUMP_WARNONSUSPEND` (`false`) - Set to `true` to get an alarm when the pump is suspended.
* `PUMP_WARN_ON_SUSPEND` (`false`) - Set to `true` to get an alarm when the pump is suspended.
* `PUMP_FIELDS` (`reservoir battery`) - The fields to display by default. Any of the following fields: `reservoir`, `battery`, `clock`, `status`, and `device`
* `PUMP_RETRO_FIELDS` (`reservoir battery clock`) - The fields to display in retro mode. Any of the above fields.
* `PUMP_WARN_CLOCK` (`30`) - The number of minutes ago that needs to be exceed before an alert is triggered.
Expand Down Expand Up @@ -408,9 +438,19 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `LOOP_URGENT` (`60`) - The number of minutes since the last loop that needs to be exceeded before an urgent alarm is triggered
* Add `loop` to `SHOW_FORECAST` to show forecasted BG.

##### `xdrip-js` (xDrip-js)
Integrated xDrip-js monitoring, uses these extended settings:
* Requires `DEVICESTATUS_ADVANCED="true"` to be set
* `XDRIP-JS_ENABLE_ALERTS` (`false`) - Set to `true` to enable notifications when CGM state is not OK or battery voltages fall below threshold.
* `XDRIP-JS_STATE_NOTIFY_INTRVL` (`0.5`) - Set to number of hours between CGM state notifications
* `XDRIP-JS_WARN_BAT_V` (`300`) - The voltage of either transmitter battery, a warning will be triggered when dropping below this threshold.

##### `alexa` (Amazon Alexa)
Integration with Amazon Alexa, [detailed setup instructions](lib/plugins/alexa-plugin.md)

##### `speech` (Speech)
Speech synthesis plugin. When enabled, speaks out the blood glucose values, IOB and alarms. Note you have to set the LANGUAGE setting on the server to get all translated alarms.

##### `cors` (CORS)
Enabled [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) so other websites can make request to your Nightscout site, uses these extended settings:
* `CORS_ALLOW_ORIGIN` (`*`) - The list of sites that are allow to make requests
Expand All @@ -419,6 +459,8 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
Some plugins support additional configuration using extra environment variables. These are prefixed with the name of the plugin and a `_`. For example setting `MYPLUGIN_EXAMPLE_VALUE=1234` would make `extendedSettings.exampleValue` available to the `MYPLUGIN` plugin.

Plugins only have access to their own extended settings, all the extended settings of client plugins will be sent to the browser.

* `DEVICESTATUS_ADVANCED` (`true`) - Defaults to true. Users who only have a single device uploading data to Nightscout can set this to false to reduce the data use of the site.

#### Pushover
In addition to the normal web based alarms, there is also support for [Pushover](https://pushover.net/) based alarms and notifications.
Expand Down Expand Up @@ -518,10 +560,6 @@ The setup script will install OS packages then run `npm install`.
The Vagrant VM serves to your host machine only on 192.168.33.10, you can access
the web interface on [http://192.168.33.10:1337](http://192.168.33.10:1337)

## Installation on Windows

If you have access to local computing resources and want to maintain more control over your data, you can host Nightscout and its database outside of the cloud. Windows Server supports MongoDB, Node.js, and Nightscout [installed on a single system](https://github.com/jaylagorio/Nightscout-on-Windows-Server). Although the instructions are intended for Windows Server the procedure is compatible with client versions of Windows such as Windows 7 and Windows 10.

More questions?
---------------

Expand Down
19 changes: 13 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _ = require('lodash');
var _get = require('lodash/get');
var express = require('express');
var compression = require('compression');
var bodyParser = require('body-parser');
Expand All @@ -24,12 +24,12 @@ function create(env, ctx) {
app.locals.cachebuster = fs.readFileSync(process.cwd() + '/tmp/cacheBusterToken').toString().trim();

if (ctx.bootErrors && ctx.bootErrors.length > 0) {
app.get('*', require('./lib/booterror')(ctx));
app.get('*', require('./lib/server/booterror')(ctx));
return app;
}

if (env.settings.isEnabled('cors')) {
var allowOrigin = _.get(env, 'extendedSettings.cors.allowOrigin') || '*';
var allowOrigin = _get(env, 'extendedSettings.cors.allowOrigin') || '*';
console.info('Enabled CORS, allow-origin:', allowOrigin);
app.use(function allowCrossDomain(req, res, next) {
res.header('Access-Control-Allow-Origin', allowOrigin);
Expand Down Expand Up @@ -101,9 +101,9 @@ function create(env, ctx) {
// pebble data
app.get('/pebble', ctx.pebble);

// expose swagger.yaml
app.get('/swagger.yaml', function(req, res) {
res.sendFile(__dirname + '/swagger.yaml');
// expose swagger.json
app.get('/swagger.json', function(req, res) {
res.sendFile(__dirname + '/swagger.json');
});

/*
Expand Down Expand Up @@ -141,6 +141,13 @@ function create(env, ctx) {
// serve the static content
app.use(staticFiles);

var swaggerFiles = express.static(env.swagger_files, {
maxAge: maxAge
});

// serve the static content
app.use('/swagger-ui-dist', swaggerFiles);

var tmpFiles = express.static('tmp', {
maxAge: maxAge
});
Expand Down
Loading

0 comments on commit 3cd040f

Please sign in to comment.