summary refs log tree commit diff
path: root/src/db/db.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/db.js')
-rw-r--r--src/db/db.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/db/db.js b/src/db/db.js

index 36f2105..9a7b50e 100644 --- a/src/db/db.js +++ b/src/db/db.js
@@ -1,19 +1,19 @@ -import { connect } from "mongoose"; -import { readSecret } from "#util/secretUtils.js"; +import { connect } from 'mongoose'; +import { readSecret } from '#util/secretUtils.js'; export async function initDb() { - const connectionString = await readSecret( - process.env["DATABASE_SECRET_PATH"], - ); - try { - const res = await connect(connectionString); - if (res.connection.readyState === 1) { - console.log("[MONGODB] Connected successfully!"); - } else { - console.error("[MONGODB] Failed to connect to ", connectionString); + const connectionString = await readSecret( + process.env['DATABASE_SECRET_PATH'] + ); + try { + const res = await connect(connectionString); + if (res.connection.readyState === 1) { + console.log('[MONGODB] Connected successfully!'); + } else { + console.error('[MONGODB] Failed to connect to ', connectionString); + } + } catch (e) { + console.error('[MONGODB] Error connecting to database!'); + throw e; } - } catch (e) { - console.error("[MONGODB] Error connecting to database!"); - throw e; - } }