aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/controllers/api/config.ts
blob: c9a051bdc1839f19bd019532e43513ca1921af31 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                  
 
                                               
                                           
                                              




                                     
                                                                                              

                                     



                                                                                                 


                                


                          
       
     
 

                  






                                                                              
import * as express from 'express'

import { isSignupAllowed } from '../../helpers'
import { CONFIG } from '../../initializers'
import { ServerConfig } from '../../../shared'

const configRouter = express.Router()

configRouter.get('/', getConfig)

function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {

  isSignupAllowed().then(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)
  })
}

// ---------------------------------------------------------------------------

export {
  configRouter
}