Add commentsEnabled field to AS context
[oweals/peertube.git] / server / middlewares / servers.ts
1 import * as express from 'express'
2 import 'express-validator'
3 import { getHostWithPort } from '../helpers/utils'
4
5 function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
6   if (!req.body.hosts) return next()
7
8   for (let i = 0; i < req.body.hosts.length; i++) {
9     const hostWithPort = getHostWithPort(req.body.hosts[i])
10
11     // Problem with the url parsing?
12     if (hostWithPort === null) {
13       return res.sendStatus(500)
14     }
15
16     req.body.hosts[i] = hostWithPort
17   }
18
19   return next()
20 }
21
22 // ---------------------------------------------------------------------------
23
24 export {
25   setBodyHostsPort
26 }