diff --git a/lstV2/server/services/sqlServer/utils/prodServerConfig.ts b/lstV2/server/services/sqlServer/utils/prodServerConfig.ts index bd3cd38..2825740 100644 --- a/lstV2/server/services/sqlServer/utils/prodServerConfig.ts +++ b/lstV2/server/services/sqlServer/utils/prodServerConfig.ts @@ -4,48 +4,47 @@ import { createLog } from "../../logger/logger.js"; import { serverSettings } from "../../server/controller/settings/getSettings.js"; export const prodSqlConfig = async () => { - try { - //const serverSetting = await db.select().from(settings); - const serverSetting = serverSettings as any; - // create dummy type data - const server = serverSetting.filter((s: any) => s.name === "dbServer"); - const plantToken = serverSetting.filter( - (s: any) => s.name === "plantToken" - ); - const dbUser = serverSetting.filter((s: any) => s.name === "dbUser"); - // if erroring out double check the password was actually encoded before saving - const dbPassword = serverSetting.filter( - (s: any) => s.name === "dbPass" - ); + try { + //const serverSetting = await db.select().from(settings); + const serverSetting = serverSettings as any; + // create dummy type data + const server = serverSetting.filter((s: any) => s.name === "dbServer"); + const plantToken = serverSetting.filter( + (s: any) => s.name === "plantToken", + ); + const dbUser = serverSetting.filter((s: any) => s.name === "dbUser"); + // if erroring out double check the password was actually encoded before saving + const dbPassword = serverSetting.filter((s: any) => s.name === "dbPass"); - const sqlConfig = { - server: server[0].value, - database: `AlplaPROD_${plantToken[0].value}_cus`, - user: dbUser[0].value, - password: atob(dbPassword[0].value), - options: { - encrypt: true, - trustServerCertificate: true, - }, - requestTimeout: 90000, // in milliseconds - pool: { - max: 20, // Maximum number of connections in the pool - min: 0, // Minimum number of connections in the pool - idleTimeoutMillis: 10000, // How long a connection is allowed to be idle before being released - reapIntervalMillis: 1000, // how often to check for idle resourses to destory - acquireTimeoutMillis: 100000, // How long until a complete timeout happens - }, - }; + const sqlConfig = { + server: + process.env.NODE_ENV !== "development" ? "localhost" : server[0].value, + database: `AlplaPROD_${plantToken[0].value}_cus`, + user: dbUser[0].value, + password: atob(dbPassword[0].value), + options: { + encrypt: true, + trustServerCertificate: true, + }, + requestTimeout: 90000, // in milliseconds + pool: { + max: 20, // Maximum number of connections in the pool + min: 0, // Minimum number of connections in the pool + idleTimeoutMillis: 10000, // How long a connection is allowed to be idle before being released + reapIntervalMillis: 1000, // how often to check for idle resourses to destory + acquireTimeoutMillis: 100000, // How long until a complete timeout happens + }, + }; - return sqlConfig; - } catch (error) { - createLog( - "info", - "lst", - "sqlProd", - `${JSON.stringify( - error - )} "There was an error getting/setting up the config for the prod sql server."` - ); - } + return sqlConfig; + } catch (error) { + createLog( + "info", + "lst", + "sqlProd", + `${JSON.stringify( + error, + )} "There was an error getting/setting up the config for the prod sql server."`, + ); + } };