29 lines
635 B
TypeScript
29 lines
635 B
TypeScript
import { PrismaClient } from "@prisma/client";
|
|
import { hashPassword } from "../lib/crypto";
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const email = process.env.ADMIN_EMAIL ?? "jaradatgamer@gmail.com";
|
|
const password = process.env.ADMIN_PASSWORD ?? "admin123";
|
|
|
|
const passwordHash = await hashPassword(password);
|
|
|
|
await prisma.user.upsert({
|
|
where: { email },
|
|
update: {},
|
|
create: { email, passwordHash },
|
|
});
|
|
|
|
console.log(`Seeded admin user: ${email}`);
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|