aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/config.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-25 11:55:06 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-26 09:11:38 +0200
commiteb08047657e739bcd9e592d76307befa3998482b (patch)
treefc309f51ece792fd4307c4af510710a853e1d6b2 /server/controllers/api/config.ts
parent5f04dd2f743961e0a06c29531cc3ccc9e4928d56 (diff)
downloadPeerTube-eb08047657e739bcd9e592d76307befa3998482b.tar.gz
PeerTube-eb08047657e739bcd9e592d76307befa3998482b.tar.zst
PeerTube-eb08047657e739bcd9e592d76307befa3998482b.zip
Use async/await in controllers
Diffstat (limited to 'server/controllers/api/config.ts')
-rw-r--r--server/controllers/api/config.ts32
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
3import { isSignupAllowed } from '../../helpers' 3import { isSignupAllowed } from '../../helpers'
4import { CONFIG } from '../../initializers' 4import { CONFIG } from '../../initializers'
5import { asyncMiddleware } from '../../middlewares'
5import { ServerConfig } from '../../../shared' 6import { ServerConfig } from '../../../shared'
6 7
7const configRouter = express.Router() 8const configRouter = express.Router()
8 9
9configRouter.get('/', getConfig) 10configRouter.get('/',
11 asyncMiddleware(getConfig)
12)
10 13
11function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { 14async 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// ---------------------------------------------------------------------------