Skip to content

DreamteamApps/devquiz-backend-nodejs

Repository files navigation

Online at

To run

1 - create .env file or set your environment variables as in the .env.example

2 - npm run setup (to run migrations and seeds)

To debug

1 - npm run dev (to run migrations and seeds)

Database

SQLite - To use SQLITE change DB_CONNECTION in .env or environment variables to sqlite

MySql - To use MySql change DB_CONNECTION in .env or environment variables to mysql

Match sequence diagram

Match sequence diagram

Socket events

(client) join-match

{
	"userId" : 1,
	"matchId" : 1
}

(server) player-joined

{
	"owner": {
		"id": 1,
		"login": "githubuser",
		"name": "Primeiro segundo nome",
		"avatar": "http://imagem.png",
	"	repos": 0
},
	opponent: {
		"id": 1,
		"login": "githubuser",
		"name": "Primeiro segundo nome",
		"avatar": "http://imagem.png",
		"repos": 0
	}
}

(client) set-ready

{
	"userId" : 1,
	"matchId" : 1
}

(server) player-ready

{
	"userId": 1
}

(server) match-start

(server) match-start-round

{
	"currentRound": 1,
	"totalRound": 5
}

(server) match-start-question

{
	"id": 0,
	"title": "Pergunta 01",
	"image": "http://image.png",
	"answer1": "Resposta 01",
	"answer2": "Resposta 02",
	"answer3": "Resposta 03",
	"answer4": "Resposta 04",
}

(server) match-countdown

{
	"seconds": 10
}

(client) answer-question

{
	"userId" : 1,
	"matchId" : 1,
	"questionId": 1,
	"answer":  1,
  "time":  5
}

(server) match-round-end

{
	"owner" : {
		"id": 1,
		"answer": 1,
		"score": 10
	},
	"opponent" : {
		"id": 2,
		"answer": 3,
		"score": 0
	},
	"correctAnswer": 1
}

(server) match-end

{
	"totalScore": 50,
	"wins": 5,
	"losses": 1
}

Test client

cd test_client

npm install

node client.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published