feat(server): added a missing db prevention crash

This commit is contained in:
2025-03-13 15:38:46 -05:00
parent 3c2b10b28c
commit b9724aa89c

View File

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