From 47d7f370d060d0356d2dfb21446e3939c8c2186e Mon Sep 17 00:00:00 2001 From: vishnu Date: Tue, 17 Jun 2025 13:50:00 +0530 Subject: [PATCH] enable health check --- src/healthCheck/mongodb.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/healthCheck/mongodb.js b/src/healthCheck/mongodb.js index efcf57c..b849f46 100644 --- a/src/healthCheck/mongodb.js +++ b/src/healthCheck/mongodb.js @@ -3,29 +3,26 @@ * author : Aman Karki. * created-date : 01-Feb-2021. * Description : Mongodb health check functionality. -*/ + */ // Dependencies -const mongoose = require("mongoose") +const mongoose = require('mongoose') function health_check() { - return new Promise(async (resolve, reject) => { + return new Promise(async (resolve, reject) => { + const db = mongoose.createConnection(process.env.MONGODB_URL) - const db = mongoose.createConnection( - process.env.MONGODB_URL + ":" + process.env.MONGODB_PORT + "/" + process.env.MONGODB_DATABASE_NAME - ) - - db.on("error", function () { - return resolve(false) - }) - db.once("open", function () { - db.close(function () { }) - return resolve(true) - }) - }) + db.on('error', function () { + return resolve(false) + }) + db.once('open', function () { + db.close(function () {}) + return resolve(true) + }) + }) } module.exports = { - health_check: health_check -} \ No newline at end of file + health_check: health_check, +}