diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-27 14:32:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-27 15:12:22 +0200 |
commit | 41fb13c330de629df2d23379209e79c7af0f2e9a (patch) | |
tree | 73bc5a90566406b3910f142beae2a879c1e4265d /server/initializers | |
parent | 40e7ed0714f96c01e16de3ac971a4b28116294e1 (diff) | |
download | PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.gz PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.zst PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.zip |
esModuleInterop to true
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/checker-after-init.ts | 10 | ||||
-rw-r--r-- | server/initializers/checker-before-init.ts | 5 | ||||
-rw-r--r-- | server/initializers/config.ts | 2 | ||||
-rw-r--r-- | server/initializers/installer.ts | 8 | ||||
-rw-r--r-- | server/initializers/migrator.ts | 10 |
5 files changed, 19 insertions, 16 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index 09f587274..c0a6c41ab 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as config from 'config' | 1 | import { util, has, get } from 'config' |
2 | import { uniq } from 'lodash' | 2 | import { uniq } from 'lodash' |
3 | import { URL } from 'url' | 3 | import { URL } from 'url' |
4 | import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils' | 4 | import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils' |
@@ -18,8 +18,8 @@ async function checkActivityPubUrls () { | |||
18 | 18 | ||
19 | const parsed = new URL(actor.url) | 19 | const parsed = new URL(actor.url) |
20 | if (WEBSERVER.HOST !== parsed.host) { | 20 | if (WEBSERVER.HOST !== parsed.host) { |
21 | const NODE_ENV = config.util.getEnv('NODE_ENV') | 21 | const NODE_ENV = util.getEnv('NODE_ENV') |
22 | const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR') | 22 | const NODE_CONFIG_DIR = util.getEnv('NODE_CONFIG_DIR') |
23 | 23 | ||
24 | logger.warn( | 24 | logger.warn( |
25 | 'It seems PeerTube was started (and created some data) with another domain name. ' + | 25 | 'It seems PeerTube was started (and created some data) with another domain name. ' + |
@@ -36,7 +36,7 @@ async function checkActivityPubUrls () { | |||
36 | function checkConfig () { | 36 | function checkConfig () { |
37 | 37 | ||
38 | // Moved configuration keys | 38 | // Moved configuration keys |
39 | if (config.has('services.csp-logger')) { | 39 | if (has('services.csp-logger')) { |
40 | logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.') | 40 | logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.') |
41 | } | 41 | } |
42 | 42 | ||
@@ -97,7 +97,7 @@ function checkConfig () { | |||
97 | 97 | ||
98 | // Check storage directory locations | 98 | // Check storage directory locations |
99 | if (isProdInstance()) { | 99 | if (isProdInstance()) { |
100 | const configStorage = config.get('storage') | 100 | const configStorage = get('storage') |
101 | for (const key of Object.keys(configStorage)) { | 101 | for (const key of Object.keys(configStorage)) { |
102 | if (configStorage[key].startsWith('storage/')) { | 102 | if (configStorage[key].startsWith('storage/')) { |
103 | logger.warn( | 103 | logger.warn( |
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 93c019121..16dc137c0 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts | |||
@@ -1,7 +1,10 @@ | |||
1 | import * as config from 'config' | 1 | import { IConfig } from 'config' |
2 | import { parseSemVersion, promisify0 } from '../helpers/core-utils' | 2 | import { parseSemVersion, promisify0 } from '../helpers/core-utils' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | 4 | ||
5 | // Special behaviour for config because we can reload it | ||
6 | const config: IConfig = require('config') | ||
7 | |||
5 | // ONLY USE CORE MODULES IN THIS FILE! | 8 | // ONLY USE CORE MODULES IN THIS FILE! |
6 | 9 | ||
7 | // Check the config files | 10 | // Check the config files |
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 0e684eef8..be9fc61f0 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as bytes from 'bytes' | 1 | import bytes from 'bytes' |
2 | import { IConfig } from 'config' | 2 | import { IConfig } from 'config' |
3 | import decache from 'decache' | 3 | import decache from 'decache' |
4 | import { dirname, join } from 'path' | 4 | import { dirname, join } from 'path' |
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 676f88653..75daeb5d8 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -1,15 +1,15 @@ | |||
1 | import * as passwordGenerator from 'password-generator' | 1 | import { ensureDir, remove } from 'fs-extra' |
2 | import passwordGenerator from 'password-generator' | ||
2 | import { UserRole } from '../../shared' | 3 | import { UserRole } from '../../shared' |
3 | import { logger } from '../helpers/logger' | 4 | import { logger } from '../helpers/logger' |
4 | import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' | 5 | import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' |
5 | import { UserModel } from '../models/user/user' | ||
6 | import { ApplicationModel } from '../models/application/application' | 6 | import { ApplicationModel } from '../models/application/application' |
7 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 7 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
8 | import { UserModel } from '../models/user/user' | ||
8 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' | 9 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' |
10 | import { CONFIG } from './config' | ||
9 | import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants' | 11 | import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants' |
10 | import { sequelizeTypescript } from './database' | 12 | import { sequelizeTypescript } from './database' |
11 | import { ensureDir, remove } from 'fs-extra' | ||
12 | import { CONFIG } from './config' | ||
13 | 13 | ||
14 | async function installApplication () { | 14 | async function installApplication () { |
15 | try { | 15 | try { |
diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts index 77203ae24..7d7c9f8cb 100644 --- a/server/initializers/migrator.ts +++ b/server/initializers/migrator.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import * as path from 'path' | 1 | import { readdir } from 'fs-extra' |
2 | import { join } from 'path' | ||
3 | import { QueryTypes } from 'sequelize' | ||
2 | import { logger } from '../helpers/logger' | 4 | import { logger } from '../helpers/logger' |
3 | import { LAST_MIGRATION_VERSION } from './constants' | 5 | import { LAST_MIGRATION_VERSION } from './constants' |
4 | import { sequelizeTypescript } from './database' | 6 | import { sequelizeTypescript } from './database' |
5 | import { readdir } from 'fs-extra' | ||
6 | import { QueryTypes } from 'sequelize' | ||
7 | 7 | ||
8 | async function migrate () { | 8 | async function migrate () { |
9 | const tables = await sequelizeTypescript.getQueryInterface().showAllTables() | 9 | const tables = await sequelizeTypescript.getQueryInterface().showAllTables() |
@@ -58,7 +58,7 @@ export { | |||
58 | // --------------------------------------------------------------------------- | 58 | // --------------------------------------------------------------------------- |
59 | 59 | ||
60 | async function getMigrationScripts () { | 60 | async function getMigrationScripts () { |
61 | const files = await readdir(path.join(__dirname, 'migrations')) | 61 | const files = await readdir(join(__dirname, 'migrations')) |
62 | const filesToMigrate: { | 62 | const filesToMigrate: { |
63 | version: string | 63 | version: string |
64 | script: string | 64 | script: string |
@@ -88,7 +88,7 @@ async function executeMigration (actualVersion: number, entity: { version: strin | |||
88 | const migrationScriptName = entity.script | 88 | const migrationScriptName = entity.script |
89 | logger.info('Executing %s migration script.', migrationScriptName) | 89 | logger.info('Executing %s migration script.', migrationScriptName) |
90 | 90 | ||
91 | const migrationScript = require(path.join(__dirname, 'migrations', migrationScriptName)) | 91 | const migrationScript = require(join(__dirname, 'migrations', migrationScriptName)) |
92 | 92 | ||
93 | return sequelizeTypescript.transaction(async t => { | 93 | return sequelizeTypescript.transaction(async t => { |
94 | const options = { | 94 | const options = { |