feat: full site build — Project/Melody schema (Option A), admin CRUD, public sections, uploads, email+SMTP, internal analytics, legal pages, docs
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { hash } from "bcryptjs";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const email = process.env.ADMIN_EMAIL?.trim().toLowerCase();
|
||||
const password = process.env.ADMIN_PASSWORD;
|
||||
|
||||
if (!email || !password) {
|
||||
throw new Error("ADMIN_EMAIL and ADMIN_PASSWORD are required to seed the admin user.");
|
||||
}
|
||||
|
||||
if (password.length < 12) {
|
||||
throw new Error("ADMIN_PASSWORD must be at least 12 characters long.");
|
||||
}
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
try {
|
||||
const passwordHash = await hash(password, 12);
|
||||
|
||||
await prisma.user.upsert({
|
||||
where: { email },
|
||||
update: { password: passwordHash },
|
||||
create: { email, password: passwordHash },
|
||||
});
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
Reference in New Issue
Block a user