X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fconfig.ts;h=2f1132904fef5846bf54e8a93c75a096d7115513;hb=da854ddd502cd70685ef779c673b9e63757b8aa0;hp=57c9398ecaafbd57a326b9ee02887fa5ca160dc2;hpb=4d4e5cd4dca78480ec7f40e747f424cd107376a4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 57c9398ec..2f1132904 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -1,18 +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) +) -// Get the client credentials for the PeerTube front end -function getConfig (req, res, next) { - res.json({ +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)) + + const json: ServerConfig = { signup: { - enabled: CONFIG.SIGNUP.ENABLED + allowed + }, + transcoding: { + enabledResolutions } - }) + } + + return res.json(json) } // ---------------------------------------------------------------------------