stremio/apps/master-api/prisma/seed.ts
Jos Vooges | STH a5c6fd5fe4 Initial commit: Distributed Stremio Media Cluster V1
Master API, Admin UI, Go media-node, Docker/Dokploy deploy configs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 00:17:04 +02:00

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());