forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert to c1b2988 (Merge branch 'hotfix/0.3.5')"
This reverts commit 1cc9c61.
- Loading branch information
Jason Calabrese
committed
Aug 31, 2014
1 parent
1cc9c61
commit 0404905
Showing
35 changed files
with
882 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,8 @@ my.env | |
*.env | ||
static/bower_components/ | ||
.*.sw? | ||
.DS_Store | ||
|
||
.vagrant | ||
.vagrant | ||
/iisnode | ||
/web.config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "CGM Remote Monitor", | ||
"repository": "https://github.com/nightscout/cgm-remote-monitor", | ||
"env": { | ||
"MONGO_COLLECTION": { | ||
"description": "The mongo collection to connect to.", | ||
"value": "nightscout" | ||
} | ||
}, | ||
"addons": [ | ||
"mongolab" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
curl -H "Content-Type: application/json" -XPOST 'http://localhost:1337/api/v1/treatments/' -d '{ | ||
"enteredBy": "Dad", | ||
"eventType":"Site Change", | ||
"glucoseValue": 322, | ||
"glucoseType": "sensor", | ||
"carbsGiven": 0, | ||
"insulinGiven": 1.25, | ||
"notes": "Argh..." | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
var consts = require('../../constants'); | ||
|
||
function configure (app, wares, treatments) { | ||
var express = require('express'), | ||
api = express.Router( ); | ||
|
||
// invoke common middleware | ||
api.use(wares.sendJSONStatus); | ||
// text body types get handled as raw buffer stream | ||
api.use(wares.bodyParser.raw( )); | ||
// json body types get handled as parsed json | ||
api.use(wares.bodyParser.json( )); | ||
// also support url-encoded content-type | ||
api.use(wares.bodyParser.urlencoded({ extended: true })); | ||
|
||
// List settings available | ||
api.get('/treatments/', function(req, res) { | ||
treatments.list(function (err, profiles) { | ||
return res.json(profiles); | ||
}); | ||
}); | ||
|
||
function config_authed (app, api, wares, treatments) { | ||
|
||
api.post('/treatments/', /*TODO: auth disabled for quick UI testing... wares.verifyAuthorization, */ function(req, res) { | ||
var treatment = req.body; | ||
treatments.create(treatment, function (err, created) { | ||
if (err) | ||
res.sendJSONStatus(res, consts.HTTP_INTERNAL_ERROR, 'Mongo Error', err); | ||
else | ||
res.json(created); | ||
}); | ||
}); | ||
|
||
} | ||
|
||
if (app.enabled('api') || true /*TODO: auth disabled for quick UI testing...*/) { | ||
config_authed(app, api, wares, treatments); | ||
} | ||
|
||
return api; | ||
} | ||
|
||
module.exports = configure; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
function configure (collection, storage) { | ||
|
||
function create (obj, fn) { | ||
obj.created_at = (new Date( )).toISOString( ); | ||
api( ).insert(obj, function (err, doc) { | ||
fn(null, doc); | ||
}); | ||
} | ||
|
||
function list (fn) { | ||
return api( ).find({ }).sort({created_at: -1}).toArray(fn); | ||
} | ||
|
||
function api ( ) { | ||
return storage.pool.db.collection(collection); | ||
} | ||
|
||
api.list = list; | ||
api.create = create; | ||
return api; | ||
} | ||
module.exports = configure; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.