zerobyte/app/server/index.ts
Nico 1391d6fe5e refactor: move from biome to oxlint/oxformat (#311)
* chore: install and configure oxlint

* chore: fix liniting issues

* chore: install and configure oxfmt

* ci: add oxlint action instead of biome

* chore: pr feedbacks

* Revert "chore: pr feedbacks"

This reverts commit 525dcd8d9f.
2026-01-06 18:34:06 +01:00

50 lines
1.3 KiB
TypeScript

import { createHonoServer } from "react-router-hono-server/bun";
import { runDbMigrations } from "./db/db";
import { startup } from "./modules/lifecycle/startup";
import { retagSnapshots } from "./modules/lifecycle/migration";
import { logger } from "./utils/logger";
import { shutdown } from "./modules/lifecycle/shutdown";
import { REQUIRED_MIGRATIONS } from "./core/constants";
import { validateRequiredMigrations } from "./modules/lifecycle/checkpoint";
import { createApp } from "./app";
import { config } from "./core/config";
import { runCLI } from "./cli";
const cliRun = await runCLI(Bun.argv);
if (cliRun) {
process.exit(0);
}
const app = createApp();
runDbMigrations();
await retagSnapshots();
await validateRequiredMigrations(REQUIRED_MIGRATIONS);
await startup();
export type AppType = typeof app;
process.on("SIGTERM", async () => {
logger.info("SIGTERM received, starting graceful shutdown...");
await shutdown();
process.exit(0);
});
process.on("SIGINT", async () => {
logger.info("SIGINT received, starting graceful shutdown...");
await shutdown();
process.exit(0);
});
export default await createHonoServer({
app,
port: config.port,
customBunServer: {
idleTimeout: config.serverIdleTimeout,
error(err) {
logger.error(`[Bun.serve] Server error: ${err.message}`);
},
},
});