diff --git a/database/db.ts b/database/db.ts index 42a3ac3..c6abb18 100644 --- a/database/db.ts +++ b/database/db.ts @@ -5,7 +5,7 @@ import client from './db.config'; // if no connection can be made, return null const getDB = async () => { console.log("Connecting to Database ..."); - if(client._connected) return client; + if(client._connected || client._connecting) return client; try{ await client.connect() console.log("Connected to Database"); diff --git a/server.ts b/server.ts index e59eb83..0d68eb6 100644 --- a/server.ts +++ b/server.ts @@ -13,15 +13,12 @@ import fs from 'fs'; // const credentials = {key: privateKey, cert: certificate}; const PORT = 3000; -// const INTERVAL = secondsToMs(10); // 1 hr -// const TIMEOUT = secondsToMs(10); const app = express(); let dbAval: boolean = true; // initial check (async () => { try { - // logger.info(`Please wait ${TIMEOUT / 1000}s for the database to connect`); dbAval = await checkDB(); logger.info(`Server is up, database is ${dbAval ? "up" : "not up"}`); } catch (e: any) {