diff --git a/frontend/server/utils/mongo.ts b/frontend/server/utils/mongo.ts index ab0ed8f..35bbf51 100644 --- a/frontend/server/utils/mongo.ts +++ b/frontend/server/utils/mongo.ts @@ -2,7 +2,11 @@ import { MongoClient } from 'mongodb' async function connectToDatabase() { // Create a MongoClient with a MongoClientOptions object to set the Stable API version - const client = new MongoClient(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@${process.env.MONGO_HOST}`) + let uri = `mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@${process.env.MONGO_HOST}` + if(process.env.MONGO_URI != undefined && process.env.MONGO_URI != null && process.env.MONGO_URI != "") { + uri = process.env.MONGO_URI + } + const client = new MongoClient(uri) await client.connect() return client } diff --git a/match_collector/index.ts b/match_collector/index.ts index 5b1b8f4..cbdf8a2 100644 --- a/match_collector/index.ts +++ b/match_collector/index.ts @@ -74,7 +74,11 @@ function handleError(response : Response) { async function connectToDatabase() { // Create a MongoClient with a MongoClientOptions object to set the Stable API version - const client = new MongoClient(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@${process.env.MONGO_HOST}`) + let uri = `mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@${process.env.MONGO_HOST}` + if(process.env.MONGO_URI != undefined && process.env.MONGO_URI != null && process.env.MONGO_URI != "") { + uri = process.env.MONGO_URI + } + const client = new MongoClient(uri) await client.connect() return client } diff --git a/patch_detector/index.ts b/patch_detector/index.ts index a1e69dd..c3c949f 100644 --- a/patch_detector/index.ts +++ b/patch_detector/index.ts @@ -27,7 +27,11 @@ async function fetchLatestPatch() { async function connectToDatabase() { // Create a MongoClient with a MongoClientOptions object to set the Stable API version - const client = new MongoClient(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@${process.env.MONGO_HOST}`) + let uri = `mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@${process.env.MONGO_HOST}` + if(process.env.MONGO_URI != undefined && process.env.MONGO_URI != null && process.env.MONGO_URI != "") { + uri = process.env.MONGO_URI + } + const client = new MongoClient(uri) await client.connect() return client }