zerobyte/app/server/modules/lifecycle/bootstrap.ts
Nicolas Meienberger 436a63a4b4
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / checks (push) Has been cancelled
Release Workflow / e2e-tests (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
refactor: add nitro bootstrap plugin to ensure app is started before first call
2026-02-13 20:20:16 +01:00

26 lines
574 B
TypeScript

import * as schema from "../../db/schema";
import { runDbMigrations, setSchema } from "../../db/db";
import { runMigrations } from "./migrations";
import { startup } from "./startup";
let bootstrapPromise: Promise<void> | undefined;
const runBootstrap = async () => {
setSchema(schema);
runDbMigrations();
await runMigrations();
await startup();
};
export const bootstrapApplication = async () => {
if (!bootstrapPromise) {
bootstrapPromise = runBootstrap();
}
try {
await bootstrapPromise;
} catch (err) {
bootstrapPromise = undefined;
throw err;
}
};