This commit is contained in:
Surya Paolo
2023-12-07 11:28:01 +01:00
parent 72a7e3fa37
commit f7bcb0c361
5 changed files with 31 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ mongoose.plugin(schema => {
mongoose.set('debug', false);
const options = {
let options = {
// user: process.env.UDB,
// pass: process.env.PDB,
// useMongoClient: true,
@@ -38,7 +38,7 @@ const options = {
// keepAliveInitialDelay: 300000 // keepAliveInitialDelay is the number of milliseconds to wait before initiating keepAlive on the socket.
};
if (process.env.AUTH_MONGODB) {
if (process.env.AUTH_MONGODB === '1') {
options.auth = {
authSource: "admin",
poolSize: 10,
@@ -47,6 +47,12 @@ if (process.env.AUTH_MONGODB) {
};
}
if (options.auth && options.auth.user) {
console.log('MongoDb con Authenticazione:', options.auth.user, '******');
} else {
console.log('### MongoDb SENZA Authenticazione !!! ');
}
const db = mongoose.connection;
console.log('Node Version ' + process.version);
@@ -60,7 +66,7 @@ mongoose.connect(connectionUrl, options);
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
// we're connected!
console.log('*** CONNESSIONE EFFETTUATA ! ' + process.env.MONGODB_URI + ' db: ' + process.env.DATABASE)
console.log('*** CONNESSIONE EFFETTUATA ! ' + connectionUrl + ' db: ' + process.env.DATABASE)
});