From b9724aa89c47edaf1dbbf730e0605166626c9936 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 13 Mar 2025 15:38:46 -0500 Subject: [PATCH] feat(server): added a missing db prevention crash --- server/index.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/index.ts b/server/index.ts index 22db8d4..39e20d4 100644 --- a/server/index.ts +++ b/server/index.ts @@ -17,11 +17,18 @@ import sqlService from "./services/sqlServer/sqlService.js"; import logistics from "./services/logistics/logisticsService.js"; import {db} from "../database/dbclient.js"; import {settings} from "../database/schema/settings.js"; -import {eq} from "drizzle-orm"; +import {count, eq} from "drizzle-orm"; + +// create the main prodlogin here +const username = "lst_user"; +const password = "Alpla$$Prod"; +export const lstAuth = btoa(`${username}:${password}`); + +// checking to make sure we have the settings intialized +const serverIntialized = await db.select({count: count()}).from(settings); +export const installed = serverIntialized[0].count === 0 && process.env.NODE_ENV !== "development" ? false : true; +createLog("info", "LST", "server", `Server is installed: ${installed}`); -// plant token -const dbServer = await db.select().from(settings).where(eq(settings.name, "dbServer")); -const serverPort = await db.select().from(settings).where(eq(settings.name, "serverPort")); const allowedOrigins = [ "http://localhost:3000", "http://localhost:4000",