Skip to content

fuchien/luizalabs

Repository files navigation

Luizalabs backend test

Challenge to read game log file, manipulate the file data and create API to show all game data

Developing

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

Docker

Run docker-compose to start the server and database

docker-compose up --build

Node

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


For both, you need create table running db:migrate

// 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

Description and solution

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.


Testing

To test the application, only need to run script

npm run test

You will have each test in terminal and coverage for each file


Endpoint list:


getAllLogs

Returns all games log object

Input: path parameter

/logs
params required type
logs true string

Output:

[
  {
    game_id: 1,
    total_kills: 0,
    kills: {},
    players: []
  },
  ...
]

getLogById

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: []
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published