diff --git a/package-lock.json b/package-lock.json index a03e3956f..c510233ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,7 @@ "jsonwebtoken": "~9.0.0", "jwt-decode": "~3.1.2", "limiter": "~2.1.0", - "mongodb": "^4.12.0", + "mongodb": "~4.13.0", "mqtt": "~4.3.7", "mssql": "~8.1.4", "mysql2": "~2.3.3", @@ -13611,9 +13611,9 @@ } }, "node_modules/mongodb": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.12.0.tgz", - "integrity": "sha512-ssWod7DqVE4faluZESdOqYhV1BI5CQA5c31sr+zxDLJDBX9EA5VJLo8RNSItPTwxExmuGn/T6MbETQWjywNehA==", + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.13.0.tgz", + "integrity": "sha512-+taZ/bV8d1pYuHL4U+gSwkhmDrwkWbH1l4aah4YpmpscMwgFBkufIKxgP/G7m87/NUuQzc2Z75ZTI7ZOyqZLbw==", "dependencies": { "bson": "^4.7.0", "mongodb-connection-string-url": "^2.5.4", @@ -28738,9 +28738,9 @@ "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" }, "mongodb": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.12.0.tgz", - "integrity": "sha512-ssWod7DqVE4faluZESdOqYhV1BI5CQA5c31sr+zxDLJDBX9EA5VJLo8RNSItPTwxExmuGn/T6MbETQWjywNehA==", + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.13.0.tgz", + "integrity": "sha512-+taZ/bV8d1pYuHL4U+gSwkhmDrwkWbH1l4aah4YpmpscMwgFBkufIKxgP/G7m87/NUuQzc2Z75ZTI7ZOyqZLbw==", "requires": { "@aws-sdk/credential-providers": "^3.186.0", "bson": "^4.7.0", diff --git a/package.json b/package.json index b3d1a656f..276c43823 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "jsonwebtoken": "~9.0.0", "jwt-decode": "~3.1.2", "limiter": "~2.1.0", - "mongodb": "^4.12.0", + "mongodb": "~4.13.0", "mqtt": "~4.3.7", "mssql": "~8.1.4", "mysql2": "~2.3.3", diff --git a/server/util-server.js b/server/util-server.js index a28b99ad9..a0ed03d71 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -325,21 +325,14 @@ exports.mysqlQuery = function (connectionString, query) { * @returns {Promise<(string[]|Object[]|Object)>} */ exports.mongodbPing = async function (connectionString) { - let client; + let client = await MongoClient.connect(connectionString); + let dbPing = await client.db().command({ ping: 1 }); + await client.close(); - try { - client = await MongoClient.connect(connectionString, { useNewUrlParser: true }); - let db = client.db(); - let dbping = await db.command({ ping: 1 }); - await client.close(); - if (dbping["ok"] === 1) { - return "UP"; - } else { - throw Error("failed"); - } - } catch (err) { - console.error(err); - throw Error(err); + if (dbPing["ok"] === 1) { + return "UP"; + } else { + throw Error("failed"); } };