mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
This commit is contained in:
parent
5fe7e89831
commit
6fcd19ba73
88 changed files with 1980 additions and 2505 deletions
|
@ -1,5 +1,4 @@
|
|||
import * as express from 'express'
|
||||
import * as waterfall from 'async/waterfall'
|
||||
|
||||
import { database as db } from '../../../initializers/database'
|
||||
import { checkSignature, signatureValidator } from '../../../middlewares'
|
||||
|
@ -24,17 +23,10 @@ export {
|
|||
function removePods (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const host = req.body.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 => {
|
||||
return pod.destroy()
|
||||
})
|
||||
.then(() => res.type('json').status(204).end())
|
||||
.catch(err => next(err))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue