mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-02-19 23:34:53 -05:00
* refactor: add nitro bootstrap plugin to ensure app is started before first call * refactor(bootstrap): avoid duplicate event firing * refactor: extract common setup in initModule function * refactor: remove proxy pattern for db and auth Since we migrated away from rr this is not needed anymore as the bundler correctly split chunks
25 lines
500 B
TypeScript
25 lines
500 B
TypeScript
import { runDbMigrations } from "../../db/db";
|
|
import { runMigrations } from "./migrations";
|
|
import { startup } from "./startup";
|
|
|
|
let bootstrapPromise: Promise<void> | undefined;
|
|
|
|
const runBootstrap = async () => {
|
|
runDbMigrations();
|
|
await runMigrations();
|
|
await startup();
|
|
};
|
|
|
|
export const bootstrapApplication = async () => {
|
|
if (!bootstrapPromise) {
|
|
bootstrapPromise = runBootstrap();
|
|
}
|
|
|
|
try {
|
|
await bootstrapPromise;
|
|
} catch (err) {
|
|
bootstrapPromise = undefined;
|
|
throw err;
|
|
}
|
|
};
|