File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,13 @@ const mongoConnectionString = process.env.MONGO_URL;
19
19
// Connect to MongoDB
20
20
const connectToMongoDB = async ( ) => {
21
21
try {
22
+ mongoose . set ( 'strictQuery' , true ) ;
23
+
22
24
await mongoose . connect ( mongoConnectionString , {
23
25
useNewUrlParser : true ,
24
- useUnifiedTopology : true
26
+ useUnifiedTopology : true ,
27
+ serverSelectionTimeoutMS : 30000 , // 30 seconds timeout
28
+ socketTimeoutMS : 45000 // 45 seconds timeout
25
29
} ) ;
26
30
} catch ( error ) {
27
31
console . error ( 'Failed to connect to MongoDB: ' , error ) ;
@@ -31,7 +35,6 @@ const connectToMongoDB = async () => {
31
35
32
36
connectToMongoDB ( ) ;
33
37
34
- mongoose . set ( 'strictQuery' , true ) ;
35
38
mongoose . connection . on ( 'error' , ( ) => {
36
39
console . error (
37
40
'MongoDB Connection Error. Please make sure that MongoDB is running.'
You can’t perform that action at this time.
0 commit comments