1 // import * as express from 'express'
3 // import { database as db } from '../../../initializers/database'
8 // remotePodsAddValidator,
10 // } from '../../../middlewares'
11 // import { sendOwnedDataToPod } from '../../../lib'
12 // import { getMyPublicCert, getFormattedObjects } from '../../../helpers'
13 // import { CONFIG } from '../../../initializers'
14 // import { PodInstance } from '../../../models'
15 // import { PodSignature, Pod as FormattedPod } from '../../../../shared'
17 // const remotePodsRouter = express.Router()
19 // remotePodsRouter.post('/remove',
20 // signatureValidator,
22 // asyncMiddleware(removePods)
25 // remotePodsRouter.post('/list',
26 // asyncMiddleware(remotePodsList)
29 // remotePodsRouter.post('/add',
30 // setBodyHostPort, // We need to modify the host before running the validator!
31 // remotePodsAddValidator,
32 // asyncMiddleware(addPods)
35 // // ---------------------------------------------------------------------------
41 // // ---------------------------------------------------------------------------
43 // async function addPods (req: express.Request, res: express.Response, next: express.NextFunction) {
44 // const information = req.body
46 // const pod = db.Pod.build(information)
47 // const podCreated = await pod.save()
49 // await sendOwnedDataToPod(podCreated.id)
51 // const cert = await getMyPublicCert()
52 // return res.json({ cert, email: CONFIG.ADMIN.EMAIL })
55 // async function remotePodsList (req: express.Request, res: express.Response, next: express.NextFunction) {
56 // const pods = await db.Pod.list()
58 // return res.json(getFormattedObjects<FormattedPod, PodInstance>(pods, pods.length))
61 // async function removePods (req: express.Request, res: express.Response, next: express.NextFunction) {
62 // const signature: PodSignature = req.body.signature
63 // const host = signature.host
65 // const pod = await db.Pod.loadByHost(host)
66 // await pod.destroy()
68 // return res.type('json').status(204).end()