refactor(bootstrap): avoid duplicate event firing
This commit is contained in:
parent
df34dc7597
commit
c2711e95bc
1 changed files with 9 additions and 2 deletions
|
|
@ -1,16 +1,23 @@
|
||||||
import { logger } from "./server/utils/logger";
|
import { logger } from "./server/utils/logger";
|
||||||
import { shutdown } from "./server/modules/lifecycle/shutdown";
|
import { shutdown } from "./server/modules/lifecycle/shutdown";
|
||||||
import { runCLI } from "./server/cli";
|
import { runCLI } from "./server/cli";
|
||||||
import { bootstrapApplication } from "./server/modules/lifecycle/bootstrap";
|
|
||||||
import { createStartHandler, defaultStreamHandler, defineHandlerCallback } from "@tanstack/react-start/server";
|
import { createStartHandler, defaultStreamHandler, defineHandlerCallback } from "@tanstack/react-start/server";
|
||||||
import { createServerEntry } from "@tanstack/react-start/server-entry";
|
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);
|
const cliRun = await runCLI(Bun.argv);
|
||||||
if (cliRun) {
|
if (cliRun) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
await bootstrapApplication();
|
setSchema(schema);
|
||||||
|
await initAuth().catch((err) => {
|
||||||
|
logger.error(`Error initializing auth: ${toMessage(err)}`);
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
const customHandler = defineHandlerCallback((ctx) => {
|
const customHandler = defineHandlerCallback((ctx) => {
|
||||||
return defaultStreamHandler(ctx);
|
return defaultStreamHandler(ctx);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue