Просмотр исходного кода

[misc] fix express deprecations

Co-Authored-By: Jakob Ackermann <jakob.ackermann@overleaf.com>
Ersun Warncke 6 лет назад
Родитель
Сommit
7302c0ce0b

+ 6 - 6
services/notifications/app.js

@@ -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.del('/key/:key', controller.removeNotificationByKeyOnly)
+app.delete('/user/:user_id', controller.removeNotificationKey)
+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__(

+ 4 - 4
services/notifications/app/js/NotificationsController.js

@@ -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)
     )
     )
   }
   }
 }
 }

+ 8 - 4
services/notifications/test/unit/js/NotificationsControllerTest.js

@@ -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()
         }
         }
       })
       })