This project based on this assignment.
- Run
npm i
in terminal
- Run
npm run build
- this will build both the typescript intodist
file and will build the docker image for the database - Run
npm run start:db
- for starting a docker container of the database - Run
npm run start:server
on a different terminal - for starting a local server
You can access the local DB by running
npm run debug:db
, and in the opened terminal type inmysql -u root -p
and then type the password for root (password
).
Local server runs on port 3001
.
Unfortunately I didn't make it to the testing phase.
I usually try to create tests against a dockerized db in TDD style, but I didn't have time for the setup of the test environment. :)
Anyway, there are some very basic unit tests that can be run with npm run test
. I also made builders which are in __tests__
- these are used in integration tests which I didn't get to do.
API request and response types are found in types folder, specifically in here.
URL: /game-sessions
.
Returns the list of game sessions (name and id).
URL: /game-sessions/:id
.
Path parameter:
id
- game session id
Returns a game session by id, including its measurements.
URL: /game-sessions
.
Payload:
gameSession
- the game session input (as in the example given in the task description)
Takes in the input, calculates the measurements' grades and accumulated scores, stores the information in the database (details about the stored data below).
Returns the game session id.
Database is MySQL.
The database is consisted of two tables: one for the game session records and one for the measurement records.
The following chart describes the database: