diff --git a/nuxt.config.ts b/nuxt.config.ts index 6c5eba2..1a3ac9c 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -19,25 +19,14 @@ export default defineNuxtConfig({ }, // Modules - modules: [ - // Image Handling and Optimization - '@nuxt/image', - // Performance Optimization - '@nuxtjs/critters', - 'nuxt-delay-hydration', - // Content Management - '@nuxt/content', - // Utility Functions - '@vueuse/nuxt', - // Fonts and Typography - '@nuxtjs/fontaine', - '@nuxtjs/google-fonts', - '@nuxtjs/tailwindcss', - // SEO and Crawling - '@nuxtjs/robots', - // Icons - 'nuxt-icon', - ], + modules: [// Image Handling and Optimization + '@nuxt/image', // Performance Optimization + '@nuxtjs/critters', 'nuxt-delay-hydration', // Content Management + '@nuxt/content', // Utility Functions + '@vueuse/nuxt', // Fonts and Typography + '@nuxtjs/fontaine', '@nuxtjs/google-fonts', '@nuxtjs/tailwindcss', // SEO and Crawling + '@nuxtjs/robots', // Icons + 'nuxt-icon', "nuxt-build-cache"], // Module Options content: { @@ -117,4 +106,4 @@ export default defineNuxtConfig({ }, }, }, -}) +}) \ No newline at end of file diff --git a/package.json b/package.json index 6690941..1742d47 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "lodash-es": "^4.17.21", "mysql2": "^3.9.1", "nuxt": "^3.10.0", + "nuxt-build-cache": "^0.1.1", "prettier": "^3.2.4", "prettier-plugin-tailwindcss": "^0.5.11", "ts-node": "^10.9.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e112e15..4a276fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,6 +82,9 @@ devDependencies: nuxt: specifier: ^3.10.0 version: 3.10.0(@planetscale/database@1.14.0)(@types/node@20.11.13)(typescript@5.3.3)(vite@5.0.12)(vue-tsc@1.8.27) + nuxt-build-cache: + specifier: ^0.1.1 + version: 0.1.1 prettier: specifier: ^3.2.4 version: 3.2.4 @@ -6487,6 +6490,10 @@ packages: engines: {node: ^14 || ^16 || >=18} hasBin: true + /nanotar@0.1.1: + resolution: {integrity: sha512-AiJsGsSF3O0havL1BydvI4+wR76sKT+okKRwWIaK96cZUnXqH0uNBOsHlbwZq3+m2BR1VKqHDVudl3gO4mYjpQ==} + dev: true + /negotiator@0.6.3: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'} @@ -6759,6 +6766,22 @@ packages: optionalDependencies: fsevents: 2.3.3 + /nuxt-build-cache@0.1.1: + resolution: {integrity: sha512-jn3iSYR1gdg/eK1HkgERauUu1pJSUzwJ2Oi0qOwDGrYSlO4mycJ62L0cPtpmBR2Ah/iSrMbjLOxfMMWguVEHQA==} + dependencies: + '@nuxt/kit': 3.10.1 + consola: 3.2.3 + globby: 14.0.0 + nanotar: 0.1.1 + nypm: 0.3.6 + ohash: 1.1.3 + pkg-types: 1.0.3 + std-env: 3.7.0 + transitivePeerDependencies: + - rollup + - supports-color + dev: true + /nuxt-delay-hydration@1.3.3: resolution: {integrity: sha512-M0PR0s8M7ugUpq7hQbMZ4A5DpkIGoCeeXM5mSJyHHi4yx7M5zep2zNweA/M1rMN+RIE3O/PlxuWYzZK73GiVMA==} dependencies: diff --git a/prisma/migrations/20231122104738_init/migration.sql b/prisma/migrations/20231122104738_init/migration.sql deleted file mode 100644 index a893af4..0000000 --- a/prisma/migrations/20231122104738_init/migration.sql +++ /dev/null @@ -1,127 +0,0 @@ --- CreateTable -CREATE TABLE "Section" ( - "id" UUID NOT NULL DEFAULT gen_random_uuid(), - "msgid" VARCHAR(100) NOT NULL, - "iconName" VARCHAR(100) NOT NULL, - - CONSTRAINT "Section_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Question" ( - "id" UUID NOT NULL DEFAULT gen_random_uuid(), - "msgid" VARCHAR(100) NOT NULL, - "isMultipleChoice" BOOLEAN NOT NULL DEFAULT false, - "isMediaQuestion" BOOLEAN NOT NULL DEFAULT false, - "additionalInfo" TEXT, - "sectionId" UUID NOT NULL, - - CONSTRAINT "Question_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Answer" ( - "id" UUID NOT NULL DEFAULT gen_random_uuid(), - "msgid" VARCHAR(100) NOT NULL, - "mediaSourcePath" TEXT, - "questionId" UUID NOT NULL, - - CONSTRAINT "Answer_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Distribution" ( - "id" UUID NOT NULL DEFAULT gen_random_uuid(), - "name" VARCHAR(200) NOT NULL, - "identifier" VARCHAR(200) NOT NULL, - "fgColor" VARCHAR(100), - "bgColor" VARCHAR(100), - "logo" TEXT, - "url" TEXT, - - CONSTRAINT "Distribution_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Result" ( - "id" UUID NOT NULL DEFAULT gen_random_uuid(), - "ip" INET, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Result_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "_BlockedAnswer" ( - "A" UUID NOT NULL, - "B" UUID NOT NULL -); - --- CreateTable -CREATE TABLE "_SelectedAnswers" ( - "A" UUID NOT NULL, - "B" UUID NOT NULL -); - --- CreateTable -CREATE TABLE "_ImportantAnswers" ( - "A" UUID NOT NULL, - "B" UUID NOT NULL -); - --- CreateIndex -CREATE UNIQUE INDEX "Section_msgid_key" ON "Section"("msgid"); - --- CreateIndex -CREATE UNIQUE INDEX "Question_msgid_key" ON "Question"("msgid"); - --- CreateIndex -CREATE UNIQUE INDEX "Question_sectionId_key" ON "Question"("sectionId"); - --- CreateIndex -CREATE UNIQUE INDEX "Answer_msgid_key" ON "Answer"("msgid"); - --- CreateIndex -CREATE UNIQUE INDEX "Distribution_identifier_key" ON "Distribution"("identifier"); - --- CreateIndex -CREATE UNIQUE INDEX "_BlockedAnswer_AB_unique" ON "_BlockedAnswer"("A", "B"); - --- CreateIndex -CREATE INDEX "_BlockedAnswer_B_index" ON "_BlockedAnswer"("B"); - --- CreateIndex -CREATE UNIQUE INDEX "_SelectedAnswers_AB_unique" ON "_SelectedAnswers"("A", "B"); - --- CreateIndex -CREATE INDEX "_SelectedAnswers_B_index" ON "_SelectedAnswers"("B"); - --- CreateIndex -CREATE UNIQUE INDEX "_ImportantAnswers_AB_unique" ON "_ImportantAnswers"("A", "B"); - --- CreateIndex -CREATE INDEX "_ImportantAnswers_B_index" ON "_ImportantAnswers"("B"); - --- AddForeignKey -ALTER TABLE "Question" ADD CONSTRAINT "Question_sectionId_fkey" FOREIGN KEY ("sectionId") REFERENCES "Section"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Answer" ADD CONSTRAINT "Answer_questionId_fkey" FOREIGN KEY ("questionId") REFERENCES "Question"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_BlockedAnswer" ADD CONSTRAINT "_BlockedAnswer_A_fkey" FOREIGN KEY ("A") REFERENCES "Answer"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_BlockedAnswer" ADD CONSTRAINT "_BlockedAnswer_B_fkey" FOREIGN KEY ("B") REFERENCES "Answer"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_SelectedAnswers" ADD CONSTRAINT "_SelectedAnswers_A_fkey" FOREIGN KEY ("A") REFERENCES "Answer"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_SelectedAnswers" ADD CONSTRAINT "_SelectedAnswers_B_fkey" FOREIGN KEY ("B") REFERENCES "Result"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_ImportantAnswers" ADD CONSTRAINT "_ImportantAnswers_A_fkey" FOREIGN KEY ("A") REFERENCES "Answer"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_ImportantAnswers" ADD CONSTRAINT "_ImportantAnswers_B_fkey" FOREIGN KEY ("B") REFERENCES "Result"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml deleted file mode 100644 index fbffa92..0000000 --- a/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "postgresql" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma deleted file mode 100644 index 9acd944..0000000 --- a/prisma/schema.prisma +++ /dev/null @@ -1,60 +0,0 @@ -// This is your updated Prisma schema file - -generator client { - provider = "prisma-client-js" -} - -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") - directUrl = env("DIRECT_URL") -} - -model Section { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - msgid String @unique @db.VarChar(100) - iconName String @db.VarChar(100) - question Question? -} - -model Question { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - msgid String @unique @db.VarChar(100) - isMultipleChoice Boolean @default(false) - isMediaQuestion Boolean @default(false) - additionalInfo String? - answers Answer[] - section Section @relation(fields: [sectionId], references: [id], onDelete: Cascade) - sectionId String @unique @db.Uuid -} - -model Answer { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - msgid String @unique @db.VarChar(100) - mediaSourcePath String? - question Question @relation(fields: [questionId], references: [id], onDelete: Cascade) - questionId String @db.Uuid - blocks Answer[] @relation("BlockedAnswer") - blockedBy Answer[] @relation("BlockedAnswer") - // results where answer has been selected, and marked important, respectively. - resultSelectedAnswers Result[] @relation("SelectedAnswers") - resultImportantAnswers Result[] @relation("ImportantAnswers") -} - -model Distribution { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - name String @db.VarChar(200) - identifier String @unique @db.VarChar(200) - fgColor String? @db.VarChar(100) - bgColor String? @db.VarChar(100) - logo String? - url String? -} - -model Result { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - ip String? @db.Inet - createdAt DateTime @default(now()) - selectedAnswers Answer[] @relation("SelectedAnswers") - importantAnswers Answer[] @relation("ImportantAnswers") -} diff --git a/prisma/distros.json b/seed-data/distros.json similarity index 100% rename from prisma/distros.json rename to seed-data/distros.json diff --git a/prisma/question-data.json b/seed-data/question-data.json similarity index 100% rename from prisma/question-data.json rename to seed-data/question-data.json diff --git a/prisma/sections.json b/seed-data/sections.json similarity index 100% rename from prisma/sections.json rename to seed-data/sections.json diff --git a/src/server/database/seed.ts b/src/server/database/seed.ts index 7fffe12..8f30a75 100644 --- a/src/server/database/seed.ts +++ b/src/server/database/seed.ts @@ -5,9 +5,9 @@ import * as question from '~/server/crud/question' import * as section from '~/server/crud/section' import { getDb } from '~/server/database/db' import { distributions } from '~/server/database/schema/distributions' -import distros from '~~/prisma/distros.json' -import { default as questionData } from '~~/prisma/question-data.json' -import { default as sectionData } from '~~/prisma/sections.json' +import distros from '~~/seed-data/distros.json' +import questionData from '~~/seed-data/question-data.json' +import sectionData from '~~/seed-data/sections.json' async function main() { const databaseUrl = process.env.DATABASE_URL