1 files changed, 6 insertions, 3 deletions
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!");
|