import { About } from '../../../shared/models/server/about.model'
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
-import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME } from '../../initializers/constants'
+import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '../../initializers/constants'
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
import { ClientHtml } from '../../lib/client-html'
import { PluginManager } from '../../lib/plugins/plugin-manager'
import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
-const packageJSON = require('../../../../package.json')
const configRouter = express.Router()
const auditLogger = auditLoggerFactory('config')
)
let serverCommit: string
+
async function getConfig (req: express.Request, res: express.Response) {
const allowed = await isSignupAllowed()
const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip)
+ const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
if (serverCommit === undefined) serverCommit = await getServerCommit()
- const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
- .filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
- .map(r => parseInt(r, 10))
-
- const registeredPlugins = PluginManager.Instance.getRegisteredPlugins()
- .map(p => ({
- name: p.name,
- version: p.version,
- description: p.description,
- clientScripts: p.clientScripts
- }))
-
- const registeredThemes = PluginManager.Instance.getRegisteredThemes()
- .map(t => ({
- name: t.name,
- version: t.version,
- description: t.description,
- css: t.css,
- clientScripts: t.clientScripts
- }))
-
- const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
-
const json: ServerConfig = {
instance: {
name: CONFIG.INSTANCE.NAME,
}
},
plugin: {
- registered: registeredPlugins
+ registered: getRegisteredPlugins()
},
theme: {
- registered: registeredThemes,
+ registered: getRegisteredThemes(),
default: defaultTheme
},
email: {
contactForm: {
enabled: CONFIG.CONTACT_FORM.ENABLED
},
- serverVersion: packageJSON.version,
+ serverVersion: PEERTUBE_VERSION,
serverCommit,
signup: {
allowed,
hls: {
enabled: CONFIG.TRANSCODING.HLS.ENABLED
},
- enabledResolutions
+ enabledResolutions: getEnabledResolutions()
},
import: {
videos: {
return objectConverter(body, keyConverter, valueConverter)
}
+
+function getRegisteredThemes () {
+ return PluginManager.Instance.getRegisteredThemes()
+ .map(t => ({
+ name: t.name,
+ version: t.version,
+ description: t.description,
+ css: t.css,
+ clientScripts: t.clientScripts
+ }))
+}
+
+function getEnabledResolutions () {
+ return Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
+ .filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[ key ] === true)
+ .map(r => parseInt(r, 10))
+}
+
+function getRegisteredPlugins () {
+ return PluginManager.Instance.getRegisteredPlugins()
+ .map(p => ({
+ name: p.name,
+ version: p.version,
+ description: p.description,
+ clientScripts: p.clientScripts
+ }))
+}
import * as Bluebird from 'bluebird'
import { createWriteStream, remove } from 'fs-extra'
import * as request from 'request'
-import { ACTIVITY_PUB, WEBSERVER } from '../initializers/constants'
+import { ACTIVITY_PUB, PEERTUBE_VERSION, WEBSERVER } from '../initializers/constants'
import { processImage } from './image-utils'
import { join } from 'path'
import { logger } from './logger'
import { CONFIG } from '../initializers/config'
-const packageJSON = require('../../../package.json')
-
function doRequest <T> (
requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean },
bodyKBLimit = 1000 // 1MB
}
function getUserAgent () {
- return `PeerTube/${packageJSON.version} (+${WEBSERVER.URL})`
+ return `PeerTube/${PEERTUBE_VERSION} (+${WEBSERVER.URL})`
}
// ---------------------------------------------------------------------------
import { PluginModel } from '../../models/server/plugin'
import { PluginManager } from './plugin-manager'
import { logger } from '../../helpers/logger'
-
-const packageJSON = require('../../../../package.json')
+import { PEERTUBE_VERSION } from '../../initializers/constants'
async function listAvailablePluginsFromIndex (options: PeertubePluginIndexList) {
const { start = 0, count = 20, search, sort = 'npmName', pluginType } = options
sort,
pluginType,
search,
- currentPeerTubeEngine: packageJSON.version
+ currentPeerTubeEngine: PEERTUBE_VERSION
}
const uri = CONFIG.PLUGINS.INDEX.URL + '/api/v1/plugins'
async function getLatestPluginsVersion (npmNames: string[]): Promise<PeertubePluginLatestVersionResponse> {
const bodyRequest: PeertubePluginLatestVersionRequest = {
npmNames,
- currentPeerTubeEngine: packageJSON.version
+ currentPeerTubeEngine: PEERTUBE_VERSION
}
const uri = CONFIG.PLUGINS.INDEX.URL + '/api/v1/plugins/latest-version'