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
pazaan authored Dec 26, 2016
2 parents 45e8562 + 192c4d0 commit 9883b93
Show file tree
Hide file tree
Showing 192 changed files with 13,132 additions and 2,966 deletions.
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Some simple rules, that will make it easier to maintain our codebase:
* A space before function parameters, such as: `function boom (name, callback) { }`, this makes searching for calls easier
* Name your callback functions, such as `boom('the name', function afterBoom ( result ) { }`
* Don't include author names in the header of your files, if you need to give credit to someone else do it in the commit comment.
* Use single quotes.
* Use the comma first style, for example:

```javascript
Expand Down Expand Up @@ -95,10 +96,8 @@ appropriate.
## Co-ordination
There is a google groups nightscout-core developers list where lots of
people discuss Nightscout. Most cgm-remote-monitor hackers use
github's ticketing system, along with Facebook cgm-in-the-cloud, and
gitter system.
Most cgm-remote-monitor hackers use github's ticketing system, along with Facebook cgm-in-the-cloud, and
gitter.

We use git-flow, with `master` as our production, stable branch, and
`dev` is used to queue up for upcoming releases. Everything else is
Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ report:
(npm install coveralls && cat ${ANALYZED} | \
./node_modules/.bin/coveralls) || echo "NO COVERAGE"
test -f ${ANALYZED} && \
(npm install codecov.io && cat ${ANALYZED} | \
./node_modules/codecov.io/bin/codecov.io.js) || echo "NO COVERAGE"
test -f ${ANALYZED} && \
(npm install codacy-coverage && cat ${ANALYZED} | \
YOURPACKAGE_COVERAGE=1 ./node_modules/codacy-coverage/bin/codacy-coverage.js) || echo "NO COVERAGE"

Expand Down
90 changes: 59 additions & 31 deletions README.md

Large diffs are not rendered by default.

34 changes: 28 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
'use strict';

var _ = require('lodash');
var express = require('express');
var compression = require('compression');
var bodyParser = require('body-parser');

function create (env, ctx) {
///////////////////////////////////////////////////
// api and json object variables
///////////////////////////////////////////////////
var api = require('./lib/api/')(env, ctx);

var app = express();
var appInfo = env.name + ' ' + env.version;
app.set('title', appInfo);
Expand All @@ -20,6 +16,29 @@ function create (env, ctx) {
return app;
}

if (env.settings.isEnabled('cors')) {
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);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');

// intercept OPTIONS method
if ('OPTIONS' === req.method) {
res.send(200);
} else {
next();
}
});
}

///////////////////////////////////////////////////
// api and json object variables
///////////////////////////////////////////////////
var api = require('./lib/api/')(env, ctx);
var ddata = require('./lib/data/endpoints')(env, ctx);

app.use(compression({filter: function shouldCompress(req, res) {
//TODO: return false here if we find a condition where we don't want to compress
// fallback to standard filter function
Expand All @@ -32,6 +51,9 @@ function create (env, ctx) {
//}
app.use('/api/v1', bodyParser({limit: 1048576 * 50 }), api);

app.use('/api/v2/properties', ctx.properties);
app.use('/api/v2/authorization', ctx.authorization.endpoints);
app.use('/api/v2/ddata', ddata);

// pebble data
app.get('/pebble', ctx.pebble);
Expand All @@ -50,7 +72,7 @@ function create (env, ctx) {
// serve the static content
app.use(staticFiles);

var bundle = require('./bundle')();
var bundle = require('./bundle')(env);
app.use(bundle);

// Handle errors with express's errorhandler, to display more readable error messages.
Expand Down
Loading

0 comments on commit 9883b93

Please sign in to comment.