refactor: add nitro bootstrap plugin to ensure app is started before first call

This commit is contained in:
Nicolas Meienberger 2026-02-13 20:20:16 +01:00
parent 297e14ebb2
commit df34dc7597

View file

@ -1,23 +1,16 @@
import { logger } from "./server/utils/logger";
import { shutdown } from "./server/modules/lifecycle/shutdown";
import { runCLI } from "./server/cli";
import { bootstrapApplication } from "./server/modules/lifecycle/bootstrap";
import { createStartHandler, defaultStreamHandler, defineHandlerCallback } from "@tanstack/react-start/server";
import { createServerEntry } from "@tanstack/react-start/server-entry";
import { initAuth } from "~/server/lib/auth";
import { setSchema } from "./server/db/db";
import * as schema from "./server/db/schema";
import { toMessage } from "./server/utils/errors";
const cliRun = await runCLI(Bun.argv);
if (cliRun) {
process.exit(0);
}
setSchema(schema);
await initAuth().catch((err) => {
logger.error(`Error initializing auth: ${toMessage(err)}`);
throw err;
});
await bootstrapApplication();
const customHandler = defineHandlerCallback((ctx) => {
return defaultStreamHandler(ctx);