From 74dc3bca2b14f5fd3fe80c394dfc34177a46db77 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Apr 2019 14:26:41 +0200 Subject: Don't expose constants directly in initializers/ --- server/initializers/constants.ts | 7 ++++++- server/initializers/index.ts | 2 -- server/initializers/migrations/0170-actor-follow-score.ts | 2 +- server/initializers/migrations/0210-video-language.ts | 2 +- server/initializers/migrations/0215-video-support-length.ts | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) (limited to 'server/initializers') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 3922d8515..a0609d7cd 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -341,7 +341,7 @@ const VIDEO_LICENCES = { 7: 'Public Domain Dedication' } -const VIDEO_LANGUAGES = buildLanguages() +let VIDEO_LANGUAGES: { [id: string]: string } = {} const VIDEO_PRIVACIES = { [ VideoPrivacy.PUBLIC ]: 'Public', @@ -684,6 +684,7 @@ export { VIDEO_VIEW_LIFETIME, CONTACT_FORM_LIFETIME, VIDEO_PLAYLIST_PRIVACIES, + loadLanguages, buildLanguages } @@ -732,6 +733,10 @@ function buildVideosExtname () { : [ '.mp4', '.ogv', '.webm' ] } +function loadLanguages () { + VIDEO_LANGUAGES = buildLanguages() +} + function buildLanguages () { const iso639 = require('iso-639-3') diff --git a/server/initializers/index.ts b/server/initializers/index.ts index fe9190a9c..0fc1a7363 100644 --- a/server/initializers/index.ts +++ b/server/initializers/index.ts @@ -1,5 +1,3 @@ -// Constants first, database in second! -export * from './constants' export * from './database' export * from './installer' export * from './migrator' diff --git a/server/initializers/migrations/0170-actor-follow-score.ts b/server/initializers/migrations/0170-actor-follow-score.ts index 2deabaf98..a12b35da9 100644 --- a/server/initializers/migrations/0170-actor-follow-score.ts +++ b/server/initializers/migrations/0170-actor-follow-score.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { ACTOR_FOLLOW_SCORE } from '../index' +import { ACTOR_FOLLOW_SCORE } from '../constants' async function up (utils: { transaction: Sequelize.Transaction, diff --git a/server/initializers/migrations/0210-video-language.ts b/server/initializers/migrations/0210-video-language.ts index b7ec90905..ca95c7527 100644 --- a/server/initializers/migrations/0210-video-language.ts +++ b/server/initializers/migrations/0210-video-language.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../index' +import { CONSTRAINTS_FIELDS } from '../constants' async function up (utils: { transaction: Sequelize.Transaction, diff --git a/server/initializers/migrations/0215-video-support-length.ts b/server/initializers/migrations/0215-video-support-length.ts index 994eda60d..ba395050f 100644 --- a/server/initializers/migrations/0215-video-support-length.ts +++ b/server/initializers/migrations/0215-video-support-length.ts @@ -1,5 +1,4 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../index' async function up (utils: { transaction: Sequelize.Transaction, -- cgit v1.2.3