Skip to content

Repository files navigation

DH2643 Project group 12

API documentation Node version 18.7.0 (.nvmrc available).

Project structure

  • /dist contains the main.bundle.js after building the frontend with npm run build:dev in /frontend (uses webpack). /dist is served by the backend when the backend is started with npm run start:dev from /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 running npm run build in /backend.

Installation

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.

  1. Clone the repository in some way.
  2. Install mkcert for your OS. On macOS you could use brew install mkcert from any directory, if you have brew.
  3. Make a new directory /backend/cert.
  4. In the /backend/cert directory, run mkcert localhost.
  5. 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 use from /backend/ or /frontend prior to running the npm commands below for both installing and running things. nvm use makes use of the node version listed in .nvmrc. (I'm not sure if this setting survives terminal shutdown.)
  6. Go to /frontend and run npm install.
  7. Go to /backend and run npm install.
  8. Create a .env file in the backend folder (at root level) and paste the distributed token (emailed to course instructors).

Workflows

There are basically three scenarios which are described in the following sections.

A. Running the project with the development server

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.

  1. In /frontend, run npm run dev. This starts a dev server, serving the frontend, right?
  2. 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.)
  3. The app should be viewable in the browser at address https://localhost:3000.

B. Running the backend with fast recompilation using nodemon

This allows for quick iteration on the backend, serving the "compiled" frontend.

  1. In /frontend, npm run build:dev.
  2. In /backend, npm run start:dev.
  3. App viewable at https://localhost:8080/.

C. Making a Docker image of the project and starting a container containing our backend, serving frontend

  1. Install Docker Desktop.
  2. In /frontend, npm run build:dev.
  3. In the project directory, run docker build -t iprogbackend ..
  4. Run docker run -p 3000:3000 iprogbackend.
  5. App viewable at https://localhost:3000/. MVP Archietecture

About

Advanced Interaction Course at KTH

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages