Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
2189bea
* Bump version to 14.2.3
sulkaharo Feb 23, 2021
562364a
Add `docker-compose` support (#6903)
pazaan Mar 11, 2021
ccfa07e
New Crowdin updates (#6917)
sulkaharo Apr 29, 2021
8d75200
Fixing a bad URL that sends the user to docs if they have an open sit…
shanselman Apr 29, 2021
76adc81
New translations en.json (German)
sulkaharo Jun 12, 2021
e82697a
New translations en.json (Polish)
sulkaharo Jun 13, 2021
2e39bbe
New translations en.json (Polish)
sulkaharo Jun 13, 2021
495179c
New translations en.json (Polish)
sulkaharo Jun 16, 2021
3cabb5a
New translations en.json (Polish)
sulkaharo Jun 16, 2021
1ac44da
New translations en.json (Greek)
sulkaharo Aug 19, 2021
f1322cf
New translations en.json (Greek)
sulkaharo Aug 19, 2021
ef19f60
New translations en.json (Greek)
sulkaharo Aug 19, 2021
8b93cca
bump share2nightscout-bridge version
bewest Sep 30, 2021
310da5d
New translations en.json (Hebrew)
sulkaharo Oct 4, 2021
88071b5
Merge pull request #7123 from nightscout/wip/bewest/share2nightscout-…
bewest Oct 7, 2021
1da75b6
New translations en.json (Arabic)
sulkaharo Oct 9, 2021
38b2b78
New translations en.json (Arabic)
sulkaharo Oct 9, 2021
776a01d
New translations en.json (Arabic)
sulkaharo Oct 9, 2021
72129d5
New translations en.json (Arabic)
sulkaharo Oct 10, 2021
606e5b3
New translations en.json (Arabic)
sulkaharo Oct 10, 2021
b2fb9b3
New translations en.json (Arabic)
sulkaharo Oct 12, 2021
bc44960
New translations en.json (Arabic)
sulkaharo Oct 12, 2021
41fdb8e
respect per route body-parser configuration
bewest Oct 13, 2021
633c23a
New translations en.json (Arabic)
sulkaharo Oct 13, 2021
0ddcede
New translations en.json (Arabic)
sulkaharo Oct 13, 2021
bb6a7a5
New translations en.json (Arabic)
sulkaharo Oct 13, 2021
bc8e319
Merge pull request #7131 from nightscout/wip/bewest/request-body-limit
bewest Oct 18, 2021
6250612
sanitize x-forwarded-for header (#7122)
bewest Oct 24, 2021
f5e8dca
Merge branch 'master' into dev
sulkaharo Oct 24, 2021
027bf5e
Prep next release - 14.2.4
bewest Oct 24, 2021
76cecc5
Add wares to v2 to support request parsing
sulkaharo Oct 25, 2021
87ff945
Move wares to ctx
sulkaharo Oct 25, 2021
a4e8466
Merge pull request #7144 from nightscout/add_wares_to_v2
bewest Oct 25, 2021
0b99060
npm install diffs make package-lock.json match
bewest Oct 25, 2021
6cc9a95
new dev branch starting post 14.2.4 release
bewest Oct 25, 2021
8e476b3
Fix api-secret header name in swagger configuration.
MJDSys Oct 31, 2021
1f747cd
New translations en.json (Turkish)
sulkaharo Nov 3, 2021
811249f
New translations en.json (Turkish)
sulkaharo Nov 3, 2021
753550f
New translations en.json (Turkish)
sulkaharo Nov 4, 2021
a08d2ae
New translations en.json (Turkish)
sulkaharo Nov 5, 2021
cf55034
New translations en.json (Turkish)
sulkaharo Nov 5, 2021
93f5c0b
New translations en.json (Turkish)
sulkaharo Nov 5, 2021
534c117
New translations en.json (Turkish)
sulkaharo Nov 7, 2021
473912c
New translations en.json (Turkish)
sulkaharo Nov 7, 2021
07559b6
New translations en.json (Turkish)
sulkaharo Nov 7, 2021
1b61122
New translations en.json (Turkish)
sulkaharo Nov 7, 2021
fb33420
New translations en.json (Turkish)
sulkaharo Nov 8, 2021
ca7ae17
New translations en.json (Turkish)
sulkaharo Nov 9, 2021
a4fde71
New translations en.json (Polish)
sulkaharo Nov 10, 2021
69aa5ee
New translations en.json (Polish)
sulkaharo Nov 10, 2021
cf92d4d
New translations en.json (Polish)
sulkaharo Nov 11, 2021
f8aa686
New translations en.json (Polish)
sulkaharo Nov 12, 2021
3da5b92
New translations en.json (Polish)
sulkaharo Nov 12, 2021
c65230f
New translations en.json (Polish)
sulkaharo Nov 13, 2021
321592f
New translations en.json (Polish)
sulkaharo Nov 13, 2021
1b780cb
New translations en.json (Polish)
sulkaharo Nov 13, 2021
4e0d8fd
New translations en.json (Portuguese, Brazilian)
sulkaharo Nov 19, 2021
780e5b0
New translations en.json (Portuguese, Brazilian)
sulkaharo Nov 19, 2021
e9b50e7
New translations en.json (Polish)
sulkaharo Nov 22, 2021
39cba5c
New translations en.json (Polish)
sulkaharo Nov 22, 2021
27dd88e
New translations en.json (Turkish)
sulkaharo Nov 27, 2021
8b17eb7
New translations en.json (Turkish)
sulkaharo Nov 27, 2021
c0a566d
New translations en.json (Turkish)
sulkaharo Nov 30, 2021
327051e
New translations en.json (Hebrew)
sulkaharo Nov 30, 2021
55e14fe
update minimum version of share2nightscout-bridge
bewest Dec 2, 2021
513d155
update minimed-connect-to-nightscout updates
bewest Dec 2, 2021
0bd983c
Increase accuracy of mg/dl to mmol/l ratio
cpitchford Dec 2, 2021
44d6cb9
Merge branch 'dev' into wip/cpitchford/increase_mmoll_accuracy
cpitchford Dec 2, 2021
8d83617
Support Dexcom HIGH/LOW when device is share2
cpitchford Dec 2, 2021
4b58cf7
Revert "update minimed-connect-to-nightscout updates"
bewest Dec 3, 2021
b00df3d
use newer version of minimed-connect-to-nightscout
bewest Dec 3, 2021
3def3a4
Merge branch 'dev' into wip/cpitchford/support_high_low_share2_device
bewest Dec 3, 2021
ededfc8
Merge branch 'wip/cpitchford/increase_mmoll_accuracy' of github.com:c…
bewest Dec 3, 2021
1477c79
Merge branch 'fix-swagger-auth' of github.com:mjdsys/cgm-remote-monit…
bewest Dec 3, 2021
cdc18b9
New translations en.json (Chinese Simplified)
sulkaharo Dec 6, 2021
5e0e592
Fixes broken Docker image build
pazaan Dec 6, 2021
0df986f
New translations en.json (Chinese Simplified)
sulkaharo Dec 6, 2021
bf3d90d
Merge branch 'crowdin_incoming' of github.com:nightscout/cgm-remote-m…
bewest Dec 6, 2021
cc392c8
Merge branch 'pazaan/fix-docker-image-build' of git://github.com/paza…
bewest Dec 6, 2021
df4acfa
Generating codacy coverage should not fail build
bewest Dec 6, 2021
a34a58b
Synchronise the dexcom collection times to reduce refresh lag
cpitchford Dec 9, 2021
a19a023
Merge branch 'dev' into wip/cpitchford/synchronize_dexcom_fetch_times
cpitchford Dec 9, 2021
7b9e07b
Merge branch 'dev' into wip/cpitchford/synchronize_dexcom_fetch_times
cpitchford Dec 10, 2021
dc312a8
Update test for new default interval
cpitchford Dec 10, 2021
4750f13
Merge pull request #7231 from cpitchford/wip/cpitchford/synchronize_d…
bewest Dec 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ npm-debug.log
/cgm-remote-monitor.sln
/obj/Debug
/*.bat

# directories created by docker-compose.yml
mongo-data/
letsencrypt/
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ FROM node:14.15.3-alpine

LABEL maintainer="Nightscout Contributors"

RUN mkdir -p /opt/app
ADD . /opt/app
WORKDIR /opt/app
RUN chown -R node:node /opt/app
USER node
ADD . /opt/app

RUN npm install && \
# TODO: We should be able to do `RUN npm install --only=production`.
# For this to work, we need to copy only package.json and things needed for `npm`'s to succeed.
# TODO: Do we need to re-add `npm audit fix`? Or should that be part of a development process/stage?
RUN npm install --cache /tmp/empty-cache && \
npm run postinstall && \
npm run env && \
npm audit fix
rm -rf /tmp/*
# TODO: These should be added in the future to correctly cache express-minify content to disk
# Currently, doing this breaks the browser cache.
# mkdir /tmp/public && \
# chown node:node /tmp/public

USER node
EXPOSE 1337

CMD ["node", "lib/server/server.js"]
76 changes: 76 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
version: '3'

services:
mongo:
image: mongo:4.4
volumes:
- ${NS_MONGO_DATA_DIR:-./mongo-data}:/data/db:cached

nightscout:
image: nightscout/cgm-remote-monitor:latest
container_name: nightscout
restart: always
depends_on:
- mongo
labels:
- 'traefik.enable=true'
# Change the below Host from `localhost` to be the web address where Nightscout is running.
# Also change the email address in the `traefik` service below.
- 'traefik.http.routers.nightscout.rule=Host(`localhost`)'
- 'traefik.http.routers.nightscout.entrypoints=websecure'
- 'traefik.http.routers.nightscout.tls.certresolver=le'
environment:
### Variables for the container
NODE_ENV: production
TZ: Etc/UTC

### Overridden variables for Docker Compose setup
# The `nightscout` service can use HTTP, because we use `traefik` to serve the HTTPS
# and manage TLS certificates
INSECURE_USE_HTTP: 'true'

# For all other settings, please refer to the Environment section of the README
### Required variables
# MONGO_CONNECTION - The connection string for your Mongo database.
# Something like mongodb://sally:[email protected]:99999/nightscout
# The default connects to the `mongo` included in this docker-compose file.
# If you change it, you probably also want to comment out the entire `mongo` service block
# and `depends_on` block above.
MONGO_CONNECTION: mongodb://mongo:27017/nightscout

# API_SECRET - A secret passphrase that must be at least 12 characters long.
API_SECRET: change_me

### Features
# ENABLE - Used to enable optional features, expects a space delimited list, such as: careportal rawbg iob
# See https://github.com/nightscout/cgm-remote-monitor#plugins for details
ENABLE: careportal rawbg iob

# AUTH_DEFAULT_ROLES (readable) - possible values readable, denied, or any valid role name.
# When readable, anyone can view Nightscout without a token. Setting it to denied will require
# a token from every visit, using status-only will enable api-secret based login.
AUTH_DEFAULT_ROLES: denied

# For all other settings, please refer to the Environment section of the README
# https://github.com/nightscout/cgm-remote-monitor#environment

traefik:
image: traefik:latest
container_name: 'traefik'
command:
- '--providers.docker=true'
- '--providers.docker.exposedbydefault=false'
- '--entrypoints.web.address=:80'
- '--entrypoints.web.http.redirections.entrypoint.to=websecure'
- '--entrypoints.websecure.address=:443'
- "--certificatesresolvers.le.acme.httpchallenge=true"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
- '--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json'
# Change the below to match your email address
- '[email protected]'
ports:
- '443:443'
- '80:80'
volumes:
- './letsencrypt:/letsencrypt'
- '/var/run/docker.sock:/var/run/docker.sock:ro'
19 changes: 4 additions & 15 deletions lib/api/activity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,14 @@ function configure(app, wares, ctx) {
, api = express.Router();

api.use(wares.compression());
api.use(wares.bodyParser({
limit: 1048576 * 50
}));
// text body types get handled as raw buffer stream
api.use(wares.bodyParser.raw({
limit: 1048576
}));
api.use(wares.rawParser);
// json body types get handled as parsed json
api.use(wares.bodyParser.json({
limit: 1048576
, extended: true
limit: '50Mb'
}));
// also support url-encoded content-type
api.use(wares.bodyParser.urlencoded({
limit: 1048576
, extended: true
}));
api.use(wares.urlencodedParser);
// invoke common middleware
api.use(wares.sendJSONStatus);

Expand Down Expand Up @@ -94,9 +85,7 @@ function configure(app, wares, ctx) {
});
}

api.post('/activity/', wares.bodyParser({
limit: 1048576 * 50
}), ctx.authorization.isPermitted('api:activity:create'), post_response);
api.post('/activity/', ctx.authorization.isPermitted('api:activity:create'), post_response);

api.delete('/activity/:_id', ctx.authorization.isPermitted('api:activity:delete'), function(req, res) {
ctx.activity.remove(req.params._id, function() {
Expand Down
10 changes: 5 additions & 5 deletions lib/api/alexa/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function configure (app, wares, ctx, env) {
// invoke common middleware
api.use(wares.sendJSONStatus);
// text body types get handled as raw buffer stream
api.use(wares.bodyParser.raw());
api.use(wares.rawParser);
// json body types get handled as parsed json
api.use(wares.bodyParser.json({
limit: 1048576
, extended: true
}));
api.use(wares.jsonParser);
// also support url-encoded content-type
api.use(wares.urlencodedParser);
// text body types get handled as raw buffer stream

ctx.virtAsstBase.setupVirtAsstHandlers(ctx.alexa);

Expand Down
10 changes: 4 additions & 6 deletions lib/api/devicestatus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ function configure (app, wares, ctx, env) {
// invoke common middleware
api.use(wares.sendJSONStatus);
// text body types get handled as raw buffer stream
api.use(wares.bodyParser.raw());
api.use(wares.rawParser);
// json body types get handled as parsed json
api.use(wares.bodyParser.json({
limit: 1048576
, extended: true
}));
api.use(wares.jsonParser);
// also support url-encoded content-type
api.use(wares.bodyParser.urlencoded({ extended: true }));
api.use(wares.urlencodedParser);
// text body types get handled as raw buffer stream

api.use(ctx.authorization.isPermitted('api:devicestatus:read'));

Expand Down
12 changes: 5 additions & 7 deletions lib/api/entries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,18 @@ function configure (app, wares, ctx, env) {
// invoke common middleware
api.use(wares.sendJSONStatus);
// text body types get handled as raw buffer stream
api.use(wares.bodyParser.raw());
api.use(wares.rawParser);
// json body types get handled as parsed json
api.use(wares.bodyParser.json({
limit: 1048576
, extended: true
limit: '50Mb'
}));
// also support url-encoded content-type
api.use(wares.urlencodedParser);
// text body types get handled as raw buffer stream
// shortcut to use extension to specify output content-type
api.use(wares.extensions([
'json', 'svg', 'csv', 'txt', 'png', 'html', 'tsv'
]));
// also support url-encoded content-type
api.use(wares.bodyParser.urlencoded({
extended: true
}));

api.use(ctx.authorization.isPermitted('api:entries:read'));
/**
Expand Down
11 changes: 5 additions & 6 deletions lib/api/food/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ function configure (app, wares, ctx) {
// invoke common middleware
api.use(wares.sendJSONStatus);
// text body types get handled as raw buffer stream
api.use(wares.bodyParser.raw( ));
api.use(wares.rawParser);
// json body types get handled as parsed json
api.use(wares.bodyParser.json({
limit: 1048576
, extended: true
}));
api.use(wares.jsonParser);
// also support url-encoded content-type
api.use(wares.bodyParser.urlencoded({ extended: true }));
api.use(wares.urlencodedParser);
// text body types get handled as raw buffer stream
// shortcut to use extension to specify output content-type

api.use(ctx.authorization.isPermitted('api:food:read'));

Expand Down
5 changes: 3 additions & 2 deletions lib/api/googlehome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ function configure (app, wares, ctx, env) {
// invoke common middleware
api.use(wares.sendJSONStatus);
// text body types get handled as raw buffer stream
api.use(wares.bodyParser.raw());
api.use(wares.rawParser);
// json body types get handled as parsed json
api.use(wares.bodyParser.json());
api.use(wares.jsonParser);


ctx.virtAsstBase.setupVirtAsstHandlers(ctx.googleHome);

Expand Down
2 changes: 1 addition & 1 deletion lib/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function create (env, ctx) {
, app = express( )
;

var wares = require('../middleware/')(env);
const wares = ctx.wares;

// set up express app with our options
app.set('name', env.name);
Expand Down
7 changes: 7 additions & 0 deletions lib/api/notifications-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ function configure (app, ctx) {
, api = express.Router( )
;

api.use(ctx.wares.compression());
api.use(ctx.wares.rawParser);
api.use(ctx.wares.bodyParser.json({
limit: '50Mb'
}));
api.use(ctx.wares.urlencodedParser);

api.post('/loop', ctx.authorization.isPermitted('notifications:loop:push'), function (req, res) {
ctx.loop.sendNotification(req.body, req.connection.remoteAddress, function (error) {
if (error) {
Expand Down
10 changes: 4 additions & 6 deletions lib/api/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ function configure (app, wares, ctx) {
// invoke common middleware
api.use(wares.sendJSONStatus);
// text body types get handled as raw buffer stream
api.use(wares.bodyParser.raw( ));
api.use(wares.rawParser);
// json body types get handled as parsed json
api.use(wares.bodyParser.json({
limit: 1048576
, extended: true
}));
api.use(wares.jsonParser);
// also support url-encoded content-type
api.use(wares.bodyParser.urlencoded({ extended: true }));
api.use(wares.urlencodedParser);
// text body types get handled as raw buffer stream

api.use(ctx.authorization.isPermitted('api:profile:read'));

Expand Down
4 changes: 3 additions & 1 deletion lib/api/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

function configure (app, wares, env, ctx) {
var express = require('express'),
forwarded = require('forwarded-for'),
api = express.Router( )
;

Expand All @@ -21,7 +22,8 @@ function configure (app, wares, env, ctx) {
var authToken = req.query.token || req.query.secret || '';

function getRemoteIP (req) {
return req.headers['x-forwarded-for'] || req.connection.remoteAddress;
const address = forwarded(req, req.headers);
return address.ip;
}

var date = new Date();
Expand Down
22 changes: 6 additions & 16 deletions lib/api/treatments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,16 @@ function configure (app, wares, ctx, env) {
, api = express.Router();

api.use(wares.compression());
api.use(wares.bodyParser({
limit: 1048576 * 50
, extended: true
}));

// text body types get handled as raw buffer stream
api.use(wares.bodyParser.raw({
limit: 1048576
}));
api.use(wares.rawParser);
// json body types get handled as parsed json
api.use(wares.bodyParser.json({
limit: 1048576
, extended: true
limit: '50Mb'
}));
// also support url-encoded content-type
api.use(wares.bodyParser.urlencoded({
limit: 1048576
, extended: true
}));
api.use(wares.urlencodedParser);

// invoke common middleware
api.use(wares.sendJSONStatus);

Expand Down Expand Up @@ -150,9 +142,7 @@ function configure (app, wares, ctx, env) {
});
}

api.post('/treatments/', wares.bodyParser({
limit: 1048576 * 50
}), ctx.authorization.isPermitted('api:treatments:create'), post_response);
api.post('/treatments/', ctx.authorization.isPermitted('api:treatments:create'), post_response);

/**
* @function delete_records
Expand Down
4 changes: 3 additions & 1 deletion lib/api3/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ const apiConst = require('./const.json')
, _ = require('lodash')
, shiroTrie = require('shiro-trie')
, opTools = require('./shared/operationTools')
, forwarded = require('forwarded-for')
;


function getRemoteIP (req) {
return req.headers['x-forwarded-for'] || req.connection.remoteAddress;
const address = forwarded(req, req.headers);
return address.ip;
}


Expand Down
6 changes: 4 additions & 2 deletions lib/api3/storageSocket.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const apiConst = require('./const');
const forwarded = require('forwarded-for');

/**
* Socket.IO broadcaster of any storage change
Expand Down Expand Up @@ -28,7 +29,8 @@ function StorageSocket (app, env, ctx) {
self.namespace = io.of(NAMESPACE);
self.namespace.on('connection', function onConnected (socket) {

const remoteIP = socket.request.headers['x-forwarded-for'] || socket.request.connection.remoteAddress;
const address = forwarded(socket.request, socket.request.headers);
const remoteIP = address.ip;
console.log(LOG + 'Connection from client ID: ', socket.client.id, ' IP: ', remoteIP);

socket.on('disconnect', function onDisconnect () {
Expand Down Expand Up @@ -142,4 +144,4 @@ function StorageSocket (app, env, ctx) {
}
}

module.exports = StorageSocket;
module.exports = StorageSocket;
Loading