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;
1919// Connect to MongoDB
2020const connectToMongoDB = async ( ) => {
2121 try {
22+ mongoose . set ( 'strictQuery' , true ) ;
23+
2224 await mongoose . connect ( mongoConnectionString , {
2325 useNewUrlParser : true ,
24- useUnifiedTopology : true
26+ useUnifiedTopology : true ,
27+ serverSelectionTimeoutMS : 30000 , // 30 seconds timeout
28+ socketTimeoutMS : 45000 // 45 seconds timeout
2529 } ) ;
2630 } catch ( error ) {
2731 console . error ( 'Failed to connect to MongoDB: ' , error ) ;
@@ -31,7 +35,6 @@ const connectToMongoDB = async () => {
3135
3236connectToMongoDB ( ) ;
3337
34- mongoose . set ( 'strictQuery' , true ) ;
3538mongoose . connection . on ( 'error' , ( ) => {
3639 console . error (
3740 'MongoDB Connection Error. Please make sure that MongoDB is running.'
You can’t perform that action at this time.
0 commit comments