Use a full Mongo URI instead of address and port in config

This commit is contained in:
Jonathan Barrow
2022-06-20 17:16:28 -04:00
parent 3183e45fb2
commit ad60c70831
2 changed files with 2 additions and 4 deletions

View File

@@ -3,12 +3,11 @@ const PNIDSchema = require('./schema/pnid');
const config = require('../config.json');
const accountServerConfig = config.database.account;
const accountServerURI = `mongodb://${accountServerConfig.address}:${accountServerConfig.port}/${accountServerConfig.database_name}`;
let accountServerDBConnection;
let PNID;
async function connect() {
accountServerDBConnection = await mongoose.createConnection(accountServerURI, accountServerConfig.options);
accountServerDBConnection = await mongoose.createConnection(accountServerConfig.uri, accountServerConfig.options);
accountServerDBConnection.on('error', console.error.bind(console, 'Mongoose connection error:'));
accountServerDBConnection.on('close', () => {
accountServerDBConnection.removeAllListeners();