From debe0fab2017cc2beeeafa44c11c9d96c48e4ccd Mon Sep 17 00:00:00 2001 From: AidanLoran Date: Wed, 18 Mar 2026 13:40:03 -0500 Subject: [PATCH 1/2] added basic seed.ts file --- docs/useful_links.md | 1 + package-lock.json | 17 ++++++++++++ package.json | 1 + prisma/seed.ts | 64 +++++++++++++++++++++++++++++++++++++------- 4 files changed, 74 insertions(+), 9 deletions(-) diff --git a/docs/useful_links.md b/docs/useful_links.md index bd3cfdc..8dadb3b 100644 --- a/docs/useful_links.md +++ b/docs/useful_links.md @@ -4,5 +4,6 @@ * [Nuxt Docs](https://nuxt.com/docs/4.x/getting-started/introduction) * [Vue Docs](https://vuejs.org/guide/introduction.html) * [BetterAuth MagicLinks](https://better-auth.com/docs/plugins/magic-link) +* [Bruno Docs](https://docs.usebruno.com/introduction/what-is-bruno) * [Previous Form Example](https://docs.google.com/forms/d/e/1FAIpQLSdALlePXxx2Ckgax4R0-wbpRy-Q1TBVQqpySWhT4WOvmHvQ8w/viewform) * [Example API from past EPICS Project](https://github.com/UTDallasEPICS/xuchil/tree/102e94c99e7c052a84839e2523e3fee0034ed69a/src/app/api) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8a96f99..8d6bb31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "name": "epics-template", "hasInstallScript": true, "dependencies": { + "@faker-js/faker": "10.3.0", "@nuxt/image": "2.0.0", "@nuxt/ui": "^4.4.0", "@prisma/adapter-better-sqlite3": "^7.5.0", @@ -1160,6 +1161,22 @@ "node": ">=18" } }, + "node_modules/@faker-js/faker": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-10.3.0.tgz", + "integrity": "sha512-It0Sne6P3szg7JIi6CgKbvTZoMjxBZhcv91ZrqrNuaZQfB5WoqYYbzCUOq89YR+VY8juY9M1vDWmDDa2TzfXCw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/fakerjs" + } + ], + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.13.0 || ^23.5.0 || >=24.0.0", + "npm": ">=10" + } + }, "node_modules/@fastify/accept-negotiator": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@fastify/accept-negotiator/-/accept-negotiator-2.0.1.tgz", diff --git a/package.json b/package.json index 1d5fd08..7544a5b 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "better-auth": "^1.4.7", "better-sqlite3": "^12.6.2", "dotenv": "^17.2.3", + "@faker-js/faker": "10.3.0", "nodemailer": "^7.0.11", "nuxt": "^4.3.1", "pg": "^8.20.0", diff --git a/prisma/seed.ts b/prisma/seed.ts index c892a92..b755720 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,45 +1,91 @@ import { Param } from '@prisma/client/runtime/client' import { prisma } from '../server/utils/prisma' +import { faker } from '@faker-js/faker' async function main() { console.log('Start seeding...') - // 1. Create a User with a Password (Local Auth) + // 1. Create a Parent with a Password (Local Auth) and one child const user1 = await prisma.user.create({ data: { - name: 'Alice Developer', - email: 'alice@a.com', + name: 'Oryx', + email: 'oryx@example.com', emailVerified: true, accounts: { create: { - accountId: 'alice_local_id', + accountId: 'oryx_local_id', providerId: 'credential', // Common for email/password password: 'hashed_password_here', // In a real app, hash this! + students: { + create: { name: 'Crota' }, + }, }, }, }, }) - // 2. Create a User with an OAuth Account (e.g., Google) + // 2. Create a Parent with an OAuth Account (e.g., Google) and multiple children const user2 = await prisma.user.create({ data: { - name: 'Bob Tester', - email: 'bob@b.com', + name: 'Richard Watterson', + email: 'RW123456789@gmail.com', emailVerified: true, accounts: { create: { - accountId: 'bob_google_id', + accountId: 'rich_google_id', providerId: 'google', accessToken: 'mock_access_token', + students: { + create: [ + { name: 'Gumball' }, + { name: 'Darwin' }, + { name: 'Anais' }, + ], + }, }, }, }, }) - console.log({ user1, user2 }) + //create a test admin user + const admin1 = await prisma.user.create({ + data: { + name: 'Gary Admin', + email: 'admin@gary.com', + emailVerified: true, + accounts: { + create: { + accountId: 'gary_admin_id', + providerId: 'credential', + password: 'hashed_password_here', + admin: { create: {} }, + }, + }, + }, + }) + + //create a second test admin user + const admin2 = await prisma.user.create({ + data: { + name: 'Admin Two', + email: 'admin2@example.com', + emailVerified: true, + accounts: { + create: { + accountId: 'admin2_local_id', + providerId: 'credential', + password: 'hashed_password_here', + admin: { create: { settings: {} } }, + }, + }, + }, + }) + + console.log({ user1, user2, admin1, admin2 }) console.log('Seeding finished.') } + main() .then(async () => { await prisma.$disconnect() From 9e35ec7919fd1de91219bce4ea49f5afcecda6e7 Mon Sep 17 00:00:00 2001 From: AidanLoran Date: Wed, 25 Mar 2026 00:35:04 -0500 Subject: [PATCH 2/2] updated seed file with requested changes + added data for testing --- prisma/seed.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prisma/seed.ts b/prisma/seed.ts index b755720..6976c63 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -9,7 +9,7 @@ async function main() { const user1 = await prisma.user.create({ data: { name: 'Oryx', - email: 'oryx@example.com', + email: 'parent1@example.com', emailVerified: true, accounts: { create: { @@ -17,7 +17,7 @@ async function main() { providerId: 'credential', // Common for email/password password: 'hashed_password_here', // In a real app, hash this! students: { - create: { name: 'Crota' }, + create: { name: 'Crota', exp: 5000, settings: { dyslexiaFont: true, fontSize: 1, language: 'en'}} }, }, }, }, @@ -28,7 +28,7 @@ async function main() { const user2 = await prisma.user.create({ data: { name: 'Richard Watterson', - email: 'RW123456789@gmail.com', + email: 'parent2@gmail.com', emailVerified: true, accounts: { create: { @@ -51,7 +51,7 @@ async function main() { const admin1 = await prisma.user.create({ data: { name: 'Gary Admin', - email: 'admin@gary.com', + email: 'admin1@example.com', emailVerified: true, accounts: { create: { @@ -75,7 +75,7 @@ async function main() { accountId: 'admin2_local_id', providerId: 'credential', password: 'hashed_password_here', - admin: { create: { settings: {} } }, + admin: { create: { settings: { dyslexiaFont: true, fontSize: 1, language: 'en' } } } }, }, }, },