forked from Galactic/galactic-bot
Fixing mongodbprovider env names
This commit is contained in:
parent
c7949676b2
commit
1410e0ed43
@ -22,7 +22,7 @@ class MongoDBProvider extends Provider
|
|||||||
tables: config.tables
|
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;
|
MONGODB_DATABASE, MONGODB_AUTH_SOURCE, MONGODB_URI } = process.env;
|
||||||
if ((!MONGODB_HOST || !MONGODB_PORT || !MONGODB_DATABASE) && !MONGODB_URI)
|
if ((!MONGODB_HOST || !MONGODB_PORT || !MONGODB_DATABASE) && !MONGODB_URI)
|
||||||
throw new Error('Missing host, port and database OR a connection string');
|
throw new Error('Missing host, port and database OR a connection string');
|
||||||
@ -35,12 +35,13 @@ class MongoDBProvider extends Provider
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auth = MONGODB_USERNAME ? `${MONGODB_USERNAME}:${MONGODB_PASSWORD}@` : '';
|
const auth = MONGODB_USER ? `${MONGODB_USER}:${MONGODB_PASS}@` : '';
|
||||||
if (!auth)
|
if (!auth)
|
||||||
this.logger.warn('No auth provided');
|
this.logger.warn('No auth provided');
|
||||||
this.#URI = `mongodb://${auth}${MONGODB_HOST}/${this.#database}?authSource=${MONGODB_AUTH_SOURCE || this.#database}`;
|
this.#URI = `mongodb://${auth}${MONGODB_HOST}/${this.#database}?authSource=${MONGODB_AUTH_SOURCE || this.#database}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.#client = new MongoClient(this.#URI, config.client);
|
this.#client = new MongoClient(this.#URI, config.client);
|
||||||
this.#client!.on('error', (error: Error) => this.logger.error(`MongoDB error:\n${error.stack || error.message}`))
|
this.#client!.on('error', (error: Error) => this.logger.error(`MongoDB error:\n${error.stack || error.message}`))
|
||||||
.on('timeout', () => this.logger.warn('Connection timed out'))
|
.on('timeout', () => this.logger.warn('Connection timed out'))
|
||||||
|
Loading…
Reference in New Issue
Block a user