University Health Network API Endpoint Backend Server
- Install Node.js through online browser
- Install MongoDB through online browser, specifically the MongoDB Community Server
- Create a ".env" file with SECRET defined as one of the environment variables
- In ".env", define DATABASE_URL with format:
"postgresql://<username>:<password>@<host>:5432/UHN-metrics"
- Open command prompt from start on local PC (assuming windows setup)
- Type "cd ..." and replace "..." with the bin folder directory within where mongoDB is installed
- Run "mongo.exe"
- Download Redis using wget (Windows: wsl, Mac/Linux: terminal). Use version 5.0.6
$ wget http://download.redis.io/releases/redis-5.0.6.tar.gz
- Unzip tar file
$ tar xzf redis-5.0.6.tar.gz
- Make project
$ cd redis-5.0.6
$ make
- Run Redis server, leave process opened
$ src/redis-server
Make sure you are in project directory and run, it will automatically detect any changes and refresh when necessary
$ npm start
-
Download and install Postgres 12 (Older versions cannot use Postgres 12 databases). Remember superuser password.
-
Make sure your system environment variables contain the PATH to the "bin" folder in PostgresQL's install location, or else "pg_ctl" command may not be found.
-
Start server with
pg_ctl -D "PathToPostgresInstall" start
(Default windows path: "C:/Program Files/PostgreSQL/12/data")
Stop server with
pg_ctl -D "PathToPostgresInstall" stop
-
Once server has started, enter postgres CLI with superuser account 'postgres'
psql postgres postgres
. Enter your superuser password when prompted. -
Create database called "UHN-metrics"
CREATE DATABASE "UHN-metrics";
-
Create user named metric with password pwctcuhn
CREATE ROLE metric WITH LOGIN PASSWORD 'pwctcuhn';
-
Logout from postgres server and enter following command in the root directory to initalize database
psql --username=metric UHN-metrics < data.sql
To fill database with example data, uncomment bottom statements in data.sql and run command from step 7.
For help with DATABASE_URL fields, go to root directory, connect to postgres with psql --username=metric UHN-metrics
and enter \conninfo
Make sure you are in project directory and run
$ npm test
- Remove email field:
db.users.update({}, {$unset: {email: true}}, {multi: true, safe: true})