Code Monkey home page Code Monkey logo

devquiz-backend-nodejs's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.