API documentation Node version 18.7.0 (.nvmrc available).
/distcontains the main.bundle.js after building the frontend withnpm run build:devin /frontend (uses webpack). /dist is served by the backend when the backend is started withnpm run start:devfrom /backend./backend/buildcontains the javascript output of the typescript files that the backend is made of. The typescript compiler puts javascript into /backend/build when runningnpm run buildin /backend.
These steps should only be done once per person, which should allow for local development using a temporary SSL certificate (the certificate is ignored from the repository), as well as installing NPM packages.
- Clone the repository in some way.
- Install mkcert for your OS. On macOS you could use
brew install mkcertfrom any directory, if you have brew. - Make a new directory /backend/cert.
- In the /backend/cert directory, run
mkcert localhost. - In order for the team to have the same version of node, you could either install node v18.7.0, or install nvm (node version manager) for your OS. With nvm, you could run
nvm usefrom /backend/ or /frontend prior to running the npm commands below for both installing and running things.nvm usemakes use of the node version listed in .nvmrc. (I'm not sure if this setting survives terminal shutdown.) - Go to /frontend and run
npm install. - Go to /backend and run
npm install. - Create a .env file in the backend folder (at root level) and paste the distributed token (emailed to course instructors).
There are basically three scenarios which are described in the following sections.
This runs the frontend with the development server, which allows for hot-reloading and faster iteration, rather than building the main.bundle.js after every change.
- In /frontend, run
npm run dev. This starts a dev server, serving the frontend, right? - In /backend, run
npm run start:dev(I don't get this, why do we need to start the server if we already have started a dev server in the previous step? Is "start:dev" on the backend meant to run in conjunction with "dev" on frontend? If so, that would mean two servers have started? But why? We only need one server.) - The app should be viewable in the browser at address https://localhost:3000.
This allows for quick iteration on the backend, serving the "compiled" frontend.
- In /frontend,
npm run build:dev. - In /backend,
npm run start:dev. - App viewable at https://localhost:8080/.
C. Making a Docker image of the project and starting a container containing our backend, serving frontend
- Install Docker Desktop.
- In /frontend,
npm run build:dev. - In the project directory, run
docker build -t iprogbackend .. - Run
docker run -p 3000:3000 iprogbackend. - App viewable at https://localhost:3000/.
