Challenge to read game log file, manipulate the file data and create API to show all game data
First, you need to install docker and docker-compose for server and database or you can run with node to start server
Clone the repository
git clone https://github.com/fuchien/luizalabs.git
Run docker-compose to start the server and database
docker-compose up --build
npm install
Run postgres database
docker run --name luizalabs -p 5432:5432 -e POSTGRES_DBNAME=luizalabs -e POSTGRES_USER=luizalabs -e POSTGRES_PASS=luizalabs -d -t kartoza/postgis
Create table by migration
// With docker
docker exec luizalabs npx sequelize db:migrate
// With node
npx sequelize db:migrate
Open your favourite browser, and enter
http://localhost:3001
You need click file button, and put the file located in
/backend_test/src/public/games.log
The backend will receive the file, save file in uploads folder, get the file data and manipulate each line to create an Game object, then save all games objects in database. After, you can get games or game data by API.
To test the application, only need to run script
npm run test
You will have each test in terminal and coverage for each file
Returns all games log object
Input: path parameter
/logs
params | required | type |
---|---|---|
logs |
true | string |
Output:
[
{
game_id: 1,
total_kills: 0,
kills: {},
players: []
},
...
]
Returns the game log object
Input: path parameter
/logs/:id
params | required | type |
---|---|---|
logs |
true | string |
:id |
true | string |
Output:
{
game_id: 1,
total_kills: 0,
kills: {},
players: []
}