diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-11 11:33:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-11 13:45:39 +0200 |
commit | 6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0 (patch) | |
tree | b47de7efb8c6c611c63a15a971c6125a278f547a /server/helpers | |
parent | 2c3abc4fa796555eb7d25f416c4f41ab3e3ad8ca (diff) | |
download | PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.gz PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.tar.zst PeerTube-6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0.zip |
Move config in its own file
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/audit-logger.ts | 2 | ||||
-rw-r--r-- | server/helpers/captions-utils.ts | 2 | ||||
-rw-r--r-- | server/helpers/custom-validators/video-channels.ts | 2 | ||||
-rw-r--r-- | server/helpers/custom-validators/webfinger.ts | 4 | ||||
-rw-r--r-- | server/helpers/express-utils.ts | 5 | ||||
-rw-r--r-- | server/helpers/ffmpeg-utils.ts | 5 | ||||
-rw-r--r-- | server/helpers/logger.ts | 2 | ||||
-rw-r--r-- | server/helpers/requests.ts | 3 | ||||
-rw-r--r-- | server/helpers/signup.ts | 3 | ||||
-rw-r--r-- | server/helpers/utils.ts | 2 | ||||
-rw-r--r-- | server/helpers/webfinger.ts | 4 | ||||
-rw-r--r-- | server/helpers/webtorrent.ts | 2 |
12 files changed, 20 insertions, 16 deletions
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts index af37bce16..f536da439 100644 --- a/server/helpers/audit-logger.ts +++ b/server/helpers/audit-logger.ts | |||
@@ -4,11 +4,11 @@ import { diff } from 'deep-object-diff' | |||
4 | import { chain } from 'lodash' | 4 | import { chain } from 'lodash' |
5 | import * as flatten from 'flat' | 5 | import * as flatten from 'flat' |
6 | import * as winston from 'winston' | 6 | import * as winston from 'winston' |
7 | import { CONFIG } from '../initializers' | ||
8 | import { jsonLoggerFormat, labelFormatter } from './logger' | 7 | import { jsonLoggerFormat, labelFormatter } from './logger' |
9 | import { User, VideoAbuse, VideoChannel, VideoDetails, VideoImport } from '../../shared' | 8 | import { User, VideoAbuse, VideoChannel, VideoDetails, VideoImport } from '../../shared' |
10 | import { VideoComment } from '../../shared/models/videos/video-comment.model' | 9 | import { VideoComment } from '../../shared/models/videos/video-comment.model' |
11 | import { CustomConfig } from '../../shared/models/server/custom-config.model' | 10 | import { CustomConfig } from '../../shared/models/server/custom-config.model' |
11 | import { CONFIG } from '../initializers/config' | ||
12 | 12 | ||
13 | function getAuditIdFromRes (res: express.Response) { | 13 | function getAuditIdFromRes (res: express.Response) { |
14 | return res.locals.oauth.token.User.username | 14 | return res.locals.oauth.token.User.username |
diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.ts index 0fb11a125..7174d4654 100644 --- a/server/helpers/captions-utils.ts +++ b/server/helpers/captions-utils.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { CONFIG } from '../initializers' | 2 | import { CONFIG } from '../initializers/config' |
3 | import { VideoCaptionModel } from '../models/video/video-caption' | 3 | import { VideoCaptionModel } from '../models/video/video-caption' |
4 | import * as srt2vtt from 'srt-to-vtt' | 4 | import * as srt2vtt from 'srt-to-vtt' |
5 | import { createReadStream, createWriteStream, remove, move } from 'fs-extra' | 5 | import { createReadStream, createWriteStream, remove, move } from 'fs-extra' |
diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts index fad7a9bcf..ca8d207cf 100644 --- a/server/helpers/custom-validators/video-channels.ts +++ b/server/helpers/custom-validators/video-channels.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import 'express-validator' | 2 | import 'express-validator' |
3 | import 'multer' | 3 | import 'multer' |
4 | import * as validator from 'validator' | 4 | import * as validator from 'validator' |
5 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | 5 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
6 | import { VideoChannelModel } from '../../models/video/video-channel' | 6 | import { VideoChannelModel } from '../../models/video/video-channel' |
7 | import { exists } from './misc' | 7 | import { exists } from './misc' |
8 | 8 | ||
diff --git a/server/helpers/custom-validators/webfinger.ts b/server/helpers/custom-validators/webfinger.ts index 80a7e4a9d..b18e43fad 100644 --- a/server/helpers/custom-validators/webfinger.ts +++ b/server/helpers/custom-validators/webfinger.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { CONFIG, REMOTE_SCHEME } from '../../initializers' | 1 | import { REMOTE_SCHEME, WEBSERVER } from '../../initializers' |
2 | import { sanitizeHost } from '../core-utils' | 2 | import { sanitizeHost } from '../core-utils' |
3 | import { exists } from './misc' | 3 | import { exists } from './misc' |
4 | 4 | ||
@@ -11,7 +11,7 @@ function isWebfingerLocalResourceValid (value: string) { | |||
11 | if (actorParts.length !== 2) return false | 11 | if (actorParts.length !== 2) return false |
12 | 12 | ||
13 | const host = actorParts[1] | 13 | const host = actorParts[1] |
14 | return sanitizeHost(host, REMOTE_SCHEME.HTTP) === CONFIG.WEBSERVER.HOST | 14 | return sanitizeHost(host, REMOTE_SCHEME.HTTP) === WEBSERVER.HOST |
15 | } | 15 | } |
16 | 16 | ||
17 | // --------------------------------------------------------------------------- | 17 | // --------------------------------------------------------------------------- |
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index fef2da313..2b574ab8e 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as multer from 'multer' | 2 | import * as multer from 'multer' |
3 | import { CONFIG, REMOTE_SCHEME } from '../initializers' | 3 | import { REMOTE_SCHEME } from '../initializers' |
4 | import { logger } from './logger' | 4 | import { logger } from './logger' |
5 | import { deleteFileAsync, generateRandomString } from './utils' | 5 | import { deleteFileAsync, generateRandomString } from './utils' |
6 | import { extname } from 'path' | 6 | import { extname } from 'path' |
7 | import { isArray } from './custom-validators/misc' | 7 | import { isArray } from './custom-validators/misc' |
8 | import { CONFIG } from '../initializers/config' | ||
8 | 9 | ||
9 | function buildNSFWFilter (res?: express.Response, paramNSFW?: string) { | 10 | function buildNSFWFilter (res?: express.Response, paramNSFW?: string) { |
10 | if (paramNSFW === 'true') return true | 11 | if (paramNSFW === 'true') return true |
@@ -58,7 +59,7 @@ function getHostWithPort (host: string) { | |||
58 | return host | 59 | return host |
59 | } | 60 | } |
60 | 61 | ||
61 | function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { | 62 | function badRequest (req: express.Request, res: express.Response) { |
62 | return res.type('json').status(400).end() | 63 | return res.type('json').status(400).end() |
63 | } | 64 | } |
64 | 65 | ||
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index c477e2e89..d818c459c 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import * as ffmpeg from 'fluent-ffmpeg' | 1 | import * as ffmpeg from 'fluent-ffmpeg' |
2 | import { dirname, join } from 'path' | 2 | import { dirname, join } from 'path' |
3 | import { getTargetBitrate, VideoResolution } from '../../shared/models/videos' | 3 | import { getTargetBitrate, VideoResolution } from '../../shared/models/videos' |
4 | import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' | 4 | import { FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' |
5 | import { processImage } from './image-utils' | 5 | import { processImage } from './image-utils' |
6 | import { logger } from './logger' | 6 | import { logger } from './logger' |
7 | import { checkFFmpegEncoders } from '../initializers/checker-before-init' | 7 | import { checkFFmpegEncoders } from '../initializers/checker-before-init' |
8 | import { remove, readFile, writeFile } from 'fs-extra' | 8 | import { readFile, remove, writeFile } from 'fs-extra' |
9 | import { CONFIG } from '../initializers/config' | ||
9 | 10 | ||
10 | function computeResolutionsToTranscode (videoFileHeight: number) { | 11 | function computeResolutionsToTranscode (videoFileHeight: number) { |
11 | const resolutionsEnabled: number[] = [] | 12 | const resolutionsEnabled: number[] = [] |
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index f8a142718..734523b01 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | import { mkdirpSync } from 'fs-extra' | 2 | import { mkdirpSync } from 'fs-extra' |
3 | import * as path from 'path' | 3 | import * as path from 'path' |
4 | import * as winston from 'winston' | 4 | import * as winston from 'winston' |
5 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { omit } from 'lodash' | 6 | import { omit } from 'lodash' |
7 | 7 | ||
8 | const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | 8 | const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT |
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 3762e4d3c..02854b164 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { createWriteStream, remove } from 'fs-extra' | 2 | import { createWriteStream, remove } from 'fs-extra' |
3 | import * as request from 'request' | 3 | import * as request from 'request' |
4 | import { ACTIVITY_PUB, CONFIG } from '../initializers' | 4 | import { ACTIVITY_PUB } from '../initializers' |
5 | import { processImage } from './image-utils' | 5 | import { processImage } from './image-utils' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { logger } from './logger' | 7 | import { logger } from './logger' |
8 | import { CONFIG } from '../initializers/config' | ||
8 | 9 | ||
9 | function doRequest <T> ( | 10 | function doRequest <T> ( |
10 | requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean }, | 11 | requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean }, |
diff --git a/server/helpers/signup.ts b/server/helpers/signup.ts index cdce7989d..5eb56b3cf 100644 --- a/server/helpers/signup.ts +++ b/server/helpers/signup.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { CONFIG } from '../initializers' | ||
2 | import { UserModel } from '../models/account/user' | 1 | import { UserModel } from '../models/account/user' |
3 | import * as ipaddr from 'ipaddr.js' | 2 | import * as ipaddr from 'ipaddr.js' |
3 | import { CONFIG } from '../initializers/config' | ||
4 | |||
4 | const isCidr = require('is-cidr') | 5 | const isCidr = require('is-cidr') |
5 | 6 | ||
6 | async function isSignupAllowed () { | 7 | async function isSignupAllowed () { |
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index cb0e823c5..94ceb15e0 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { ResultList } from '../../shared' | 1 | import { ResultList } from '../../shared' |
2 | import { CONFIG } from '../initializers' | ||
3 | import { ApplicationModel } from '../models/application/application' | 2 | import { ApplicationModel } from '../models/application/application' |
4 | import { execPromise, execPromise2, pseudoRandomBytesPromise, sha256 } from './core-utils' | 3 | import { execPromise, execPromise2, pseudoRandomBytesPromise, sha256 } from './core-utils' |
5 | import { logger } from './logger' | 4 | import { logger } from './logger' |
@@ -7,6 +6,7 @@ import { join } from 'path' | |||
7 | import { Instance as ParseTorrent } from 'parse-torrent' | 6 | import { Instance as ParseTorrent } from 'parse-torrent' |
8 | import { remove } from 'fs-extra' | 7 | import { remove } from 'fs-extra' |
9 | import * as memoizee from 'memoizee' | 8 | import * as memoizee from 'memoizee' |
9 | import { CONFIG } from '../initializers/config' | ||
10 | 10 | ||
11 | function deleteFileAsync (path: string) { | 11 | function deleteFileAsync (path: string) { |
12 | remove(path) | 12 | remove(path) |
diff --git a/server/helpers/webfinger.ts b/server/helpers/webfinger.ts index 156376943..049808846 100644 --- a/server/helpers/webfinger.ts +++ b/server/helpers/webfinger.ts | |||
@@ -3,7 +3,7 @@ import { WebFingerData } from '../../shared' | |||
3 | import { ActorModel } from '../models/activitypub/actor' | 3 | import { ActorModel } from '../models/activitypub/actor' |
4 | import { isTestInstance } from './core-utils' | 4 | import { isTestInstance } from './core-utils' |
5 | import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' | 5 | import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' |
6 | import { CONFIG } from '../initializers' | 6 | import { WEBSERVER } from '../initializers/constants' |
7 | 7 | ||
8 | const webfinger = new WebFinger({ | 8 | const webfinger = new WebFinger({ |
9 | webfist_fallback: false, | 9 | webfist_fallback: false, |
@@ -19,7 +19,7 @@ async function loadActorUrlOrGetFromWebfinger (uriArg: string) { | |||
19 | const [ name, host ] = uri.split('@') | 19 | const [ name, host ] = uri.split('@') |
20 | let actor: ActorModel | 20 | let actor: ActorModel |
21 | 21 | ||
22 | if (host === CONFIG.WEBSERVER.HOST) { | 22 | if (host === WEBSERVER.HOST) { |
23 | actor = await ActorModel.loadLocalByName(name) | 23 | actor = await ActorModel.loadLocalByName(name) |
24 | } else { | 24 | } else { |
25 | actor = await ActorModel.loadByNameAndHost(name, host) | 25 | actor = await ActorModel.loadByNameAndHost(name, host) |
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index 3c9a0b96a..14dfe0d28 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts | |||
@@ -2,7 +2,7 @@ import { logger } from './logger' | |||
2 | import { generateVideoImportTmpPath } from './utils' | 2 | import { generateVideoImportTmpPath } from './utils' |
3 | import * as WebTorrent from 'webtorrent' | 3 | import * as WebTorrent from 'webtorrent' |
4 | import { createWriteStream, ensureDir, remove } from 'fs-extra' | 4 | import { createWriteStream, ensureDir, remove } from 'fs-extra' |
5 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { dirname, join } from 'path' | 6 | import { dirname, join } from 'path' |
7 | 7 | ||
8 | async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) { | 8 | async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) { |