mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Add about page
This commit is contained in:
parent
66b16cafb3
commit
36f9424ff1
20 changed files with 250 additions and 16 deletions
|
@ -1,19 +1,22 @@
|
|||
import * as express from 'express'
|
||||
import { omit } from 'lodash'
|
||||
import { ServerConfig, UserRight } from '../../../shared'
|
||||
import { About } from '../../../shared/models/config/about.model'
|
||||
import { CustomConfig } from '../../../shared/models/config/custom-config.model'
|
||||
import { unlinkPromise, writeFilePromise } from '../../helpers/core-utils'
|
||||
import { isSignupAllowed } from '../../helpers/utils'
|
||||
import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers'
|
||||
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
|
||||
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
|
||||
import { omit } from 'lodash'
|
||||
|
||||
const packageJSON = require('../../../../package.json')
|
||||
const configRouter = express.Router()
|
||||
|
||||
configRouter.get('/about', getAbout)
|
||||
configRouter.get('/',
|
||||
asyncMiddleware(getConfig)
|
||||
)
|
||||
|
||||
configRouter.get('/custom',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
|
||||
|
@ -39,6 +42,9 @@ async function getConfig (req: express.Request, res: express.Response, next: exp
|
|||
.map(r => parseInt(r, 10))
|
||||
|
||||
const json: ServerConfig = {
|
||||
instance: {
|
||||
name: CONFIG.INSTANCE.NAME
|
||||
},
|
||||
serverVersion: packageJSON.version,
|
||||
signup: {
|
||||
allowed
|
||||
|
@ -64,6 +70,18 @@ async function getConfig (req: express.Request, res: express.Response, next: exp
|
|||
return res.json(json)
|
||||
}
|
||||
|
||||
function getAbout (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const about: About = {
|
||||
instance: {
|
||||
name: CONFIG.INSTANCE.NAME,
|
||||
description: CONFIG.INSTANCE.DESCRIPTION,
|
||||
terms: CONFIG.INSTANCE.TERMS
|
||||
}
|
||||
}
|
||||
|
||||
return res.json(about).end()
|
||||
}
|
||||
|
||||
async function getCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const data = customConfig()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue