Skip to content

CHUV-PCL/Nof1Companion-backend

Repository files navigation

Nest Logo

N-of-1 Companion - Backend

Description

N-of-1 Companion is a web application designed to facilitate the conduct of N-of-1 therapeutic tests. It allows you to design and manage your tests, collect patient data, perform statistical analysis and many other features.

This tool is offered by the Clinical Pharmacology Department of the University Hospital of Vaud (PCL - CHUV, Switzerland). With the collaboration of the School of Engineering and Management Vaud (HEIG-VD).


This is the backend API of the N-of-1 Companion web application.

Build with:

The frontend part of the application can be found here.

Prerequisites

Please ensure that the following items are installed on your operating system :

You must have a working MongoDB database. You can use either the MongoDB Server Community Edition, a cloud-based MongoDB Atlas instance, or a Docker container.

Create a .env file if not present and set the following environment variables :

# APP PORT
PORT=3001 # port number of your choice
# Frontend urls
FRONTEND_URL=https://your_frontend_application_url
FRONTEND_URL2=https://your_frontend_application_url2 # we used this for a specific need, but you can simply copy and paste the url above.
# mongodb uri connection string
MONGODB_URI=mongodb://user:password@host:27017/nof1Companion # your mongodb URI
# JWT
JWT_SECRET=YOUR_STRONG_JWT_SECRET
JWT_EXPIRATION_TIME=24h # JWT expiration time of your choice
# Configuration of the email account that will be used to send emails.
MAIL_HOST=smtp.office365.com # smtp server address. Here is an exemple with a Microsoft account.
MAIL_USER=your_address@domain.com # email address
MAIL_PASSWORD=YOUR_PASSWORD # email account password
# crypto secrets used to encrypt/decrypt identifying data
SECRET=32_BYTES_SECRET_STRING # 32 bytes
IV_SECRET=16_BYTES_SECRET_STRING # 16 bytes
SALT_SECRET=64_BYTES_SECRET_STRING # 64 bytes
# secret of the session cookie for the captcha challenge
SESSION_KEY=32_BYTES_SECRET_STRING # 32 bytes

Installation

Install the Nest CLI globally using :

$ npm install -g @nestjs/cli

Clone the repository and install the project dependencies using the following command in the project root folder:

$ npm install

Running the app

Make sure MongoDB is up and running before launching the server.

Commands:

# development mode
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run build
$ npm run start:prod

Default url : http://localhost:3000/ (or port :process.env.PORT)

Install the frontend part of the application to interact with the server, or use a tool like postman.

OpenAPI documentation

After launching the server, you can access the OpenAPI documentation (not complete, but providing an overview of routes) at http://localhost:PORT/api.

Maintenance

There is no guarantee that the project will be further developed. But you are welcome to fork the project.

Contributors

Initially developed as a Bachelor study project at the HEIG-VD, then taken over as a Junior Software Engineer.

License

Distributed under the GNU AGPLv3 license. See LICENSE for more information.

About

N-of-1 Companion is a web application designed to facilitate the conduct of N-of-1 therapeutic tests.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published