This commit is contained in:
2025-07-19 12:21:46 +02:00
parent 12822dfdbf
commit 2e7957d0a0
86 changed files with 25573 additions and 0 deletions

28
scripts/createAdmin.js Normal file
View File

@@ -0,0 +1,28 @@
const { PrismaClient } = require('../generated/prisma');
const bcrypt = require('bcryptjs');
const prisma = new PrismaClient();
async function createAdmin() {
try {
const username = 'admin';
const password = 'admin123';
const hash = await bcrypt.hash(password, 10);
const admin = await prisma.adminUser.create({
data: { username, passwordHash: hash },
});
console.log('Admin created successfully:', { id: admin.id, username: admin.username });
} catch (err) {
if (err.code === 'P2002') {
console.log('Admin already exists');
} else {
console.error('Error creating admin:', err);
}
} finally {
await prisma.$disconnect();
}
}
createAdmin();