2023-11-06 02:57:00 +01:00
|
|
|
import { defineEventHandler } from "h3";
|
2023-11-08 05:35:48 +01:00
|
|
|
import { database } from "../utils/database";
|
2023-06-14 13:00:19 +02:00
|
|
|
|
|
|
|
export async function isFirstRun() {
|
2023-11-08 05:35:48 +01:00
|
|
|
try {
|
|
|
|
const numberOfUsers = await database.user.count();
|
|
|
|
return numberOfUsers === 0;
|
|
|
|
} catch {
|
|
|
|
// We could fall here if the database is not initialized
|
|
|
|
return true;
|
|
|
|
}
|
2023-06-14 13:00:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export default defineEventHandler((e) => {
|
|
|
|
return isFirstRun();
|
|
|
|
});
|