WorkshopTasker/server/api/firstRun.get.ts
Wroclaw eebf25198d Replace mysql2 with prisma
also I updated packages,
and properly typed api input
a lot of time was spent, I don't remeber what really I did x3
but everything was related to replacing mysql2 with prisma
2023-11-08 05:36:12 +01:00

16 lines
387 B
TypeScript

import { defineEventHandler } from "h3";
import { database } from "../utils/database";
export async function isFirstRun() {
try {
const numberOfUsers = await database.user.count();
return numberOfUsers === 0;
} catch {
// We could fall here if the database is not initialized
return true;
}
}
export default defineEventHandler((e) => {
return isFirstRun();
});