This repository provides the source code for the mobile back end of the Compass NUM-App Project. This project provides a set of open source components meant for the digital conduct of questionnaire based studies. The mobile back end itself is a part of COMPASS (Coordination On Mobile Pandemic Apps best practice and Solution Sharing).
The mobile back end provides study data for the NUM-App in form of FHIR Questionnaires. It also stores the study data that is uploaded from the mobile app. Additionally it makes the collected data accessible for other parties.
You can find an exemplary questionnaire here.
-
Make sure you have a recent version (LTS recommended) of Node.js installed and run the following commands to download and prepare this repository:
git clone https://github.com/NUMde/compass-numapp-backend.git
cd compass-numapp-backend/
npm install
-
In case you use VSCode as your editor, install the recommended extensions
For local development we need an RSA key pair for the encryption with the client.
Execute the following commands to create a key pair.
The resulting files are picked automatically. But they can also be inserted into the .env
file.
$ openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:4096
$ openssl rsa -pubout -in private_key.pem -out public_key.pem
To submit the public key to the client, a certificate must be created. To create a self-signed certificate, which will be valid for 1 year, use the following command:
$ openssl req -x509 -days 365 -new -out self-signed-certificate.pem -key private_key.pem
The certificate must be put in the .env file. If no certificate is provided, the native app will default to a built-in one (defined in src/config/appConfig.js).
Start the application on the local machine in watch mode. This is the preferred command for local development.
There are many different environment variables used by the application.
Most of them have default values, that can be overridden by exposing a different value as environment variable.
All used variables can be found in the src/config
folder.
This app uses Husky to trigger some actions during a commit. Before each commit passes automatic tests and linting is run. If any action fails, the commit fails.
The application should run in any environment that provides a Node.js runtime. The current configuration is suited for an OpenShift deployment. Find detailed instructions here OCP Deployment.
Dedicated documentation for the database setup can be found here DB Setup.