Master API, Admin UI, Go media-node, Docker/Dokploy deploy configs. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
904 B
TypeScript
35 lines
904 B
TypeScript
import "dotenv/config";
|
|
import { prisma } from "../src/database/client";
|
|
import { hashPassword } from "../src/security/crypto";
|
|
|
|
async function seed() {
|
|
const email = process.env.ADMIN_EMAIL ?? "admin@localhost";
|
|
const password = process.env.ADMIN_PASSWORD ?? "changeme123";
|
|
|
|
const existing = await prisma.user.findUnique({ where: { email } });
|
|
if (!existing) {
|
|
await prisma.user.create({
|
|
data: {
|
|
email,
|
|
passwordHash: await hashPassword(password),
|
|
name: "Admin",
|
|
},
|
|
});
|
|
console.log(`Created admin: ${email}`);
|
|
}
|
|
|
|
const locations = ["Main", "Remote-01"];
|
|
for (const name of locations) {
|
|
await prisma.location.upsert({
|
|
where: { name },
|
|
create: { name, priority: name === "Main" ? 10 : 0 },
|
|
update: {},
|
|
});
|
|
}
|
|
|
|
console.log("Seed completed");
|
|
}
|
|
|
|
seed()
|
|
.catch(console.error)
|
|
.finally(() => prisma.$disconnect());
|