import { IConfig } from 'config'
import { dirname, join } from 'path'
-import { VideosRedundancy } from '../../shared/models'
+import { VideosRedundancyStrategy } from '../../shared/models'
// Do not use barrels, remain constants as independent as possible
import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils'
import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
import * as bytes from 'bytes'
+import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
// Use a variable to reload the configuration if we need
let config: IConfig = require('config')
TRUST_PROXY: config.get<string[]>('trust_proxy'),
LOG: {
LEVEL: config.get<string>('log.level'),
- ROTATION: config.get<boolean>('log.rotation.enabled')
+ ROTATION: {
+ ENABLED: config.get<boolean>('log.rotation.enabled'),
+ MAX_FILE_SIZE: bytes.parse(config.get<string>('log.rotation.maxFileSize')),
+ MAX_FILES: config.get<number>('log.rotation.maxFiles')
+ },
+ ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP')
},
SEARCH: {
REMOTE_URI: {
STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies'))
}
},
+ REMOTE_REDUNDANCY: {
+ VIDEOS: {
+ ACCEPT_FROM: config.get<VideoRedundancyConfigFilter>('remote_redundancy.videos.accept_from')
+ }
+ },
CSP: {
ENABLED: config.get<boolean>('csp.enabled'),
REPORT_ONLY: config.get<boolean>('csp.report_only'),
get ALLOW_AUDIO_FILES () { return config.get<boolean>('transcoding.allow_audio_files') },
get THREADS () { return config.get<number>('transcoding.threads') },
RESOLUTIONS: {
+ get '0p' () { return config.get<boolean>('transcoding.resolutions.0p') },
get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') },
get '360p' () { return config.get<boolean>('transcoding.resolutions.360p') },
get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') },
},
HLS: {
get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') }
+ },
+ WEBTORRENT: {
+ get ENABLED () { return config.get<boolean>('transcoding.webtorrent.enabled') }
}
},
IMPORT: {
VIDEOS: {
HTTP: {
- get ENABLED () { return config.get<boolean>('import.videos.http.enabled') }
+ get ENABLED () { return config.get<boolean>('import.videos.http.enabled') },
+ PROXY: {
+ get ENABLED () { return config.get<boolean>('import.videos.http.proxy.enabled') },
+ get URL () { return config.get<string>('import.videos.http.proxy.url') }
+ }
},
TORRENT: {
get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') }
configChangedHandlers.push(fun)
}
+function isEmailEnabled () {
+ return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT
+}
+
// ---------------------------------------------------------------------------
export {
CONFIG,
- registerConfigChangedHandler
+ registerConfigChangedHandler,
+ isEmailEnabled
}
// ---------------------------------------------------------------------------
if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}`
if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}`
- return join(dirname(configSources[ 0 ].name), filename + '.json')
+ return join(dirname(configSources[0].name), filename + '.json')
}
-function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
+function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] {
if (!objs) return []
if (!Array.isArray(objs)) return objs
function purge () {
for (const fileName in require.cache) {
- if (-1 === fileName.indexOf(directory())) {
+ if (fileName.includes(directory()) === false) {
continue
}