Skip to content

Commit

Permalink
Merge pull request #56 from mcode/rems-556-connectathon-docs
Browse files Browse the repository at this point in the history
Update docs for Jan 2024 Connectathon
  • Loading branch information
jtquach1 authored Jan 4, 2024
2 parents fd3ca3d + 28c54dc commit be412e6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 64 deletions.
16 changes: 0 additions & 16 deletions .github/auto_assign.yml

This file was deleted.

File renamed without changes.
2 changes: 0 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ WORKDIR /home/node/app/frontend
RUN npm install
WORKDIR /home/node/app

RUN npm install pm2 -g

EXPOSE 5050
EXPOSE 5051

Expand Down
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
# Pharmacy Information Management System

### Setup
## Setup

The application is divided into a frontend and backend service. For an initial setup run `npm install` in both the frontend and backend subdirectories. This will install the dependencies required for each of the services.

The application is divided into a frontend and backend service. For an initial setup you will need to `run npm install` in both the frontend and backend subdirectories. This will install the dependencies required for each of the services.
## Running backend and frontend

### Running
Run the individual services by either launching both of them independently or using pm2 innately through Docker.

Running the individual services can be done by either launching both of them independently or using pm2. To run them individually you will need to open a terminal window in each of the frontend and backend subdirectories. From there you will need to run `npm start` in each of the terminal windows.
### Running independently

To run both the systems under pm2 you will first need to install it: `npm install pm2 -g` After it is installed you can run both the systems with a single command `pm2 start pm2.config.json`. This will start both the frontend and the backend services.
To run them individually you will need to open a terminal window in each of the frontend and backend subdirectories. From there you will need to run `npm start` in each of the terminal windows.

By default, the frontend will start on port 3000 and the backend will start on port 5051. To configure the frontend to start on different port set the PORT environment variable to the port you would like it to start on. ex. `PORT 5050 npm start` To configure the backend to start on a different port set the BACKEND_PORT environment variable to the port you would like it to run on.
By default, the frontend will start on port 5050 (defined in `frontend/.env`) and the backend will start on port 5051 (defined in `backend/env.json`).

These environment variables, and others , can also be set in the pm2 configuration file for the individula service entries.
To configure the frontend to start on different port, set the `PORT` environment variable to the desired port; e.g. `PORT=5050 npm start`, or create a `frontend/.env.local` to override `PORT`.

Once running both the frontend and backend systems open [http://localhost:5050](http://localhost:5050) in your browser to view the application.
To configure the backend to start on a different port, set the `BACKEND_PORT` environment variable to the desired port; e.g.
`BACKEND_PORT=5051 npm start`.

These environment variables, and others, can also be set in the pm2 configuration file for the individual service entries.

Once running both the frontend and backend systems, open [http://localhost:5050](http://localhost:5050) in your browser to view the application.

### Using pm2

`pm2` is used in our [Dockerized REMS Integration Prototype setup](https://github.com/mcode/rems-setup/blob/main/DeveloperSetupGuide.md) for production to start both the frontend and the backend services. It is not used in development due to a bug with hot-reloading code changes in the two services.

## Version
This application requires node v20.0 or greater.

This application requires node.js v20.0 or greater. Using [`nvm`](https://github.com/nvm-sh/nvm) is optional, but easier when managing different node.js versions.

- `nvm install 20`
- `nvm use 20` or `nvm use default 20`, as most of the REMS Integration Prototype repositories are compatible with node v20.0.
22 changes: 0 additions & 22 deletions pm2.config.dev.js

This file was deleted.

30 changes: 15 additions & 15 deletions pm2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
*
* This is mainly used in our Docker image.
*/
module.exports = {
module.exports = {
apps: [
// API Server
{
name: 'API',
script: 'npm start',
cwd: 'backend',
name: "API",
script: "npm start",
cwd: "backend",
env_production: {
NODE_ENV: 'production'
}
NODE_ENV: "production",
},
},
// Fronted Server
// Frontend Server
{
name: 'FrontEnd',
script: 'npm start',
cwd: 'frontend',
name: "FrontEnd",
script: "npm start",
cwd: "frontend",
env_production: {
NODE_ENV: 'production'
}
}
]
};
NODE_ENV: "production",
},
},
],
};

0 comments on commit be412e6

Please sign in to comment.