From ec050390ad602530b6b1414a6009fd0c637a71e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sat, 6 Jan 2024 20:37:11 -0500 Subject: [PATCH] refactor(dbconfig): make db url ternary check if env == production --- lib/dbconfig.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dbconfig.ts b/lib/dbconfig.ts index cefffe2..5f475a6 100644 --- a/lib/dbconfig.ts +++ b/lib/dbconfig.ts @@ -6,12 +6,12 @@ dotenv.config({ path: resolve("/home/rockfic/rockfic-staging/.env") }); export const hasMigrated = false; console.log("indbconfig"); export const uri = - process.env.NODE_ENV == "development" - ? `mongodb://127.0.0.1/${process.env.DBNAME}?authSource=admin` - : `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@${process.env.DB}?authSource=admin`; + process.env.NODE_ENV === "production" + ? `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@${process.env.DB}?authSource=admin` + : `mongodb://127.0.0.1/${process.env.DBNAME}?authSource=admin`; export const olduri = - process.env.NODE_ENV == "development" - ? `mongodb://127.0.0.1/rockfic_old?authSource=admin` - : `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@127.0.0.1:27017/rockfic_old?authSource=admin`; + process.env.NODE_ENV === "production" + ? `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@127.0.0.1:27017/rockfic_old?authSource=admin` + : `mongodb://127.0.0.1/rockfic_old?authSource=admin`; !mongoose.connection.modelNames().length && !hasMigrated && mongoose.connect(uri);