{"id":28152489,"url":"https://github.com/dcdms/polls-api","last_synced_at":"2025-09-10T21:32:14.344Z","repository":{"id":221447934,"uuid":"754403015","full_name":"dcdms/polls-api","owner":"dcdms","description":"API to create and vote in polls with real-time updates via websockets","archived":false,"fork":false,"pushed_at":"2024-02-08T02:34:19.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T05:11:35.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dcdms.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}},"created_at":"2024-02-08T01:05:04.000Z","updated_at":"2024-09-19T01:33:35.000Z","dependencies_parsed_at":"2024-02-08T02:33:06.188Z","dependency_job_id":"35775be3-94c8-4c66-8061-f4a4eb6b1640","html_url":"https://github.com/dcdms/polls-api","commit_stats":null,"previous_names":["davi-costa-de-melo/polls-api","dcdm3g/polls-api","dcdms/polls-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dcdms/polls-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcdms%2Fpolls-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcdms%2Fpolls-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcdms%2Fpolls-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcdms%2Fpolls-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcdms","download_url":"https://codeload.github.com/dcdms/polls-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcdms%2Fpolls-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274528013,"owners_count":25302320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-05-15T05:11:34.977Z","updated_at":"2025-09-10T21:32:14.253Z","avatar_url":"https://github.com/dcdms.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polls API\n\nThis API allows clients to create polls, vote on them and read their votes. Additionally, clients can also call a websocket route to receive new votes in a poll in real time.\n\nThis application was built during [NLW Expert](https://rocketseat.com.br/eventos/nlw) promoted by [Rocketseat](https://rocketseat.com.br).\n\n## Routes\n\nIn more details, the API routes are:\n\n```ts\ninterface CreatePollBody {\n  title: string\n  options: string[]\n}\n\nPOST('/polls', (...) =\u003e {\n  // Creates a new poll with the title and\n  // options received from the request body\n})\n\ninterface CreateVoteBody {\n  pollOptionId: string\n}\n\nPOST('/polls/:pollId/votes', (...) =\u003e {\n  // Creates a new vote in the poll with the \n  // id received from the route parameters\n  // in the option with the id received from \n  // the request body.\n})\n\ninterface GetPollReturnData {\n  id: string\n  title: string\n  options: {\n    id: string\n    title: string\n    votes: number\n  }[]\n}\n\nGET('/polls/:id', (...) =\u003e {\n  // Returns the poll with the id received\n  // from the route parameters.\n})\n\nWS('/polls/:pollId/results', (...) =\u003e {\n  // Creates a connection with the client\n  // and notifies it whenever there is a \n  // new vote in the poll with the id \n  // received from the route parameters.\n})\n```\n\n## Running\n\nRun the following commands to run this application on your machine:\n\n```bash\n# Clone this repository\ngit clone https://github.com/davi-costa-de-melo/polls-api\n\n# Go to the application directory\ncd polls-api\n\n# Install dependencies\npnpm i\n\n# Initialize PostgreSQL and Redis services\ndocker-compose up -d\n\n# Set the environment variables\ncp .env.example .env\n\n# Run migrations\npnpm prisma migrate dev\n\n# Start server\npnpm dev\n```\n\n## Technologies Used\n\n- [Fastify](https://fastify.io) - NodeJS framework\n- [Prisma](https://prisma.io) - Migrations generator and database client\n- [Redis](https://redis.io) - Storage of poll vote rankings\n- [Docker](https://docker.com) - Redis and PostgreSQL containers\n- [TypeScript](https://typescriptlang.org) - Programming language\n- [Zod](https://zod.dev) - Validation","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcdms%2Fpolls-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcdms%2Fpolls-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcdms%2Fpolls-api/lists"}