Aufspaltung auf 3 Dateien, aber man muss noch weiter arbeiten (Task: Von better-sqlite3 --> ORM)
19 lines
499 B
TypeScript
19 lines
499 B
TypeScript
import { prisma } from "@/lib/db/prisma"
|
|
import argon2 from 'argon2'
|
|
|
|
export async function initDB() {
|
|
const count = await prisma.user.count()
|
|
|
|
if (count === 0) {
|
|
await prisma.user.create({
|
|
data: {
|
|
username: process.env.ADMIN_USERNAME!,
|
|
password: await argon2.hash(process.env.ADMIN_PASSWORD!),
|
|
role: 'admin',
|
|
name: 'Admin'
|
|
}
|
|
})
|
|
console.log('Created admin user')
|
|
}
|
|
}
|