-
Notifications
You must be signed in to change notification settings - Fork 7
/
tidepool.js
61 lines (53 loc) · 1.68 KB
/
tidepool.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// == BSD2 LICENSE ==
// Copyright (c) 2014, Tidepool Project
//
// This program is free software; you can redistribute it and/or modify it under
// the terms of the associated License, which is identical to the BSD 2-Clause
// License as published by the Open Source Initiative at opensource.org.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the License for more details.
//
// You should have received a copy of the License along with this program; if
// not, you can obtain one from Tidepool Project at tidepool.org.
// == BSD2 LICENSE ==
'use strict';
var superagent = require('superagent');
var _ = require('lodash');
var makeClient = require('./index');
// Public-facing API, used by app developers
module.exports = function(options) {
options = options || {};
if (options.host == null) {
options.host = 'https://api.tidepool.org';
}
if (options.uploadApi == null) {
options.uploadApi = 'https://uploads.tidepool.org';
}
if (options.dataHost == null) {
options.dataHost = 'https://data.tidepool.org';
}
var log = options.log;
if (log == null) {
log = {
warn: function(){},
info: function(){},
debug: function(){}
};
}
var localStore = options.localStore;
if (localStore == null) {
localStore = {
getItem: function() {},
setItem: function() {},
removeItem: function() {}
};
}
return makeClient(_.omit(options, 'log', 'superagent', 'localStore'), {
log: log,
superagent: superagent,
localStore: localStore
});
};
module.exports.client = makeClient;