Skip to content

mmb-irb/MDDB-REST-API

Repository files navigation

Requirements

Have Node.js and npm installed and working

Setup

Installation

  1. Install the dependencies with npm install or npm ci (install exact dependencies as defined by package-lock.json file)
  2. Create and fill an .env file in the root of the project (see reference below for the keys)
  3. Create and fill an config.js file in the root of the project
  4. (Optional) Compile the trajectory format converters with npm run build. Otherwise, the trajectory endpoint will not be able to export from .bin to other formats. Chemfiles must be previously installed.
  5. Start the server with node index.js or using a process manager like PM2 for example

Test run

To simply run an instance of the API you must enter the API git repository and run the following command:

npm run start

If you have an error related to process 9229 yo may solvie it like this:

kill -9 lsof -t -i:9229

PM2 Installation and run

PM2 is a deamon which handles the spawn and monitoring of API instances. It is also useful to automatically respawn instances after failure.

In order to install pm2 run npm install pm2.
Once installed, head to the API directory and run 4 instances of it:

cd /path/to/api
pm2 start index.js -i 4 -n MDposit_API --node-args="--experimental-worker"

If you need to stop the API then do the following:

pm2 delete MDposit_API

Note that the API processes must be stopped and run again for new code to be effective after a 'git pull'.

.env file fields

⚠️ No sensible default value is provided for any of these fields, they need to be defined ⚠️

key value description
NODE_ENV test or not defined to run a local fake mongo
DB_SERVER <url> url of the db server
DB_PORT number port of the db server
DB_NAME string name of the db collection
DB_AUTH_USER string db user
DB_AUTH_PASSWORD string db password
DB_AUTHSOURCE string authentication db
LISTEN_PORT number port to query the API

config.yml file

You may need to edit this file as well to customize your swagger documentation and define how the API should behave depending on the requesting URL.
The file in the repository provides an explanation on every field and several examples.

chemfiles installation

Clone and install the chemfiles fork customized to support '.bin' format reading and streaming.

git clone https://github.com/d-beltran/chemfiles
cd chemfiles
mkdir build
cd build
cmake ..
make
sudo make install

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •