]> 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 7a9a0c4f06552273e96699584609e1f81ca8edee..69bbd43780b4e8babcb395451f84f9ce12959aa3 100644 (file)
@@ -1,8 +1,8 @@
-import express = require('express')
-import * as waterfall from 'async/waterfall'
+import * as express from 'express'
 
 import { database as db } from '../../../initializers/database'
 import { checkSignature, signatureValidator } from '../../../middlewares'
+import { PodSignature } from '../../../../shared'
 
 const remotePodsRouter = express.Router()
 
@@ -21,20 +21,12 @@ export {
 
 // ---------------------------------------------------------------------------
 
-function removePods (req, res, next) {
-  const host = req.body.signature.host
+function removePods (req: express.Request, res: express.Response, next: express.NextFunction) {
+  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))
 }