File tree Expand file tree Collapse file tree 7 files changed +20
-27
lines changed Top Open diff view settings Expand file tree Collapse file tree 7 files changed +20
-27
lines changed Top Open diff view settings Original file line number Diff line number Diff line change 11{
22 "name" : " p5.js-web-editor" ,
3- "version" : " 2.14.8 " ,
3+ "version" : " 2.14.9 " ,
44 "description" : " The web editor for p5.js." ,
55 "scripts" : {
66 "clean" : " rimraf dist" ,
Original file line number Diff line number Diff line change @@ -14,10 +14,7 @@ const mongoConnectionString = process.env.MONGO_URL;
1414const { ObjectId } = mongoose . Types ;
1515// Connect to MongoDB
1616mongoose . Promise = global . Promise ;
17- mongoose . connect ( mongoConnectionString , {
18- useNewUrlParser : true ,
19- useUnifiedTopology : true
20- } ) ;
17+ mongoose . connect ( mongoConnectionString ) ;
2118mongoose . set ( 'strictQuery' , true ) ;
2219mongoose . connection . on ( 'error' , ( ) => {
2320 console . error (
Original file line number Diff line number Diff line change @@ -22,8 +22,6 @@ const connectToMongoDB = async () => {
2222 mongoose . set ( 'strictQuery' , true ) ;
2323
2424 await mongoose . connect ( mongoConnectionString , {
25- useNewUrlParser : true ,
26- useUnifiedTopology : true ,
2725 serverSelectionTimeoutMS : 30000 , // 30 seconds timeout
2826 socketTimeoutMS : 45000 // 45 seconds timeout
2927 } ) ;
Original file line number Diff line number Diff line change @@ -59,10 +59,7 @@ const headers = { 'User-Agent': 'p5js-web-editor/0.0.1' };
5959
6060const mongoConnectionString = process . env . MONGO_URL ;
6161
62- mongoose . connect ( mongoConnectionString , {
63- useNewUrlParser : true ,
64- useUnifiedTopology : true
65- } ) ;
62+ mongoose . connect ( mongoConnectionString ) ;
6663mongoose . set ( 'strictQuery' , true ) ;
6764mongoose . connection . on ( 'error' , ( ) => {
6865 console . error (
Original file line number Diff line number Diff line change @@ -14,10 +14,7 @@ const headers = { 'User-Agent': 'p5js-web-editor/0.0.1' };
1414
1515const mongoConnectionString = process . env . MONGO_URL ;
1616
17- mongoose . connect ( mongoConnectionString , {
18- useNewUrlParser : true ,
19- useUnifiedTopology : true
20- } ) ;
17+ mongoose . connect ( mongoConnectionString ) ;
2118mongoose . set ( 'strictQuery' , true ) ;
2219mongoose . connection . on ( 'error' , ( ) => {
2320 console . error (
Original file line number Diff line number Diff line change @@ -76,14 +76,19 @@ app.use(cookieParser());
7676
7777mongoose . set ( 'strictQuery' , true ) ;
7878
79- const clientPromise = mongoose
80- . connect ( mongoConnectionString , {
81- useNewUrlParser : true ,
82- useUnifiedTopology : true ,
83- serverSelectionTimeoutMS : 30000 , // 30 seconds timeout
84- socketTimeoutMS : 45000 // 45 seconds timeout
85- } )
86- . then ( ( m ) => m . connection . getClient ( ) ) ;
79+ async function connectToMongoDB ( ) {
80+ try {
81+ const mongooseConnection = await mongoose . connect ( mongoConnectionString , {
82+ serverSelectionTimeoutMS : 30000 , // 30 seconds timeout
83+ socketTimeoutMS : 45000 // 45 seconds timeout
84+ } ) ;
85+ return mongooseConnection . connection . getClient ( ) ;
86+ } catch ( err ) {
87+ throw new Error ( 'MongoDB connection failed' , err ) ;
88+ }
89+ }
90+
91+ const clientInstancePromise = connectToMongoDB ( ) ;
8792
8893app . use (
8994 session ( {
@@ -97,8 +102,7 @@ app.use(
97102 secure : false
98103 } ,
99104 store : new MongoStore ( {
100- clientPromise,
101- autoReconnect : true
105+ clientPromise : clientInstancePromise
102106 } )
103107 } )
104108) ;
You can’t perform that action at this time.
0 commit comments