init app
This commit is contained in:
28
prisma/seed.ts
Normal file
28
prisma/seed.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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();
|
||||
});
|
||||
Reference in New Issue
Block a user