database auth stuff

This commit is contained in:
Erik 2022-04-22 15:21:29 +03:00
parent 46ecdd5c38
commit 36583590fd
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 8 additions and 3 deletions

View File

@ -29,8 +29,11 @@ class MongoDB {
this.logger.info('Initializing database connection.');
try {
const client = new MongoClient(this.config.url + this.config.database, { useUnifiedTopology: true });
const auth = {
username: process.env.API_DB_USERNAME,
password: process.env.API_DB_PASSWORD
};
const client = new MongoClient(this.config.url + this.config.database, { auth });
this.client = await client.connect();
this.db = await this.client.db(this.config.database);
this.logger.info('Database connected.');

View File

@ -146,7 +146,9 @@ class Manager extends EventEmitter {
DISCORD_ID: env.DISCORD_ID,
DISCORD_SCOPE: opts.discord.scope,
DOMAIN: opts.domain,
DEBUG: opts.debug
DEBUG: opts.debug,
API_DB_USERNAME: env.API_DB_USERNAME,
API_DB_PASSWORD: env.API_DB_PASSWORD
};
}