diff --git a/package-lock.json b/package-lock.json index c3e99f8e4..ad5bcc6f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "p5.js-web-editor", - "version": "2.15.0", + "version": "2.15.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "p5.js-web-editor", - "version": "2.15.0", + "version": "2.15.1", "license": "LGPL-2.1", "dependencies": { "@auth0/s3": "^1.0.0", diff --git a/package.json b/package.json index 8ac3af42a..b8f30a020 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p5.js-web-editor", - "version": "2.15.0", + "version": "2.15.1", "description": "The web editor for p5.js.", "scripts": { "clean": "rimraf dist", diff --git a/server/domain-objects/createDefaultFiles.js b/server/domain-objects/createDefaultFiles.js index 8d17e7cf6..82a147012 100644 --- a/server/domain-objects/createDefaultFiles.js +++ b/server/domain-objects/createDefaultFiles.js @@ -9,8 +9,8 @@ function draw() { export const defaultHTML = `
- - + + diff --git a/server/migrations/emailConsolidation.js b/server/migrations/emailConsolidation.js index bbe02a479..01af84943 100644 --- a/server/migrations/emailConsolidation.js +++ b/server/migrations/emailConsolidation.js @@ -14,7 +14,10 @@ const mongoConnectionString = process.env.MONGO_URL; const { ObjectId } = mongoose.Types; // Connect to MongoDB mongoose.Promise = global.Promise; -mongoose.connect(mongoConnectionString); +mongoose.connect(mongoConnectionString, { + useNewUrlParser: true, + useUnifiedTopology: true +}); mongoose.set('strictQuery', true); mongoose.connection.on('error', () => { console.error( diff --git a/server/previewServer.js b/server/previewServer.js index 9e872c2a6..3c07cd5d5 100644 --- a/server/previewServer.js +++ b/server/previewServer.js @@ -22,6 +22,8 @@ const connectToMongoDB = async () => { mongoose.set('strictQuery', true); await mongoose.connect(mongoConnectionString, { + useNewUrlParser: true, + useUnifiedTopology: true, serverSelectionTimeoutMS: 30000, // 30 seconds timeout socketTimeoutMS: 45000 // 45 seconds timeout }); diff --git a/server/scripts/examples-gg-latest.js b/server/scripts/examples-gg-latest.js index 79ed2dcdc..f6ed2d4e7 100644 --- a/server/scripts/examples-gg-latest.js +++ b/server/scripts/examples-gg-latest.js @@ -59,7 +59,10 @@ const headers = { 'User-Agent': 'p5js-web-editor/0.0.1' }; const mongoConnectionString = process.env.MONGO_URL; -mongoose.connect(mongoConnectionString); +mongoose.connect(mongoConnectionString, { + useNewUrlParser: true, + useUnifiedTopology: true +}); mongoose.set('strictQuery', true); mongoose.connection.on('error', () => { console.error( diff --git a/server/scripts/examples.js b/server/scripts/examples.js index b058e6b01..39e974a87 100644 --- a/server/scripts/examples.js +++ b/server/scripts/examples.js @@ -14,7 +14,10 @@ const headers = { 'User-Agent': 'p5js-web-editor/0.0.1' }; const mongoConnectionString = process.env.MONGO_URL; -mongoose.connect(mongoConnectionString); +mongoose.connect(mongoConnectionString, { + useNewUrlParser: true, + useUnifiedTopology: true +}); mongoose.set('strictQuery', true); mongoose.connection.on('error', () => { console.error( diff --git a/server/server.js b/server/server.js index afb9530cf..8b4d19645 100644 --- a/server/server.js +++ b/server/server.js @@ -76,19 +76,14 @@ app.use(cookieParser()); mongoose.set('strictQuery', true); -async function connectToMongoDB() { - try { - const mongooseConnection = await mongoose.connect(mongoConnectionString, { - serverSelectionTimeoutMS: 30000, // 30 seconds timeout - socketTimeoutMS: 45000 // 45 seconds timeout - }); - return mongooseConnection.connection.getClient(); - } catch (err) { - throw new Error('MongoDB connection failed', err); - } -} - -const clientInstancePromise = connectToMongoDB(); +const clientPromise = mongoose + .connect(mongoConnectionString, { + useNewUrlParser: true, + useUnifiedTopology: true, + serverSelectionTimeoutMS: 30000, // 30 seconds timeout + socketTimeoutMS: 45000 // 45 seconds timeout + }) + .then((m) => m.connection.getClient()); app.use( session({ @@ -102,7 +97,8 @@ app.use( secure: false }, store: new MongoStore({ - clientPromise: clientInstancePromise + clientPromise, + autoReconnect: true }) }) );