]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/remote/pods.ts
Fix tests
[github/Chocobozzz/PeerTube.git] / server / controllers / api / remote / pods.ts
index b0d6642c13bfe71edbad706b5b8fd15ee8c7ed4c..69bbd43780b4e8babcb395451f84f9ce12959aa3 100644 (file)
@@ -1,8 +1,8 @@
 import * as express from 'express'
-import * as waterfall from 'async/waterfall'
 
 import { database as db } from '../../../initializers/database'
 import { checkSignature, signatureValidator } from '../../../middlewares'
+import { PodSignature } from '../../../../shared'
 
 const remotePodsRouter = express.Router()
 
@@ -22,19 +22,11 @@ export {
 // ---------------------------------------------------------------------------
 
 function removePods (req: express.Request, res: express.Response, next: express.NextFunction) {
-  const host = req.body.signature.host
+  const signature: PodSignature = req.body.signature
+  const host = signature.host
 
-  waterfall([
-    function loadPod (callback) {
-      db.Pod.loadByHost(host, callback)
-    },
-
-    function deletePod (pod, callback) {
-      pod.destroy().asCallback(callback)
-    }
-  ], function (err) {
-    if (err) return next(err)
-
-    return res.type('json').status(204).end()
-  })
+  db.Pod.loadByHost(host)
+    .then(pod => pod.destroy())
+    .then(() => res.type('json').status(204).end())
+    .catch(err => next(err))
 }