Download src/lib/seed.ts from sarransh/task-manager-system: direct link, hf CLI and curl.
- Browser
- Download file 827 Bytes
-
https://huggingface.co/spaces/sarransh/task-manager-system/resolve/main/src/lib/seed.ts
- Command line
-
hf download hf://spaces/sarransh/task-manager-system/src/lib/seed.ts
-
curl -L -o seed.ts https://huggingface.co/spaces/sarransh/task-manager-system/resolve/main/src/lib/seed.ts
827 Bytes
| import { prisma } from "@/lib/prisma"; | |
| import bcrypt from "bcryptjs"; | |
| // Ensure at least one admin exists | |
| export async function seedDefaults() { | |
| const adminEmail = process.env.ADMIN_EMAIL || "admin@example.com"; | |
| const existingAdmin = await prisma.user.findUnique({ | |
| where: { email: adminEmail } | |
| }); | |
| if (!existingAdmin) { | |
| const hashedPassword = await bcrypt.hash(process.env.ADMIN_PASSWORD || "admin", 10); | |
| await prisma.user.create({ | |
| data: { | |
| email: adminEmail, | |
| passwordHash: hashedPassword, | |
| name: "System Admin", | |
| username: "admin", | |
| role: "ADMIN", | |
| designation: "Super User" | |
| } | |
| }); | |
| console.log("Seeded Admin user."); | |
| } | |
| } | |