{"id":20826770,"url":"https://github.com/cedrickchee/blitzjs-voting","last_synced_at":"2026-05-05T01:31:31.595Z","repository":{"id":43932402,"uuid":"276699614","full_name":"cedrickchee/blitzjs-voting","owner":"cedrickchee","description":"A basic voting application created using Blitz.js","archived":false,"fork":false,"pushed_at":"2023-01-06T10:27:33.000Z","size":2884,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-10T04:56:37.623Z","etag":null,"topics":["blitzjs","educational-project","fullstack-react","nextjs","prisma2","reactjs","typescript"],"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/cedrickchee.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}},"created_at":"2020-07-02T16:48:40.000Z","updated_at":"2025-02-21T15:52:46.000Z","dependencies_parsed_at":"2023-02-05T21:31:44.038Z","dependency_job_id":null,"html_url":"https://github.com/cedrickchee/blitzjs-voting","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cedrickchee/blitzjs-voting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fblitzjs-voting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fblitzjs-voting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fblitzjs-voting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fblitzjs-voting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cedrickchee","download_url":"https://codeload.github.com/cedrickchee/blitzjs-voting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fblitzjs-voting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28071805,"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-12-27T02:00:05.897Z","response_time":58,"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":["blitzjs","educational-project","fullstack-react","nextjs","prisma2","reactjs","typescript"],"created_at":"2024-11-17T23:09:58.516Z","updated_at":"2025-12-27T04:10:03.230Z","avatar_url":"https://github.com/cedrickchee.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Basic Voting App\n\nA basic voting application created using [Blitz.js](https://blitzjs.com/).\n\nBlitz is the fullstack React framework — built on Next.js.\n\n![](docs/images/blitzjs_homepage.png)\n\n![](docs/images/blitzjs_voting_app.png)\n\n---\n\n## Getting Started\n\nInstall Blitz:\n\n```sh\n$ npm i blitz\n\n$ npx blitz -v\nLinux 4.4 | linux-x64 | Node: v12.16.0\n\nblitz: 0.16.0 (global)\nblitz: 0.16.0 (local)\n```\n\nCreate a new app:\n\n```sh\n$ npx blitz new blitz-voting\nYou are using alpha software - if you have any problems, please open an issue here:\n  https://github.com/blitz-js/blitz/issues/new/choose\n\n\nHang tight while we set up your new Blitz app!\n\nCREATE    .babelrc.js\nCREATE    .env\nCREATE    .eslintrc.js\nCREATE    .npmrc\nCREATE    .prettierignore\nCREATE    README.md\nCREATE    app/components/.keep\nCREATE    app/components/ErrorBoundary.tsx\nCREATE    app/layouts/.keep\nCREATE    app/pages/_app.tsx\nCREATE    app/pages/_document.tsx\nCREATE    app/pages/index.tsx\nCREATE    blitz.config.js\nCREATE    db/index.ts\nCREATE    db/migrations/.keep\nCREATE    db/schema.prisma\nCREATE    integrations/.keep\nCREATE    package.json\nCREATE    public/favicon.ico\nCREATE    public/logo.png\nCREATE    tsconfig.json\nCREATE    utils/.keep\nCREATE    .gitignore\n\n✔ Retrieving the freshest of dependencies\n✔ Resolving packages\n✔ Fetching packages\n✔ Linking dependencies\n✔ Building fresh packages\n✔ Formatting your code\n\nYour new Blitz app is ready! Next steps:\n\n   1. cd myapp\n   2. blitz start\n   3. You create new pages by placing components inside app/pages/\n```\n\nStart the dev server.\n\n```sh\n$ npx blitz start\nYou are using alpha software - if you have any problems, please open an issue here:\n  https://github.com/blitz-js/blitz/issues/new/choose\n\n✔ Prepped for launch\nready - started server on http://localhost:3000\nwarn  - You have enabled experimental feature(s).\nwarn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.\n\n\u003e Using \"webpackDevMiddleware\" config function defined in default.\n\u003e Using external babel configuration\n\u003e Location: \"/home/cedric/m/dev/scratch/blitzjs-app/.blitz/caches/dev/.babelrc.js\"\nevent - compiled successfully\nwait  - compiling...\nAttention: Next.js now collects completely anonymous telemetry regarding usage.\nThis information is used to shape Next.js' roadmap and prioritize features.\nYou can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:\nhttps://nextjs.org/telemetry\n\nevent - compiled successfully\n... ... ...\n... ... ...\nevent - build page: /\nwait  - compiling...\nevent - compiled successfully\nevent - build page: /next/dist/pages/_error\nwait  - compiling...\nevent - compiled successfully\n```\n\nOpen [http://localhost:3000](http://localhost:3000) with your browser to see the result.\n\n### Generating content\n\nFirst, we'll generate everything pertaining to the `Question` model:\n\n```sh\n$ npx blitz generate all question text hasMany:choices\n✔ Model for 'question' created successfully:\n\n\u003e model Question {\n\u003e   id        Int      @default(autoincrement()) @id\n\u003e   createdAt DateTime @default(now())\n\u003e   updatedAt DateTime @updatedAt\n\u003e   text      String\n\u003e   choices   Choice[]\n\u003e }\n\nNow run blitz db migrate to add this model to your database\n\nCREATE    app/questions/pages/questions/[questionId]/edit.tsx\nCREATE    app/questions/pages/questions/[questionId].tsx\nCREATE    app/questions/pages/questions/index.tsx\nCREATE    app/questions/pages/questions/new.tsx\nCREATE    app/questions/components/QuestionForm.tsx\nCREATE    app/questions/queries/getQuestion.ts\nCREATE    app/questions/queries/getQuestions.ts\nCREATE    app/questions/mutations/createQuestion.ts\nCREATE    app/questions/mutations/deleteQuestion.ts\nCREATE    app/questions/mutations/updateQuestion.ts\n```\n\nThen, we'll generate the `Choice` model with corresponding queries and mutations:\n\n```sh\n$ npx blitz generate resource choice text votes:int:default[0] belongsTo:question\n✔ Model for 'choice' created successfully:\n\n\u003e model Choice {\n\u003e   id         Int      @default(autoincrement()) @id\n\u003e   createdAt  DateTime @default(now())\n\u003e   updatedAt  DateTime @updatedAt\n\u003e   text       String\n\u003e   votes      Int      @default(0)\n\u003e   question   Question @relation(fields: [questionId], references: [id])\n\u003e   questionId Int\n\u003e }\n\nNow run blitz db migrate to add this model to your database\n\nCREATE    app/choices/queries/getChoice.ts\nCREATE    app/choices/queries/getChoices.ts\nCREATE    app/choices/mutations/createChoice.ts\nCREATE    app/choices/mutations/deleteChoice.ts\nCREATE    app/choices/mutations/updateChoice.ts\n```\n\nNow, we need to migrate our database:\n\n```sh\n$ npx blitz db migrate\n✔ Name of migration … init db\n📼  migrate save --name init db\n\nNew datamodel:\n\n// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ndatasource sqlite {\n  provider = \"sqlite\"\n  url      = \"file:./db.sqlite\"\n}\n\n// SQLite is easy to start with, but if you use Postgres in production\n// you should also use it in development with the following:\n//datasource postgresql {\n//  provider = \"postgresql\"\n//  url      = env(\"DATABASE_URL\")\n//}\n\ngenerator client {\n  provider = \"prisma-client-js\"\n}\n\n\n// --------------------------------------\n\nmodel Question {\n  id        Int      @default(autoincrement()) @id\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  text      String\n  choices   Choice[]\n}\n\nmodel Choice {\n  id         Int      @default(autoincrement()) @id\n  createdAt  DateTime @default(now())\n  updatedAt  DateTime @updatedAt\n  text       String\n  votes      Int      @default(0)\n  question   Question @relation(fields: [questionId], references: [id])\n  questionId Int\n}\n\n\nPrisma Migrate just created your migration 20200702230723-init-db in\n\nmigrations/\n  └─ 20200702230723-init-db/\n    └─ steps.json\n    └─ schema.prisma\n    └─ README.md\n\nRun prisma migrate up --experimental to apply the migration\n\n🏋️  migrate up\n\nDatamodel that will initialize the db:\n\n... ... ...\n... ... ...\n\nChecking the datasource for potential data loss...\n\nDatabase Changes:\n\nMigration               Database actionsStatus\n\n20200702230723-init-db   statements.  Done 🚀\n\nYou can get the detailed db changes with prisma migrate up --experimental --verbose\nOr read about them in the ./migrations/MIGRATION_ID/README.md\n\n🚀    Done with 1 migration in 180ms.\n\n\n✔ Generated Prisma Client to ./node_modules/@prisma/client in 69ms\n\nYou can now start using Prisma Client in your code:\n\n```\n\nimport { PrismaClient } from '@prisma/client'\n// or const { PrismaClient } = require('@prisma/client')\n\nconst prisma = new PrismaClient()\n\n```\n\nExplore the full API: http://pris.ly/d/client\n```\n\n### Playing with the API\n\nNow, let’s hop into the interactive Blitz shell and play around with the free API Blitz gives you.\n\n```sh\n$ npx blitz console\nYou have entered the Blitz console\nTips: - Exit by typing .exit or pressing Ctrl-D\n      - Use your db like this: await db.project.findMany()\n      - Use your queries/mutations like this: await getProjects({})\n✔ Loading your code\n⚡️ \u003e\n```\n\nOnce you’re in the console, explore the Database API:\n\n```sh\n# No questions are in the system yet.\n⚡ \u003e await db.question.findMany()\n[]\n\n# Create a new Question:\n⚡ \u003e let q = await db.question.create({data: {text: \"What's new?\"}})\nundefined\n\n# See the entire object:\n⚡ \u003e q\n{\n  id: 1,\n  createdAt: 2020-07-02T15:16:04.236Z,\n  updatedAt: 2020-07-02T15:16:04.236Z,\n  text: \"What's new?\"\n}\n\n# Or, access individual values on the object:\n⚡ \u003e q.text\n\"What's new?\"\n⚡ \u003e q.createdAt\n2020-07-02T15:16:04.236Z\n\n# Change values by using the update function:\n⚡ \u003e q = await db.question.update({where: {id: 1}, data: {text: \"What's up?\"}})\n{\n  id: 1,\n  createdAt: 2020-07-02T15:16:04.236Z,\n  updatedAt: 2020-07-02T15:17:20.706Z,\n  text: \"What's up?\"\n}\n\n# db.question.findMany() now displays all the questions in the database:\n⚡ \u003e await db.question.findMany()\n[\n  {\n    id: 1,\n    createdAt: 2020-07-02T15:16:04.236Z,\n    updatedAt: 2020-07-02T15:17:20.706Z,\n    text: \"What's up?\"\n  }\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedrickchee%2Fblitzjs-voting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcedrickchee%2Fblitzjs-voting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedrickchee%2Fblitzjs-voting/lists"}