feat: run tasks at startup

This commit is contained in:
Huskydog9988
2025-04-23 21:14:16 -04:00
parent 31ad8505b7
commit f1f19c8263
5 changed files with 15 additions and 4 deletions

View File

@@ -0,0 +1,27 @@
import prisma from "~/server/internal/db/database";
export default defineNitroPlugin(async (_nitro) => {
const userCount = await prisma.user.count({
where: { id: { not: "system" } },
});
if (userCount != 0) return;
// This setup runs every time the server sets up,
// but has not been configured
// so it should be in-place
// Create admin invitation
await prisma.invitation.upsert({
where: {
id: "admin",
},
create: {
id: "admin",
isAdmin: true,
expires: new Date("4096-01-01"),
},
update: {
isAdmin: true,
},
});
});