]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/config.ts
Propagate old comment on new follow
[github/Chocobozzz/PeerTube.git] / server / controllers / api / config.ts
index 3e9aa77a5c6aac1bb7432adcac866d2abbe41b2d..2f1132904fef5846bf54e8a93c75a096d7115513 100644 (file)
@@ -1,20 +1,33 @@
 import * as express from 'express'
+import { isSignupAllowed } from '../../helpers/utils'
 
 import { CONFIG } from '../../initializers'
+import { asyncMiddleware } from '../../middlewares'
 import { ServerConfig } from '../../../shared'
 
 const configRouter = express.Router()
 
-configRouter.get('/', getConfig)
+configRouter.get('/',
+  asyncMiddleware(getConfig)
+)
+
+async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
+  const allowed = await isSignupAllowed()
+
+  const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
+   .filter(key => CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
+   .map(r => parseInt(r, 10))
 
-// Get the client credentials for the PeerTube front end
-function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
   const json: ServerConfig = {
     signup: {
-      enabled: CONFIG.SIGNUP.ENABLED
+      allowed
+    },
+    transcoding: {
+      enabledResolutions
     }
   }
-  res.json(json)
+
+  return res.json(json)
 }
 
 // ---------------------------------------------------------------------------