Skip to content

Commit

Permalink
Merge pull request #3 from nightscout/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
boysim authored Sep 24, 2017
2 parents 71d9852 + a7cb4c2 commit 08f3034
Show file tree
Hide file tree
Showing 41 changed files with 1,271 additions and 420 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
sudo: required
node_js:
- 6
- "8.5.0"
matrix:
fast_finish: true
services:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:8.1.4
FROM node:8.5.0

MAINTAINER Nightscout Contributors

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ all: test

coverage:
NODE_ENV=test ${MONGO_SETTINGS} \
${ISTANBUL} cover ${MOCHA} -- -R tap ${TESTS}
${ISTANBUL} cover ${MOCHA} -- --timeout 30000 -R tap ${TESTS}

report:
test -f ${ANALYZED} && \
Expand All @@ -41,11 +41,11 @@ report:
YOURPACKAGE_COVERAGE=1 ./node_modules/codacy-coverage/bin/codacy-coverage.js) || echo "NO COVERAGE"

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

travis:
NODE_ENV=test ${MONGO_SETTINGS} \
${ISTANBUL} cover ${MOCHA} --report lcovonly -- -R tap ${TESTS}
${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 50000 -R tap ${TESTS}

docker_release:
# Get the version from the package.json file
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ Clone this repo then install dependencies into the root of the project:
$ npm install
```

If deploying the software to Microsoft Azure, you must set *WEBSITE_NODE_DEFAULT_VERSION* in the app settings to *8.5.0* or the site deployment will fail. Other hosting environments do not require this setting.

# Usage

The data being uploaded from the server to the client is from a
Expand Down
48 changes: 43 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ var compression = require('compression');
var bodyParser = require('body-parser');
var prettyjson = require('prettyjson');

var path = require('path');
var fs = require('fs');

function create(env, ctx) {
var app = express();
var appInfo = env.name + ' ' + env.version;
app.set('title', appInfo);
app.enable('trust proxy'); // Allows req.secure test on heroku https connections.

app.set('view engine', 'ejs');
// this allows you to render .html files as templates in addition to .ejs
app.engine('html', require('ejs').renderFile);
app.engine('appcache', require('ejs').renderFile);
app.set("views", path.join(__dirname, "views/"));

app.locals.cachebuster = fs.readFileSync(process.cwd() + '/tmp/cacheBusterToken').toString().trim();

if (ctx.bootErrors && ctx.bootErrors.length > 0) {
app.get('*', require('./lib/booterror')(ctx));
return app;
Expand Down Expand Up @@ -48,11 +58,38 @@ function create(env, ctx) {
return compression.filter(req, res);
}
}));
// app.use(bodyParser({limit: 1048576 * 50, extended: true }));

//if (env.api_secret) {
// console.log("API_SECRET", env.api_secret);
//}
app.get("/", (req, res) => {
res.render("index.html", {
locals: app.locals
});
});

var appPages = {
"/clock-color.html":"clock-color.html",
"/admin":"adminindex.html",
"/profile":"profileindex.html",
"/food":"foodindex.html",
"/bgclock.html":"bgclock.html",
"/report":"reportindex.html",
"/translations":"translationsindex.html",
"/clock.html":"clock.html"
};

Object.keys(appPages).forEach(function(page) {
app.get(page, (req, res) => {
res.render(appPages[page], {
locals: app.locals
});
});
});

app.get("/nightscout.appcache", (req, res) => {
res.render("nightscout.appcache", {
locals: app.locals
});
});

app.use('/api/v1', bodyParser({
limit: 1048576 * 50
}), api);
Expand All @@ -69,6 +106,7 @@ function create(env, ctx) {
res.sendFile(__dirname + '/swagger.yaml');
});

/*
if (env.settings.isEnabled('dumps')) {
var heapdump = require('heapdump');
app.get('/api/v2/dumps/start', function(req, res) {
Expand All @@ -79,7 +117,7 @@ function create(env, ctx) {
res.send('wrote dump to ' + path);
});
}

*/

//app.get('/package.json', software);

Expand Down
45 changes: 26 additions & 19 deletions azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@
"colors",
"colorblindfriendly"
],
"defaultValue": "colors",
"defaultValue": "colors"
},
"time_format": {
"type": "string",
"allowedValues": [
"12",
"24"
],
"defaultValue": "24",
"defaultValue": "24"
},
"language": {
"type": "string",
Expand All @@ -99,59 +99,59 @@
"fi",
"ko"
],
"defaultValue": "en",
"defaultValue": "en"
},
"custom_title": {
"type": "string",
"defaultValue": "Nightscout",
"defaultValue": "Nightscout"
},
"alarm_high": {
"type": "string",
"allowedValues": [
"on",
"off"
],
"defaultValue": "off",
"defaultValue": "off"
},
"alarm_low": {
"type": "string",
"allowedValues": [
"on",
"off"
],
"defaultValue": "off",
"defaultValue": "off"
},
"alarm_timeago_urgent": {
"type": "string",
"allowedValues": [
"on",
"off"
],
"defaultValue": "off",
"defaultValue": "off"
},
"alarm_timeago_warn": {
"type": "string",
"allowedValues": [
"on",
"off"
],
"defaultValue": "off",
"defaultValue": "off"
},
"alarm_urgent_high": {
"type": "string",
"allowedValues": [
"on",
"off"
],
"defaultValue": "off",
"defaultValue": "off"
},
"alarm_urgent_low": {
"type": "string",
"allowedValues": [
"on",
"off"
],
"defaultValue": "off",
"defaultValue": "off"
},
"basal_render": {
"type": "string",
Expand All @@ -160,7 +160,7 @@
"default",
"icicle"
],
"defaultValue": "none",
"defaultValue": "none"
},
"scale_y": {
"type": "string",
Expand All @@ -169,23 +169,23 @@
"linear",
"log-dynamic"
],
"defaultValue": "log",
"defaultValue": "log"
},
"enable": {
"type": "string",
"defaultValue": "basal bwp cage careportal iob cob rawbg sage iage treatmentnotify boluscalc profile food",
"defaultValue": "basal bwp cage careportal iob cob rawbg sage iage treatmentnotify boluscalc profile food"
},
"night_mode": {
"type": "string",
"allowedValues": [
"on",
"off"
],
"defaultValue": "off",
"defaultValue": "off"
},
"show_plugins": {
"type": "string",
"defaultValue": "careportal",
"defaultValue": "careportal"
},
"show_rawbg": {
"type": "string",
Expand All @@ -194,27 +194,31 @@
"never",
"noise"
],
"defaultValue": "never",
"defaultValue": "never"
},
"devicestatus_advanced": {
"type": "string",
"allowedValues": [
"true",
"false"
],
"defaultValue": "false",
"defaultValue": "false"
},
"profile_multiple": {
"type": "string",
"allowedValues": [
"on",
"off"
],
"defaultValue": "off",
"defaultValue": "off"
},
"auth_default_roles": {
"type": "string",
"defaultValue": "readable devicestatus-upload",
"defaultValue": "readable devicestatus-upload"
},
"WEBSITE_NODE_DEFAULT_VERSION": {
"type": "string",
"defaultValue": "8.5.0"
}
},
"resources": [{
Expand Down Expand Up @@ -311,6 +315,9 @@
}, {
"name": "AUTH_DEFAULT_ROLES",
"value": "[parameters('auth_default_roles')]"
}, {
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "8.5.0"
}
]
}
Expand Down
Loading

0 comments on commit 08f3034

Please sign in to comment.