Blip is a web-based tool for managing all your Type 1 Diabetes data in one place.
JavaScript CSS Other
Latest commit e1d4fe2 Feb 22, 2017 @jebeck jebeck committed on GitHub Merge pull request #391 from tidepool-org/jebeck/bugfix-race-conditio…
…n-state-tree

bugfix race condition state tree
Permalink
Failed to load latest commit information.
app don't mutate redux store state in mapStateToProps + regression tests Feb 21, 2017
config remove obsolte configs and update .gitignore accordingly Mar 17, 2016
docs README cleanup & first draft of docs, incl. tooling Nov 23, 2016
integration increase timeout on nightwatch terms tests Jul 27, 2016
test tinyfix: spelling Feb 21, 2017
.babelrc get tests to build with npm linked viz Aug 24, 2016
.bookignore README cleanup & first draft of docs, incl. tooling Nov 23, 2016
.eslintrc more removal of mock-mode stuff Mar 17, 2016
.gitignore README cleanup & first draft of docs, incl. tooling Nov 23, 2016
.travis.yml Disable Nightwatch in Travis config Oct 17, 2016
LICENSE Add BSD2 license Jan 16, 2014
README.md Fix typo in signup confirmation URL query parameter in the README.md Dec 1, 2016
SUMMARY.md README cleanup & first draft of docs, incl. tooling Nov 23, 2016
build.sh Fix build script Sep 6, 2014
buildapp.js Merge branch 'gordyd/redux' into gordyd/redux-style-hash Mar 18, 2016
buildconfig.js fix prod build to get nightwatch tests to succeed + some renamings fo… Jul 14, 2016
config.app.js WIP for stnadardising validation of user input forms Apr 22, 2016
config.server.js Make build compatible with shio Aug 7, 2014
config.webpack.js add back option that exposes the bundle on (crucially) Aug 23, 2016
docker-compose.yml initial attempt at trivial nightwatch test run Mar 18, 2016
favicon.ico Adds a favicon for Blip Jan 19, 2015
index.html tweak the loading indicator (recent request from HL) Mar 18, 2016
karma.conf.js fix prod build to get nightwatch tests to succeed + some renamings fo… Jul 14, 2016
loadtests.js fix prod build to get nightwatch tests to succeed + some renamings fo… Jul 14, 2016
nightwatch-globals.js server setup and teardown cleanup, adding tests Mar 18, 2016
nightwatch.json server setup and teardown cleanup, adding tests Mar 18, 2016
package.json add redux-immutable-state-invariant to warn us about hidden mutations… Feb 21, 2017
server.js initial attempt at trivial nightwatch test run Mar 18, 2016
start.sh Fix shio start script Aug 11, 2014
test.config.js get tests to build with npm linked viz Aug 24, 2016
update-gh-pages.sh README cleanup & first draft of docs, incl. tooling Nov 23, 2016
webpack.config.js use the actual freaking React production build, o m g Dec 2, 2016

README.md

Blip

Build Status

Blip is a web app for type 1 diabetes (T1D) built on top of the Tidepool platform. It allows patients and their "care team" (family, doctors) to visualize their diabetes device data (from insulin pumps, BGMs, and/or CGMs) and message each other.

This README is focused on just the details of getting blip running locally. For more detailed information aimed at those working on the development of blip, please see the developer guide.


Table of contents


Install

Requirements:

Clone this repo from GitHub, then install the dependencies:

$ npm install

Running locally

If you're running the entire Tidepool platform locally as per starting services, you can start blip using your local platform with:

$ source config/local.sh
$ npm start

Open your web browser and navigate to http://localhost:3000/.

(See also: recipe for running blip locally with hot module replacement.)

Getting past e-mail verification for a user created locally

When running locally with runservers, no e-mail will be sent to a sign-up e-mail address, and so a workaround is needed to get past the e-mail verification step for a newly created local account being used for development. What you need to do is construct the login URL that is provided in a link in the verification e-mail manually by finding the correct ID for the e-mail confirmation. There are two ways to do this: by looking in the local server.log (located at the root level of where you've cloned all the Tidepool repositories) or by finding it in your local Mongo database. The steps for the latter are:

  • start a Mongo shell in a fresh Terminal window with mongo
  • switch to the confirm database with use confirm
  • find the pending account with db.confirmations.find({status: 'pending'});
  • copy the _id from the pending confirmation record with an email matching the account you've just created and provide it as a signupKey parameter in the login URL: http://localhost:3000/login?signupKey=<_id>

Creating a user without e-mail verification

When running locally, there is also workaround so you don't have to verify the e-mail address of a new user: if you create a new user and add the localhost secret +skip to the e-mail address - e.g. me+skip@something.org - this will then allow you to login straightaway, skipping the e-mail verification step.

NB: The UI is not guaranteed to display correctly for +skip-created users on all pages, and so 💣 THIS WORKFLOW IS NOT CURRENTLY RECOMMENDED 💣. For now, you must create a normal account (without +skip) if you want to work on the sign-up flow, although we have plans to fix the way the +skip workaround operates on the platform to address this.

Running against dev

By default—that is, if you don't source a different configuration, such as the local.sh configuration for local development with runservers referenced above—if you simply run npm start in this repository after installing the dependencies, blip will start up running against Tidepool's "dev" server environment.

Config

Configuration values are set with environment variables (see config/local.sh).

You can set environment variables manually using export VAR=value, or use a bash script. For example:

$ source config/local.sh

Ask the project owners to provide you with config scripts for different environments, or you can create one of your own if you have a custom environment. It is recommended to put all config scripts in the config/ directory, where they will be ignored by Git.

Debugging

The app uses the bows library to log debugging messages to the browser's console. It is disabled by default (which makes it production-friendly). To see the messages type localStorage.debug = true in the browser console and refresh the page. Create a logger for a particular app module by giving it a name, such as:

app.foo = {
  log: bows('Foo'),
  bar: function() {
    this.log('Walked into a bar');
  }
};

Running the tests

We use Mocha with Chai for our test framework inside Karma as our test runner, as well as Sinon.JS and Sinon-Chai for spies and stubs. Our tests currently run on PhantomJS, a headless WebKit browser, or Chrome (locally only).

To run the unit tests, use:

$ npm test

To run the unit tests in Chrome, use:

$ npm run browser-tests

To run the unit tests in watch mode, use:

$ npm run test-watch

Build and deployment

The app is built as a static site in the dist/ directory.

We use Shio to deploy, so we separate the build in two.

Shio's build.sh script will take care of building the app itself with:

$ npm run build-app

Shio's start.sh script then builds the config from environment variables as a separate file with:

$ source config/env.sh
$ npm run build-config

After that, the app is ready to be served using the static web server included in this repo:

$ npm run server

You can also build everything at once locally to test the production build by simply running:

$ source config/local.sh
$ npm run build
$ npm run server