Giter Site home page Giter Site logo

compass-numapp-backend's Introduction

NUM-App Mobile Back End

Welcome

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.

Development

Local Setup

  • 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

Run the back end locally

Generating RSA key pair

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.

Create .env file

Some configuration values need to be present as environment variables during runtime. The application loads a file with the name .env during startup, if it is present.

To get started copy the file .env.sample to .env and add your values.

$ openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:4096
$ openssl rsa -pubout -in private_key.pem -out public_key.pem

Generating certificate

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).

Scripts

npm run start

Start the built application

npm run dev

Start the application on the local machine in watch mode. This is the preferred command for local development.

npm run build

Build the application into the build folder.

npm run clean

Clean the dist folder.

npm run lint

Lint the source code.

npm run prettier-format

Have prettier format your code.

npm run test

Run your unit tests with jest.

Environment variables used by the application

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.

Committing code changes

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.

Deployment

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.

Database Setup

Dedicated documentation for the database setup can be found here DB Setup.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.