]>
Commit | Line | Data |
---|---|---|
4d4e5cd4 | 1 | import * as express from 'express' |
34831b48 | 2 | |
e02643f3 | 3 | import { database as db } from '../../../initializers/database' |
65fcc311 | 4 | import { checkSignature, signatureValidator } from '../../../middlewares' |
34831b48 | 5 | |
65fcc311 | 6 | const remotePodsRouter = express.Router() |
34831b48 C |
7 | |
8 | // Post because this is a secured request | |
65fcc311 C |
9 | remotePodsRouter.post('/remove', |
10 | signatureValidator, | |
34831b48 C |
11 | checkSignature, |
12 | removePods | |
13 | ) | |
14 | ||
15 | // --------------------------------------------------------------------------- | |
16 | ||
65fcc311 C |
17 | export { |
18 | remotePodsRouter | |
19 | } | |
34831b48 C |
20 | |
21 | // --------------------------------------------------------------------------- | |
22 | ||
69818c93 | 23 | function removePods (req: express.Request, res: express.Response, next: express.NextFunction) { |
34831b48 C |
24 | const host = req.body.signature.host |
25 | ||
6fcd19ba C |
26 | db.Pod.loadByHost(host) |
27 | .then(pod => { | |
28 | return pod.destroy() | |
29 | }) | |
30 | .then(() => res.type('json').status(204).end()) | |
31 | .catch(err => next(err)) | |
34831b48 | 32 | } |