first commit

This commit is contained in:
2026-04-14 19:44:21 -05:00
commit 068576cf4b
36 changed files with 13680 additions and 0 deletions

52
prisma/seed.mjs Normal file
View File

@@ -0,0 +1,52 @@
import { PrismaClient } from '@prisma/client'
import { randomBytes, scryptSync } from 'node:crypto'
const prisma = new PrismaClient()
function hashPassword(password) {
const salt = randomBytes(16).toString('base64url')
const derivedKey = scryptSync(password, salt, 64).toString('base64url')
return `scrypt$${salt}$${derivedKey}`
}
async function upsertUser({ email, password }) {
const passwordHash = hashPassword(password)
await prisma.user.upsert({
where: { email },
update: {
passwordHash
},
create: {
email,
passwordHash
}
})
}
async function main() {
await upsertUser({
email: 'student@example.com',
password: 'student123'
})
await upsertUser({
email: 'admin@example.com',
password: 'admin123'
})
await upsertUser({
email: 'limited@example.com',
password: 'limited123'
})
}
main()
.then(async () => {
await prisma.$disconnect()
})
.catch(async (error) => {
console.error('Seed failed:', error)
await prisma.$disconnect()
process.exit(1)
})