[misc] fix express deprecations

Co-Authored-By: Jakob Ackermann <jakob.ackermann@overleaf.com>
This commit is contained in:
Ersun Warncke 2020-03-18 11:29:28 -04:00 committed by Jakob Ackermann
parent 4ab49ec6c5
commit 7302c0ce0b
3 changed files with 18 additions and 14 deletions

View file

@ -33,12 +33,12 @@ metrics.injectMetricsRoute(app)
app.post('/user/:user_id', controller.addNotification) app.post('/user/:user_id', controller.addNotification)
app.get('/user/:user_id', controller.getUserNotifications) app.get('/user/:user_id', controller.getUserNotifications)
app.del( app.delete(
'/user/:user_id/notification/:notification_id', '/user/:user_id/notification/:notification_id',
controller.removeNotificationId controller.removeNotificationId
) )
app.del('/user/:user_id', controller.removeNotificationKey) app.delete('/user/:user_id', controller.removeNotificationKey)
app.del('/key/:key', controller.removeNotificationByKeyOnly) app.delete('/key/:key', controller.removeNotificationByKeyOnly)
app.get('/status', (req, res) => res.send('notifications sharelatex up')) app.get('/status', (req, res) => res.send('notifications sharelatex up'))
@ -46,14 +46,14 @@ app.get('/health_check', (req, res) =>
HealthCheckController.check(function(err) { HealthCheckController.check(function(err) {
if (err != null) { if (err != null) {
logger.err({ err }, 'error performing health check') logger.err({ err }, 'error performing health check')
return res.send(500) return res.sendStatus(500)
} else { } else {
return res.send(200) return res.sendStatus(200)
} }
}) })
) )
app.get('*', (req, res) => res.send(404)) app.get('*', (req, res) => res.sendStatus(404))
const host = const host =
__guard__( __guard__(

View file

@ -40,7 +40,7 @@ module.exports = {
if (err != null) { if (err != null) {
return res.sendStatus(500) return res.sendStatus(500)
} else { } else {
return res.send() return res.sendStatus(200)
} }
}) })
}, },
@ -57,7 +57,7 @@ module.exports = {
return Notifications.removeNotificationId( return Notifications.removeNotificationId(
req.params.user_id, req.params.user_id,
req.params.notification_id, req.params.notification_id,
(err, notifications) => res.send() (err, notifications) => res.sendStatus(200)
) )
}, },
@ -70,7 +70,7 @@ module.exports = {
return Notifications.removeNotificationKey( return Notifications.removeNotificationKey(
req.params.user_id, req.params.user_id,
req.body.key, req.body.key,
(err, notifications) => res.send() (err, notifications) => res.sendStatus(200)
) )
}, },
@ -80,7 +80,7 @@ module.exports = {
metrics.inc('removeNotificationKey') metrics.inc('removeNotificationKey')
return Notifications.removeNotificationByKeyOnly( return Notifications.removeNotificationByKeyOnly(
notification_key, notification_key,
(err, notifications) => res.send() (err, notifications) => res.sendStatus(200)
) )
} }
} }

View file

@ -76,10 +76,11 @@ describe('Notifications Controller', function() {
body: this.stubbedNotification body: this.stubbedNotification
} }
return this.controller.addNotification(req, { return this.controller.addNotification(req, {
send: result => { sendStatus: code => {
this.notifications.addNotification this.notifications.addNotification
.calledWith(user_id, this.stubbedNotification) .calledWith(user_id, this.stubbedNotification)
.should.equal(true) .should.equal(true)
code.should.equal(200)
return done() return done()
} }
}) })
@ -96,10 +97,11 @@ describe('Notifications Controller', function() {
} }
} }
return this.controller.removeNotificationId(req, { return this.controller.removeNotificationId(req, {
send: result => { sendStatus: code => {
this.notifications.removeNotificationId this.notifications.removeNotificationId
.calledWith(user_id, notification_id) .calledWith(user_id, notification_id)
.should.equal(true) .should.equal(true)
code.should.equal(200)
return done() return done()
} }
}) })
@ -116,10 +118,11 @@ describe('Notifications Controller', function() {
body: { key: notification_key } body: { key: notification_key }
} }
return this.controller.removeNotificationKey(req, { return this.controller.removeNotificationKey(req, {
send: result => { sendStatus: code => {
this.notifications.removeNotificationKey this.notifications.removeNotificationKey
.calledWith(user_id, notification_key) .calledWith(user_id, notification_key)
.should.equal(true) .should.equal(true)
code.should.equal(200)
return done() return done()
} }
}) })
@ -137,10 +140,11 @@ describe('Notifications Controller', function() {
} }
} }
return this.controller.removeNotificationByKeyOnly(req, { return this.controller.removeNotificationByKeyOnly(req, {
send: result => { sendStatus: code => {
this.notifications.removeNotificationByKeyOnly this.notifications.removeNotificationByKeyOnly
.calledWith(notification_key) .calledWith(notification_key)
.should.equal(true) .should.equal(true)
code.should.equal(200)
return done() return done()
} }
}) })