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
39 lines
893 B
TypeScript
39 lines
893 B
TypeScript
import * as schema from "../../db/schema";
|
|
import { runDbMigrations, setSchema } from "../../db/db";
|
|
import { runMigrations } from "./migrations";
|
|
import { startup } from "./startup";
|
|
import { initAuth } from "../../lib/auth";
|
|
import { logger } from "../../utils/logger";
|
|
import { toMessage } from "../../utils/errors";
|
|
|
|
let bootstrapPromise: Promise<void> | undefined;
|
|
|
|
export const initModules = async () => {
|
|
setSchema(schema);
|
|
|
|
await initAuth().catch((err) => {
|
|
logger.error(`Error initializing auth: ${toMessage(err)}`);
|
|
throw err;
|
|
});
|
|
}
|
|
|
|
const runBootstrap = async () => {
|
|
await initModules();
|
|
|
|
runDbMigrations();
|
|
await runMigrations();
|
|
await startup();
|
|
};
|
|
|
|
export const bootstrapApplication = async () => {
|
|
if (!bootstrapPromise) {
|
|
bootstrapPromise = runBootstrap();
|
|
}
|
|
|
|
try {
|
|
await bootstrapPromise;
|
|
} catch (err) {
|
|
bootstrapPromise = undefined;
|
|
throw err;
|
|
}
|
|
};
|