From a089651693cf6912864a6589de0f7aad911a8b83 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 29 May 2025 22:28:19 +0200 Subject: Get database working --- src/db/db.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/db/db.js') diff --git a/src/db/db.js b/src/db/db.js index bf7ccfa..36f2105 100644 --- a/src/db/db.js +++ b/src/db/db.js @@ -1,13 +1,16 @@ import { connect } from "mongoose"; +import { readSecret } from "#util/secretUtils.js"; export async function initDb() { - const connStr = "mongodb://root:Foxy1987@localhost/myproject"; + const connectionString = await readSecret( + process.env["DATABASE_SECRET_PATH"], + ); try { - const res = await connect(connStr); + const res = await connect(connectionString); if (res.connection.readyState === 1) { console.log("[MONGODB] Connected successfully!"); } else { - console.error("[MONGODB] Failed to connect to ", connStr); + console.error("[MONGODB] Failed to connect to ", connectionString); } } catch (e) { console.error("[MONGODB] Error connecting to database!"); -- cgit 1.5.1