blob: 0343bc62ef091e5a9a43bdab327ecbde4d6bcf95 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
'use strict'
const express = require('express')
const waterfall = require('async/waterfall')
const db = require('../../../initializers/database')
const middlewares = require('../../../middlewares')
const checkSignature = middlewares.secure.checkSignature
const signatureValidator = middlewares.validators.remote.signature
const router = express.Router()
// Post because this is a secured request
router.post('/remove',
signatureValidator.signature,
checkSignature,
removePods
)
// ---------------------------------------------------------------------------
module.exports = router
// ---------------------------------------------------------------------------
function removePods (req, res, next) {
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()
})
}
|