]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/config.ts
Sanitize url to not end with implicit ports
[github/Chocobozzz/PeerTube.git] / server / controllers / api / config.ts
index f02a2bc58efb2c71a677d2fb07fc1a238f98792e..5f704f0eeef38d84645b8d072e8b618eaefe424f 100644 (file)
@@ -1,23 +1,33 @@
 import * as express from 'express'
 
 import { isSignupAllowed } from '../../helpers'
+import { CONFIG } from '../../initializers'
+import { asyncMiddleware } from '../../middlewares'
 import { ServerConfig } from '../../../shared'
 
 const configRouter = express.Router()
 
-configRouter.get('/', getConfig)
+configRouter.get('/',
+  asyncMiddleware(getConfig)
+)
 
-// Get the client credentials for the PeerTube front end
-function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
+async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
+  const allowed = await isSignupAllowed()
 
-  isSignupAllowed().then(allowed => {
-    const json: ServerConfig = {
-      signup: {
-        allowed
-      }
+  const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
+   .filter(key => CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
+   .map(r => parseInt(r, 10))
+
+  const json: ServerConfig = {
+    signup: {
+      allowed
+    },
+    transcoding: {
+      enabledResolutions
     }
-    res.json(json)
-  })
+  }
+
+  return res.json(json)
 }
 
 // ---------------------------------------------------------------------------