Skip to content

Commit

Permalink
Merge pull request nightscout#189 from nightscout/wip/rest/mbg
Browse files Browse the repository at this point in the history
Allow non-SGV entries to be posted to the rest API
  • Loading branch information
jasoncalabrese committed Oct 1, 2014
2 parents adc24df + a795bda commit def69f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/api/entries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function configure (app, wares, entries) {
var incoming = [ ];
// Potentially a single json encoded body.
// This can happen from either an url-encoded or json content-type.
if ('sgv' in req.body) {
if ('date' in req.body) {
// add it to the incoming list
incoming.push(req.body);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ function entries (name, storage) {

// return writable stream to lint each sgv record passing through it
function map ( ) {
return sgvdata.lint( );
function iter (item, next) {
if (item && item.type) {
return next(null, item);
}
return next(null, sgvdata.sync.json.echo(item));
}
return es.map(iter);
}

// writable stream that persists all records
Expand Down

0 comments on commit def69f9

Please sign in to comment.