]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/controllers/api/config.ts
35c89835b3d613f80f08f330c50012f2ab9411e1
[github/Chocobozzz/PeerTube.git] / server / controllers / api / config.ts
1 import * as express from 'express'
2 import { isSignupAllowed } from '../../helpers/utils'
3
4 import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers'
5 import { asyncMiddleware } from '../../middlewares'
6 import { ServerConfig } from '../../../shared'
7
8 const configRouter = express.Router()
9
10 configRouter.get('/',
11 asyncMiddleware(getConfig)
12 )
13
14 async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
15 const allowed = await isSignupAllowed()
16
17 const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
18 .filter(key => CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
19 .map(r => parseInt(r, 10))
20
21 const json: ServerConfig = {
22 signup: {
23 allowed
24 },
25 transcoding: {
26 enabledResolutions
27 },
28 avatar: {
29 file: {
30 size: {
31 max: CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max
32 },
33 extensions: CONSTRAINTS_FIELDS.ACTORS.AVATAR.EXTNAME
34 }
35 },
36 video: {
37 file: {
38 extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME
39 }
40 }
41 }
42
43 return res.json(json)
44 }
45
46 // ---------------------------------------------------------------------------
47
48 export {
49 configRouter
50 }