diff --git a/server/index.ts b/server/index.ts index 389ca6d6..33cda21f 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,13 +1,11 @@ -import { ensureActions } from "./db/ensureActions"; import { createApiServer } from "./apiServer"; import { createNextServer } from "./nextServer"; import { createInternalServer } from "./internalServer"; import { User, UserOrg } from "./db/schema"; -import { copyInConfig } from "./setup/copyInConfig"; +import { runSetupFunctions } from "./setup"; async function startServers() { - await ensureActions(); - await copyInConfig(); + await runSetupFunctions(); // Start all servers const apiServer = createApiServer(); diff --git a/server/routers/org/createOrg.ts b/server/routers/org/createOrg.ts index b8567442..8562b1d7 100644 --- a/server/routers/org/createOrg.ts +++ b/server/routers/org/createOrg.ts @@ -7,7 +7,7 @@ import response from "@server/utils/response"; import HttpCode from "@server/types/HttpCode"; import createHttpError from "http-errors"; import logger from "@server/logger"; -import { createAdminRole } from "@server/db/ensureActions"; +import { createAdminRole } from "@server/setup/ensureActions"; import config from "@server/config"; import { fromError } from "zod-validation-error"; import { defaultRoleAllowedActions } from "../role"; diff --git a/server/db/ensureActions.ts b/server/setup/ensureActions.ts similarity index 95% rename from server/db/ensureActions.ts rename to server/setup/ensureActions.ts index 2bd74fc5..c83a0a6b 100644 --- a/server/db/ensureActions.ts +++ b/server/setup/ensureActions.ts @@ -1,7 +1,7 @@ import { ActionsEnum } from "@server/auth/actions"; import { db } from "@server/db"; -import { actions, roles, roleActions } from "./schema"; -import { eq, and, inArray, notInArray } from "drizzle-orm"; +import { actions, roles, roleActions } from "../db/schema"; +import { eq, inArray } from "drizzle-orm"; import logger from "@server/logger"; export async function ensureActions() { diff --git a/server/setup/index.ts b/server/setup/index.ts new file mode 100644 index 00000000..ee7eae98 --- /dev/null +++ b/server/setup/index.ts @@ -0,0 +1,7 @@ +import { ensureActions } from "./ensureActions"; +import { copyInConfig } from "./copyInConfig"; + +export async function runSetupFunctions() { + await ensureActions(); // make sure all of the actions are in the db and the roles + await copyInConfig(); // copy in the config to the db as needed +} \ No newline at end of file