From 1410e0ed43c08f515cb6dde282305ae0825e0e78 Mon Sep 17 00:00:00 2001 From: D3vision Date: Tue, 5 Dec 2023 20:06:40 +0100 Subject: [PATCH] Fixing mongodbprovider env names --- src/client/storage/providers/MongoDBProvider.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/storage/providers/MongoDBProvider.ts b/src/client/storage/providers/MongoDBProvider.ts index 886c924..3de2d6f 100644 --- a/src/client/storage/providers/MongoDBProvider.ts +++ b/src/client/storage/providers/MongoDBProvider.ts @@ -22,7 +22,7 @@ class MongoDBProvider extends Provider tables: config.tables }); - const { MONGODB_HOST, MONGODB_PORT, MONGODB_USERNAME, MONGODB_PASSWORD, + const { MONGODB_HOST, MONGODB_PORT, MONGODB_USER, MONGODB_PASS, MONGODB_DATABASE, MONGODB_AUTH_SOURCE, MONGODB_URI } = process.env; if ((!MONGODB_HOST || !MONGODB_PORT || !MONGODB_DATABASE) && !MONGODB_URI) throw new Error('Missing host, port and database OR a connection string'); @@ -35,12 +35,13 @@ class MongoDBProvider extends Provider } else { - const auth = MONGODB_USERNAME ? `${MONGODB_USERNAME}:${MONGODB_PASSWORD}@` : ''; + const auth = MONGODB_USER ? `${MONGODB_USER}:${MONGODB_PASS}@` : ''; if (!auth) this.logger.warn('No auth provided'); this.#URI = `mongodb://${auth}${MONGODB_HOST}/${this.#database}?authSource=${MONGODB_AUTH_SOURCE || this.#database}`; } + this.#client = new MongoClient(this.#URI, config.client); this.#client!.on('error', (error: Error) => this.logger.error(`MongoDB error:\n${error.stack || error.message}`)) .on('timeout', () => this.logger.warn('Connection timed out'))