]>
Commit | Line | Data |
---|---|---|
1 | import * as express from 'express' | |
2 | ||
3 | import { database as db } from '../../../initializers/database' | |
4 | import { checkSignature, signatureValidator } from '../../../middlewares' | |
5 | ||
6 | const remotePodsRouter = express.Router() | |
7 | ||
8 | // Post because this is a secured request | |
9 | remotePodsRouter.post('/remove', | |
10 | signatureValidator, | |
11 | checkSignature, | |
12 | removePods | |
13 | ) | |
14 | ||
15 | // --------------------------------------------------------------------------- | |
16 | ||
17 | export { | |
18 | remotePodsRouter | |
19 | } | |
20 | ||
21 | // --------------------------------------------------------------------------- | |
22 | ||
23 | function removePods (req: express.Request, res: express.Response, next: express.NextFunction) { | |
24 | const host = req.body.signature.host | |
25 | ||
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)) | |
32 | } |