Add setup entrypoint

This commit is contained in:
Owen Schwartz 2024-12-22 12:33:49 -05:00
parent 39a24c951c
commit 9988061058
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD
4 changed files with 12 additions and 7 deletions

View file

@ -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();

View file

@ -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";

View file

@ -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() {

7
server/setup/index.ts Normal file
View file

@ -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
}