diff options
Diffstat (limited to 'server/controllers/api/config.ts')
-rw-r--r-- | server/controllers/api/config.ts | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index c9a051bdc..5f704f0ee 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -2,30 +2,32 @@ import * as express from 'express' | |||
2 | 2 | ||
3 | import { isSignupAllowed } from '../../helpers' | 3 | import { isSignupAllowed } from '../../helpers' |
4 | import { CONFIG } from '../../initializers' | 4 | import { CONFIG } from '../../initializers' |
5 | import { asyncMiddleware } from '../../middlewares' | ||
5 | import { ServerConfig } from '../../../shared' | 6 | import { ServerConfig } from '../../../shared' |
6 | 7 | ||
7 | const configRouter = express.Router() | 8 | const configRouter = express.Router() |
8 | 9 | ||
9 | configRouter.get('/', getConfig) | 10 | configRouter.get('/', |
11 | asyncMiddleware(getConfig) | ||
12 | ) | ||
10 | 13 | ||
11 | function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 14 | async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { |
15 | const allowed = await isSignupAllowed() | ||
12 | 16 | ||
13 | isSignupAllowed().then(allowed => { | 17 | const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS) |
14 | const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS) | 18 | .filter(key => CONFIG.TRANSCODING.RESOLUTIONS[key] === true) |
15 | .filter(key => CONFIG.TRANSCODING.RESOLUTIONS[key] === true) | 19 | .map(r => parseInt(r, 10)) |
16 | .map(r => parseInt(r, 10)) | ||
17 | 20 | ||
18 | const json: ServerConfig = { | 21 | const json: ServerConfig = { |
19 | signup: { | 22 | signup: { |
20 | allowed | 23 | allowed |
21 | }, | 24 | }, |
22 | transcoding: { | 25 | transcoding: { |
23 | enabledResolutions | 26 | enabledResolutions |
24 | } | ||
25 | } | 27 | } |
28 | } | ||
26 | 29 | ||
27 | res.json(json) | 30 | return res.json(json) |
28 | }) | ||
29 | } | 31 | } |
30 | 32 | ||
31 | // --------------------------------------------------------------------------- | 33 | // --------------------------------------------------------------------------- |