Middleware designed to interface with the Garmin API.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Before starting, download and install python, pip, virtualenv and Node.js.
Sends messages to: sensor-fhir-mapper (install).
(Recommended) Create an SSH key and clone this repository.
git clone git@github.kcl.ac.uk:consult/ehr-integration.git
(Alternative) Clone this repository using HTTPs, suppling username and password:
git clone https://github.kcl.ac.uk/consult/ehr-integration.git
Configure submodules:
git submodule init
git submodule update
View.
This is an express (lightweight server) project. The majority of the logic is contained within app.js, and in the routes and lib folders.
Once a file is edited, stage, commit and push changes from the root folder as follows:
git add .
git commit -m "[details of changes]"
git push
Create an environment file:
touch .env
Add the following information to this environment file using a text editor:
USERNAME="[username]"
PASSWORD="[password]"
Where [username] and [password] are credentials to secure this service.
Ensure you are in the root folder. Create a node virtual environment (within a python virtual environment), and activate it:
virtualenv env
. env/bin/activate
pip install nodeenv
nodeenv nenv
. nenv/bin/activate
Install dependencies:
cat requirements.txt | xargs npm install -g
Run server:
npm start
The server runs by default on port 3003. Visit localhost:3003/[route] to test changes to GET endpoints and use software such as Postman to test changes to POST (and other) endpoints.
Run both unit and lint tests using npm
:
npm test
Deployment is via Docker, and includes containers for this application, a production SQL database and an optional reverse proxy. If using the reverse proxy, fill in the appropriate configuration.
Build these containers:
docker-compose build
Run these containers:
docker-compose up
(Optional) Run without proxy:
docker-compose up --scale proxy=0
Different docker-compose files exist to accomodate different service configurations.
To use custom private certificates for communication with this service's proxy, reference them in the proxy's Dockerfile. The gen-domain-cert script can be used to generate custom certs (e.g. 'grey.crt') using a CA root cert (e.g. 'consult.crt') and accompanying keys. If distributing an image outside of an organisation, edit Dockerfile and docker-compose to mount a volume on the host containing the certs instead, so that images are not transferred with the certs inside then.
For public certificates, certificate generation is via LetsEncrypt. Generate as follows:
- Remove references to certificates from Nginx HTTPS configuration, as running HTTP server is required for challenge.
- Change Cerbot command in docker-compose from
--force-renewal
to--dry-run
. - Build and run, and upon successful call of HTTP challenge, change back to
--force-renewal
and build and run again in order to generate certificates. - Re-add certificae configuration, build and run.
Renewal can be done on re-build, or by setting up a cron.
- Express - Web framework.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
Produced as part of the CONSULT project.
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Garmin's original API: https://developerportal.garmin.com and https://healthapi.garmin.com/.