mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Use async/await in controllers
This commit is contained in:
parent
5f04dd2f74
commit
eb08047657
20 changed files with 823 additions and 992 deletions
|
@ -2,30 +2,32 @@ import * as express from 'express'
|
|||
|
||||
import { isSignupAllowed } from '../../helpers'
|
||||
import { CONFIG } from '../../initializers'
|
||||
import { asyncMiddleware } from '../../middlewares'
|
||||
import { ServerConfig } from '../../../shared'
|
||||
|
||||
const configRouter = express.Router()
|
||||
|
||||
configRouter.get('/', getConfig)
|
||||
configRouter.get('/',
|
||||
asyncMiddleware(getConfig)
|
||||
)
|
||||
|
||||
function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const allowed = await isSignupAllowed()
|
||||
|
||||
isSignupAllowed().then(allowed => {
|
||||
const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
|
||||
.filter(key => CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
|
||||
.map(r => parseInt(r, 10))
|
||||
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
|
||||
}
|
||||
const json: ServerConfig = {
|
||||
signup: {
|
||||
allowed
|
||||
},
|
||||
transcoding: {
|
||||
enabledResolutions
|
||||
}
|
||||
}
|
||||
|
||||
res.json(json)
|
||||
})
|
||||
return res.json(json)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue