mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #10939 from overleaf/em-upgrade-mongo-notifications
Upgrade Mongo driver in notifications GitOrigin-RevId: 3a504471b21873e614e617d81c15c3e17ce7fdc0
This commit is contained in:
parent
269f5f58c2
commit
efd30fae15
6 changed files with 110 additions and 47 deletions
115
package-lock.json
generated
115
package-lock.json
generated
|
@ -37157,9 +37157,8 @@
|
|||
"bunyan": "^1.8.15",
|
||||
"express": "4.17.1",
|
||||
"method-override": "^3.0.0",
|
||||
"mongodb": "^3.6.0",
|
||||
"request": "^2.88.2",
|
||||
"underscore": "1.13.1"
|
||||
"mongodb": "^4.11.0",
|
||||
"request": "^2.88.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.6",
|
||||
|
@ -37189,6 +37188,40 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"services/notifications/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/notifications/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/notifications/node_modules/bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
|
@ -37229,6 +37262,14 @@
|
|||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"services/notifications/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/notifications/node_modules/express": {
|
||||
"version": "4.17.1",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
|
||||
|
@ -37300,6 +37341,24 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"services/notifications/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/notifications/node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
|
@ -37382,11 +37441,6 @@
|
|||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"services/notifications/node_modules/underscore": {
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz",
|
||||
"integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g=="
|
||||
},
|
||||
"services/project-history": {
|
||||
"name": "@overleaf/project-history",
|
||||
"dependencies": {
|
||||
|
@ -47457,11 +47511,10 @@
|
|||
"express": "4.17.1",
|
||||
"method-override": "^3.0.0",
|
||||
"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",
|
||||
"underscore": "1.13.1"
|
||||
"sinon": "^9.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"body-parser": {
|
||||
|
@ -47481,6 +47534,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",
|
||||
|
@ -47512,6 +47582,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",
|
||||
|
@ -47571,6 +47646,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",
|
||||
|
@ -47639,11 +47727,6 @@
|
|||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
|
||||
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
|
||||
},
|
||||
"underscore": {
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz",
|
||||
"integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g=="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -14,7 +14,7 @@ const express = require('express')
|
|||
const app = express()
|
||||
const methodOverride = require('method-override')
|
||||
const bodyParser = require('body-parser')
|
||||
const mongodb = require('./app/js/mongodb')
|
||||
const { mongoClient } = require('./app/js/mongodb')
|
||||
const controller = require('./app/js/NotificationsController')
|
||||
|
||||
metrics.memory.monitor(logger)
|
||||
|
@ -64,8 +64,8 @@ const port =
|
|||
x1 => x1.port
|
||||
) || 3042
|
||||
|
||||
mongodb
|
||||
.waitForDb()
|
||||
mongoClient
|
||||
.connect()
|
||||
.then(() => {
|
||||
app.listen(port, host, () =>
|
||||
logger.debug(`notifications starting up, listening on ${host}:${port}`)
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
const { db, ObjectId } = require('./mongodb')
|
||||
const request = require('request')
|
||||
const async = require('async')
|
||||
const _ = require('underscore')
|
||||
const settings = require('@overleaf/settings')
|
||||
const { port } = settings.internal.notifications
|
||||
const logger = require('@overleaf/logger')
|
||||
|
@ -56,8 +55,7 @@ module.exports = {
|
|||
logger.err({ err }, e)
|
||||
return cb(e)
|
||||
}
|
||||
const hasNotification = _.some(
|
||||
body,
|
||||
const hasNotification = body.some(
|
||||
notification =>
|
||||
notification.key === notification_key &&
|
||||
notification.user_id === user_id.toString()
|
||||
|
|
|
@ -1,28 +1,15 @@
|
|||
const Settings = require('@overleaf/settings')
|
||||
const { MongoClient, ObjectId } = require('mongodb')
|
||||
|
||||
const clientPromise = MongoClient.connect(
|
||||
Settings.mongo.url,
|
||||
Settings.mongo.options
|
||||
)
|
||||
const mongoClient = new MongoClient(Settings.mongo.url)
|
||||
const mongoDb = mongoClient.db()
|
||||
|
||||
let setupDbPromise
|
||||
async function waitForDb() {
|
||||
if (!setupDbPromise) {
|
||||
setupDbPromise = setupDb()
|
||||
}
|
||||
await setupDbPromise
|
||||
}
|
||||
|
||||
const db = {}
|
||||
async function setupDb() {
|
||||
const internalDb = (await clientPromise).db()
|
||||
|
||||
db.notifications = internalDb.collection('notifications')
|
||||
const db = {
|
||||
notifications: mongoDb.collection('notifications'),
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
db,
|
||||
mongoClient,
|
||||
ObjectId,
|
||||
waitForDb,
|
||||
}
|
||||
|
|
|
@ -7,10 +7,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`,
|
||||
|
|
|
@ -26,9 +26,8 @@
|
|||
"bunyan": "^1.8.15",
|
||||
"express": "4.17.1",
|
||||
"method-override": "^3.0.0",
|
||||
"mongodb": "^3.6.0",
|
||||
"request": "^2.88.2",
|
||||
"underscore": "1.13.1"
|
||||
"mongodb": "^4.11.0",
|
||||
"request": "^2.88.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.6",
|
||||
|
|
Loading…
Reference in a new issue