{"id":21254115,"url":"https://github.com/luc-ribeiro/polls-api-node","last_synced_at":"2026-04-13T19:32:07.795Z","repository":{"id":245028255,"uuid":"816865635","full_name":"luc-ribeiro/polls-api-node","owner":"luc-ribeiro","description":"Real-time voting system built with Node.js, WebSockets and Redis.","archived":false,"fork":false,"pushed_at":"2024-06-18T14:46:41.000Z","size":1196,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-01T23:18:24.897Z","etag":null,"topics":["docker","fastify","nodejs","prisma","redis","websockets","zod"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luc-ribeiro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-18T14:46:24.000Z","updated_at":"2024-06-18T22:10:24.000Z","dependencies_parsed_at":"2024-06-19T06:15:16.800Z","dependency_job_id":"90395e0e-b9dd-43cf-b558-3e6146ff47e8","html_url":"https://github.com/luc-ribeiro/polls-api-node","commit_stats":null,"previous_names":["luc-ribeiro/polls-api-node"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luc-ribeiro/polls-api-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-ribeiro%2Fpolls-api-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-ribeiro%2Fpolls-api-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-ribeiro%2Fpolls-api-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-ribeiro%2Fpolls-api-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luc-ribeiro","download_url":"https://codeload.github.com/luc-ribeiro/polls-api-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luc-ribeiro%2Fpolls-api-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31768636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","fastify","nodejs","prisma","redis","websockets","zod"],"created_at":"2024-11-21T03:54:14.644Z","updated_at":"2026-04-13T19:32:07.768Z","avatar_url":"https://github.com/luc-ribeiro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Cover](./.github/cover.png)\n\n# Polls API\n\nA 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.\n\n## Technologies\n\n- Node.js\n- Fastify\n- WebSockets\n- Redis\n- Prisma\n- Docker\n- Zod\n\n## Requisites\n\n- Docker;\n- Node.js;\n\n## Setup\n\n- Clone the repository;\n- Install dependencies (`npm install`);\n- Setup PostgreSQL and Redis (`docker compose up -d`);\n- Copy `.env.example` file (`cp .env.example .env`);\n- Run application (`npm run dev`);\n- Test it! (I personally recommend testing with [Hoppscotch](https://hoppscotch.io/)). \nYou can also test it using the Rest Client extension for VSCode and the ```routes.http``` file. \nBut you will need a API Client to test the WebSocket route.\n\n## HTTP\n\n### POST `/polls`\n\nCreate a new poll.\n\n#### Request body\n\n```json\n{\n  \"title\": \"Qual a melhor linguagem de programação?\",\n  \"options\": [\n    \"JavaScript\",\n    \"Java\",\n    \"PHP\",\n    \"C#\"\n  ]\n}\n```\n\n#### Response body\n\n```json\n{\n  \"pollId\": \"194cef63-2ccf-46a3-aad1-aa94b2bc89b0\"\n}\n```\n\n### GET `/polls/:pollId`\n\nReturn data from a single poll.\n\n#### Response body\n\n```json\n{\n\t\"poll\": {\n\t\t\"id\": \"e4365599-0205-4429-9808-ea1f94062a5f\",\n\t\t\"title\": \"Qual a melhor linguagem de programação?\",\n\t\t\"options\": [\n\t\t\t{\n\t\t\t\t\"id\": \"4af3fca1-91dc-4c2d-b6aa-897ad5042c84\",\n\t\t\t\t\"title\": \"JavaScript\",\n\t\t\t\t\"score\": 1\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"id\": \"780b8e25-a40e-4301-ab32-77ebf8c79da8\",\n\t\t\t\t\"title\": \"Java\",\n\t\t\t\t\"score\": 0\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"id\": \"539fa272-152b-478f-9f53-8472cddb7491\",\n\t\t\t\t\"title\": \"PHP\",\n\t\t\t\t\"score\": 0\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"id\": \"ca1d4af3-347a-4d77-b08b-528b181fe80e\",\n\t\t\t\t\"title\": \"C#\",\n\t\t\t\t\"score\": 0\n\t\t\t}\n\t\t]\n\t}\n}\n```\n\n### POST `/polls/:pollId/votes`\n\nAdd a vote to specific poll.\n\n#### Request body\n\n```json\n{\n  \"pollOptionId\": \"31cca9dc-15da-44d4-ad7f-12b86610fe98\"\n}\n```\n\n## WebSockets\n\n### ws `/polls/:pollId/results`\n\n#### Message\n\n```json\n{\n  \"pollOptionId\": \"da9601cc-0b58-4395-8865-113cbdc42089\",\n  \"votes\": 2\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluc-ribeiro%2Fpolls-api-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluc-ribeiro%2Fpolls-api-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluc-ribeiro%2Fpolls-api-node/lists"}