mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #10753 from overleaf/em-upgrade-mongo-driver
Upgrade the Mongo driver in the chat service GitOrigin-RevId: 12808e624b75f0adc7fd474f774b855dc2eadefd
This commit is contained in:
parent
ba3b42def4
commit
f9aaa4d5de
6 changed files with 115 additions and 41 deletions
99
package-lock.json
generated
99
package-lock.json
generated
|
@ -35706,7 +35706,7 @@
|
|||
"async": "^3.2.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "4.17.1",
|
||||
"mongodb": "^3.6.0"
|
||||
"mongodb": "^4.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"acorn": "^7.1.1",
|
||||
|
@ -35745,6 +35745,40 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"services/chat/node_modules/bson": {
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.0.tgz",
|
||||
"integrity": "sha512-VrlEE4vuiO1WTpfof4VmaVolCVYkYTgB9iWgYNOrVlnifpME/06fhFRmONgBhClD5pFC1t9ZWqFUQEQAzY43bA==",
|
||||
"dependencies": {
|
||||
"buffer": "^5.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"services/chat/node_modules/buffer": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"base64-js": "^1.3.1",
|
||||
"ieee754": "^1.1.13"
|
||||
}
|
||||
},
|
||||
"services/chat/node_modules/bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
|
@ -35785,6 +35819,14 @@
|
|||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"services/chat/node_modules/denque": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
|
||||
"integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==",
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
}
|
||||
},
|
||||
"services/chat/node_modules/express": {
|
||||
"version": "4.17.1",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
|
||||
|
@ -35856,6 +35898,24 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"services/chat/node_modules/mongodb": {
|
||||
"version": "4.11.0",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.11.0.tgz",
|
||||
"integrity": "sha512-9l9n4Nk2BYZzljW3vHah3Z0rfS5npKw6ktnkmFgTcnzaXH1DRm3pDl6VMHu84EVb1lzmSaJC4OzWZqTkB5i2wg==",
|
||||
"dependencies": {
|
||||
"bson": "^4.7.0",
|
||||
"denque": "^2.1.0",
|
||||
"mongodb-connection-string-url": "^2.5.4",
|
||||
"socks": "^2.7.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.9.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@aws-sdk/credential-providers": "^3.186.0",
|
||||
"saslprep": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"services/chat/node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
|
@ -46021,7 +46081,7 @@
|
|||
"chai-as-promised": "^7.1.1",
|
||||
"express": "4.17.1",
|
||||
"mocha": "^8.4.0",
|
||||
"mongodb": "^3.6.0",
|
||||
"mongodb": "^4.11.0",
|
||||
"request": "^2.88.2",
|
||||
"sandboxed-module": "^2.0.4",
|
||||
"sinon": "^9.2.4",
|
||||
|
@ -46050,6 +46110,23 @@
|
|||
"type-is": "~1.6.17"
|
||||
}
|
||||
},
|
||||
"bson": {
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.7.0.tgz",
|
||||
"integrity": "sha512-VrlEE4vuiO1WTpfof4VmaVolCVYkYTgB9iWgYNOrVlnifpME/06fhFRmONgBhClD5pFC1t9ZWqFUQEQAzY43bA==",
|
||||
"requires": {
|
||||
"buffer": "^5.6.0"
|
||||
}
|
||||
},
|
||||
"buffer": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
||||
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
||||
"requires": {
|
||||
"base64-js": "^1.3.1",
|
||||
"ieee754": "^1.1.13"
|
||||
}
|
||||
},
|
||||
"bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
|
@ -46081,6 +46158,11 @@
|
|||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"denque": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
|
||||
"integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw=="
|
||||
},
|
||||
"express": {
|
||||
"version": "4.17.1",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
|
||||
|
@ -46140,6 +46222,19 @@
|
|||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
|
||||
},
|
||||
"mongodb": {
|
||||
"version": "4.11.0",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.11.0.tgz",
|
||||
"integrity": "sha512-9l9n4Nk2BYZzljW3vHah3Z0rfS5npKw6ktnkmFgTcnzaXH1DRm3pDl6VMHu84EVb1lzmSaJC4OzWZqTkB5i2wg==",
|
||||
"requires": {
|
||||
"@aws-sdk/credential-providers": "^3.186.0",
|
||||
"bson": "^4.7.0",
|
||||
"denque": "^2.1.0",
|
||||
"mongodb-connection-string-url": "^2.5.4",
|
||||
"saslprep": "^1.0.3",
|
||||
"socks": "^2.7.1"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
const logger = require('@overleaf/logger')
|
||||
const settings = require('@overleaf/settings')
|
||||
|
||||
const mongodb = require('./app/js/mongodb')
|
||||
const { mongoClient } = require('./app/js/mongodb')
|
||||
const Server = require('./app/js/server')
|
||||
|
||||
if (!module.parent) {
|
||||
// Called directly
|
||||
const port = settings.internal.chat.port
|
||||
const host = settings.internal.chat.host
|
||||
mongodb
|
||||
.waitForDb()
|
||||
mongoClient
|
||||
.connect()
|
||||
.then(() => {
|
||||
Server.server.listen(port, host, function (err) {
|
||||
if (err) {
|
||||
|
|
|
@ -1,29 +1,16 @@
|
|||
const Settings = require('@overleaf/settings')
|
||||
const { MongoClient, ObjectId } = require('mongodb')
|
||||
|
||||
const clientPromise = MongoClient.connect(
|
||||
Settings.mongo.url,
|
||||
Settings.mongo.options
|
||||
)
|
||||
const client = new MongoClient(Settings.mongo.url)
|
||||
const db = client.db()
|
||||
|
||||
let setupDbPromise
|
||||
async function waitForDb() {
|
||||
if (!setupDbPromise) {
|
||||
setupDbPromise = setupDb()
|
||||
}
|
||||
await setupDbPromise
|
||||
}
|
||||
|
||||
const db = {}
|
||||
async function setupDb() {
|
||||
const internalDb = (await clientPromise).db()
|
||||
|
||||
db.messages = internalDb.collection('messages')
|
||||
db.rooms = internalDb.collection('rooms')
|
||||
const collections = {
|
||||
messages: db.collection('messages'),
|
||||
rooms: db.collection('rooms'),
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
db,
|
||||
db: collections,
|
||||
mongoClient: client,
|
||||
ObjectId,
|
||||
waitForDb,
|
||||
}
|
||||
|
|
|
@ -17,10 +17,6 @@ module.exports = {
|
|||
},
|
||||
|
||||
mongo: {
|
||||
options: {
|
||||
useUnifiedTopology:
|
||||
(process.env.MONGO_USE_UNIFIED_TOPOLOGY || 'true') === 'true',
|
||||
},
|
||||
url:
|
||||
process.env.MONGO_CONNECTION_STRING ||
|
||||
`mongodb://${process.env.MONGO_HOST || 'localhost'}/sharelatex`,
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
"async": "^3.2.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "4.17.1",
|
||||
"mongodb": "^3.6.0"
|
||||
"mongodb": "^4.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"acorn": "^7.1.1",
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
const { db, waitForDb } = require('../../../../app/js/mongodb')
|
||||
const { db } = require('../../../../app/js/mongodb')
|
||||
const app = require('../../../../app')
|
||||
|
||||
let serverPromise = null
|
||||
function startServer(resolve, reject) {
|
||||
waitForDb()
|
||||
.then(() => {
|
||||
app.listen(3010, 'localhost', error => {
|
||||
if (error) {
|
||||
return reject(error)
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
.catch(reject)
|
||||
app.listen(3010, 'localhost', error => {
|
||||
if (error) {
|
||||
return reject(error)
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
async function ensureRunning() {
|
||||
|
|
Loading…
Reference in a new issue