diff options
Diffstat (limited to 'server/initializers/config.ts')
-rw-r--r-- | server/initializers/config.ts | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index c16b63c33..5281d3a66 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -1,12 +1,13 @@ | |||
1 | import * as bytes from 'bytes' | ||
1 | import { IConfig } from 'config' | 2 | import { IConfig } from 'config' |
3 | import decache from 'decache' | ||
2 | import { dirname, join } from 'path' | 4 | import { dirname, join } from 'path' |
5 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' | ||
6 | import { BroadcastMessageLevel } from '@shared/models/server' | ||
3 | import { VideosRedundancyStrategy } from '../../shared/models' | 7 | import { VideosRedundancyStrategy } from '../../shared/models' |
8 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | ||
4 | // Do not use barrels, remain constants as independent as possible | 9 | // Do not use barrels, remain constants as independent as possible |
5 | import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' | 10 | import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' |
6 | import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' | ||
7 | import * as bytes from 'bytes' | ||
8 | import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' | ||
9 | import { BroadcastMessageLevel } from '@shared/models/server' | ||
10 | 11 | ||
11 | // Use a variable to reload the configuration if we need | 12 | // Use a variable to reload the configuration if we need |
12 | let config: IConfig = require('config') | 13 | let config: IConfig = require('config') |
@@ -59,7 +60,7 @@ const CONFIG = { | |||
59 | }, | 60 | }, |
60 | STORAGE: { | 61 | STORAGE: { |
61 | TMP_DIR: buildPath(config.get<string>('storage.tmp')), | 62 | TMP_DIR: buildPath(config.get<string>('storage.tmp')), |
62 | AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), | 63 | ACTOR_IMAGES: buildPath(config.get<string>('storage.avatars')), |
63 | LOG_DIR: buildPath(config.get<string>('storage.logs')), | 64 | LOG_DIR: buildPath(config.get<string>('storage.logs')), |
64 | VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), | 65 | VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), |
65 | STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')), | 66 | STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')), |
@@ -133,6 +134,11 @@ const CONFIG = { | |||
133 | REPORT_ONLY: config.get<boolean>('csp.report_only'), | 134 | REPORT_ONLY: config.get<boolean>('csp.report_only'), |
134 | REPORT_URI: config.get<string>('csp.report_uri') | 135 | REPORT_URI: config.get<string>('csp.report_uri') |
135 | }, | 136 | }, |
137 | SECURITY: { | ||
138 | FRAMEGUARD: { | ||
139 | ENABLED: config.get<boolean>('security.frameguard.enabled') | ||
140 | } | ||
141 | }, | ||
136 | TRACKER: { | 142 | TRACKER: { |
137 | ENABLED: config.get<boolean>('tracker.enabled'), | 143 | ENABLED: config.get<boolean>('tracker.enabled'), |
138 | PRIVATE: config.get<boolean>('tracker.private'), | 144 | PRIVATE: config.get<boolean>('tracker.private'), |
@@ -163,6 +169,12 @@ const CONFIG = { | |||
163 | CLEANUP_REMOTE_INTERACTIONS: config.get<boolean>('federation.videos.cleanup_remote_interactions') | 169 | CLEANUP_REMOTE_INTERACTIONS: config.get<boolean>('federation.videos.cleanup_remote_interactions') |
164 | } | 170 | } |
165 | }, | 171 | }, |
172 | PEERTUBE: { | ||
173 | CHECK_LATEST_VERSION: { | ||
174 | ENABLED: config.get<boolean>('peertube.check_latest_version.enabled'), | ||
175 | URL: config.get<string>('peertube.check_latest_version.url') | ||
176 | } | ||
177 | }, | ||
166 | ADMIN: { | 178 | ADMIN: { |
167 | get EMAIL () { return config.get<string>('admin.email') } | 179 | get EMAIL () { return config.get<string>('admin.email') } |
168 | }, | 180 | }, |
@@ -404,7 +416,7 @@ function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] { | |||
404 | 416 | ||
405 | export function reloadConfig () { | 417 | export function reloadConfig () { |
406 | 418 | ||
407 | function directory () { | 419 | function getConfigDirectory () { |
408 | if (process.env.NODE_CONFIG_DIR) { | 420 | if (process.env.NODE_CONFIG_DIR) { |
409 | return process.env.NODE_CONFIG_DIR | 421 | return process.env.NODE_CONFIG_DIR |
410 | } | 422 | } |
@@ -413,15 +425,17 @@ export function reloadConfig () { | |||
413 | } | 425 | } |
414 | 426 | ||
415 | function purge () { | 427 | function purge () { |
428 | const directory = getConfigDirectory() | ||
429 | |||
416 | for (const fileName in require.cache) { | 430 | for (const fileName in require.cache) { |
417 | if (fileName.includes(directory()) === false) { | 431 | if (fileName.includes(directory) === false) { |
418 | continue | 432 | continue |
419 | } | 433 | } |
420 | 434 | ||
421 | delete require.cache[fileName] | 435 | delete require.cache[fileName] |
422 | } | 436 | } |
423 | 437 | ||
424 | delete require.cache[require.resolve('config')] | 438 | decache('config') |
425 | } | 439 | } |
426 | 440 | ||
427 | purge() | 441 | purge() |