Skip to content

Commit

Permalink
fix error timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanestban committed Apr 17, 2024
1 parent 9867ac8 commit 4a640a2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/config/mongoose.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import mongoose from 'mongoose';

const { MONGODB_ATLAS_USERNAME, MONGODB_ATLAS_PASSWORD, NODE_ENV } = process.env;
const database = NODE_ENV === 'production' ? 'notipadDB' : 'notipadDB_development';
const urlMongo = `mongodb+srv://${MONGODB_ATLAS_USERNAME}:${MONGODB_ATLAS_PASSWORD}@lilith-notipad.qzy3ydb.mongodb.net/${database}?retryWrites=true&w=majority&directConnection=true&directConnection=true`;

const connect = () => {
mongoose
.connect(urlMongo, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log('mongodb is connected'))
.catch((error) => console.error(`error in connection to database => ${error}`));
};

export default connect;

0 comments on commit 4a640a2

Please sign in to comment.