Skip to content

Polls is a backend API project created using Nodejs during NLW Expert - 14 edition with Rocketseat.

Notifications You must be signed in to change notification settings

ocarlosbarros/polls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polls

🚧 🚧 README under construction 🚧 🚧

ocarlosbarros - Polls

📋 Table of Contents

👉 About project

A real-time voting system where users can create a poll and other users can cast their votes. The system generates a ranking among the options and updates the votes in real-time.

back to top

✔️ Features

HTTP

POST /polls

Create a new poll.

Request body

{
  "title": "Qual a melhor linguagem de programação?",
  "options": [
    "JavaScript",
    "Java",
    "PHP",
    "C#"
  ]
}

Response body

{
  "pollId": "194cef63-2ccf-46a3-aad1-aa94b2bc89b0"
}

back to top

GET /polls/:pollId

Return data from a single poll.

Response body

{
	"poll": {
		"id": "e4365599-0205-4429-9808-ea1f94062a5f",
		"title": "Qual a melhor linguagem de programação?",
		"options": [
			{
				"id": "4af3fca1-91dc-4c2d-b6aa-897ad5042c84",
				"title": "JavaScript",
				"score": 1
			},
			{
				"id": "780b8e25-a40e-4301-ab32-77ebf8c79da8",
				"title": "Java",
				"score": 0
			},
			{
				"id": "539fa272-152b-478f-9f53-8472cddb7491",
				"title": "PHP",
				"score": 0
			},
			{
				"id": "ca1d4af3-347a-4d77-b08b-528b181fe80e",
				"title": "C#",
				"score": 0
			}
		]
	}
}

back to top

POST /polls/:pollId/votes

Add a vote to specific poll.

Request body

{
  "pollOptionId": "31cca9dc-15da-44d4-ad7f-12b86610fe98"
}

back to top

WebSockets

ws /polls/:pollId/results

Message

{
  "pollOptionId": "da9601cc-0b58-4395-8865-113cbdc42089",
  "votes": 2
}

back to top

🛠️ Built with

This project was built with Nodejs.

  • 💻 Technologies and Libs

    • Nodejs
    • @types/node
    • Typescript
    • TSX
    • Prisma
    • Fastify
    • Fastify/cookie
    • Fastify/websocket
    • Zod
    • IORedis
    • Docker
    • Postgress
    • Redis

back to top

🚀 Getting Started

These instructions will allow you to get a copy of the project on your local machine for development and testing purposes.

⚠️ Requirements

  • Docker;
  • Node.js;

Before starting, you need to have Node.js and Docker installed on your computer. You can download them at https://nodejs.org and https://www.docker.com/get-started/.

Check that the installations were successful by running the command in terminal.

node -v & docker -v

back to top

⚙️ Run Application

  1. Clone project
git clone git@github.com:ocarlosbarros/pools.git
  1. Access project folder
cd pools
  1. Install dependencies
npm install
  1. Run project

    • Run the docker compose script to up the database containers
    • Run application
docker compose up -d
npm run dev

back to top

🧪 Tests

To run tests, run the following command

back to top

📄 License

Project Name is MIT Licensed. See LICENSE.md for more information.


back to top

:octocat: Developers


Carlos Barros

Developed with 💜 by Carlos Barros

back to top

About

Polls is a backend API project created using Nodejs during NLW Expert - 14 edition with Rocketseat.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published