diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-31 17:47:36 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-31 17:51:04 +0100 |
commit | 36f9424ff192b0584a433bc196bced6fcf265808 (patch) | |
tree | 35d9fa5c53b228f5e7fc27bcc82854d035e9dde8 /server/controllers/api | |
parent | 66b16cafb380012d3eca14e524d86f2450e04069 (diff) | |
download | PeerTube-36f9424ff192b0584a433bc196bced6fcf265808.tar.gz PeerTube-36f9424ff192b0584a433bc196bced6fcf265808.tar.zst PeerTube-36f9424ff192b0584a433bc196bced6fcf265808.zip |
Add about page
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/config.ts | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index e4cb02820..89163edb3 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -1,19 +1,22 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { omit } from 'lodash' | ||
2 | import { ServerConfig, UserRight } from '../../../shared' | 3 | import { ServerConfig, UserRight } from '../../../shared' |
4 | import { About } from '../../../shared/models/config/about.model' | ||
3 | import { CustomConfig } from '../../../shared/models/config/custom-config.model' | 5 | import { CustomConfig } from '../../../shared/models/config/custom-config.model' |
4 | import { unlinkPromise, writeFilePromise } from '../../helpers/core-utils' | 6 | import { unlinkPromise, writeFilePromise } from '../../helpers/core-utils' |
5 | import { isSignupAllowed } from '../../helpers/utils' | 7 | import { isSignupAllowed } from '../../helpers/utils' |
6 | import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' | 8 | import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' |
7 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' | 9 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' |
8 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' | 10 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' |
9 | import { omit } from 'lodash' | ||
10 | 11 | ||
11 | const packageJSON = require('../../../../package.json') | 12 | const packageJSON = require('../../../../package.json') |
12 | const configRouter = express.Router() | 13 | const configRouter = express.Router() |
13 | 14 | ||
15 | configRouter.get('/about', getAbout) | ||
14 | configRouter.get('/', | 16 | configRouter.get('/', |
15 | asyncMiddleware(getConfig) | 17 | asyncMiddleware(getConfig) |
16 | ) | 18 | ) |
19 | |||
17 | configRouter.get('/custom', | 20 | configRouter.get('/custom', |
18 | authenticate, | 21 | authenticate, |
19 | ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), | 22 | ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), |
@@ -39,6 +42,9 @@ async function getConfig (req: express.Request, res: express.Response, next: exp | |||
39 | .map(r => parseInt(r, 10)) | 42 | .map(r => parseInt(r, 10)) |
40 | 43 | ||
41 | const json: ServerConfig = { | 44 | const json: ServerConfig = { |
45 | instance: { | ||
46 | name: CONFIG.INSTANCE.NAME | ||
47 | }, | ||
42 | serverVersion: packageJSON.version, | 48 | serverVersion: packageJSON.version, |
43 | signup: { | 49 | signup: { |
44 | allowed | 50 | allowed |
@@ -64,6 +70,18 @@ async function getConfig (req: express.Request, res: express.Response, next: exp | |||
64 | return res.json(json) | 70 | return res.json(json) |
65 | } | 71 | } |
66 | 72 | ||
73 | function getAbout (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
74 | const about: About = { | ||
75 | instance: { | ||
76 | name: CONFIG.INSTANCE.NAME, | ||
77 | description: CONFIG.INSTANCE.DESCRIPTION, | ||
78 | terms: CONFIG.INSTANCE.TERMS | ||
79 | } | ||
80 | } | ||
81 | |||
82 | return res.json(about).end() | ||
83 | } | ||
84 | |||
67 | async function getCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 85 | async function getCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { |
68 | const data = customConfig() | 86 | const data = customConfig() |
69 | 87 | ||