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