aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-11 11:33:44 +0200
committerChocobozzz <me@florianbigard.com>2019-04-11 13:45:39 +0200
commit6dd9de95dfa39bd5c1faed00d1dbd52cd112bae0 (patch)
treeb47de7efb8c6c611c63a15a971c6125a278f547a /server/helpers
parent2c3abc4fa796555eb7d25f416c4f41ab3e3ad8ca (diff)
downloadPeerTube-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.ts2
-rw-r--r--server/helpers/captions-utils.ts2
-rw-r--r--server/helpers/custom-validators/video-channels.ts2
-rw-r--r--server/helpers/custom-validators/webfinger.ts4
-rw-r--r--server/helpers/express-utils.ts5
-rw-r--r--server/helpers/ffmpeg-utils.ts5
-rw-r--r--server/helpers/logger.ts2
-rw-r--r--server/helpers/requests.ts3
-rw-r--r--server/helpers/signup.ts3
-rw-r--r--server/helpers/utils.ts2
-rw-r--r--server/helpers/webfinger.ts4
-rw-r--r--server/helpers/webtorrent.ts2
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'
4import { chain } from 'lodash' 4import { chain } from 'lodash'
5import * as flatten from 'flat' 5import * as flatten from 'flat'
6import * as winston from 'winston' 6import * as winston from 'winston'
7import { CONFIG } from '../initializers'
8import { jsonLoggerFormat, labelFormatter } from './logger' 7import { jsonLoggerFormat, labelFormatter } from './logger'
9import { User, VideoAbuse, VideoChannel, VideoDetails, VideoImport } from '../../shared' 8import { User, VideoAbuse, VideoChannel, VideoDetails, VideoImport } from '../../shared'
10import { VideoComment } from '../../shared/models/videos/video-comment.model' 9import { VideoComment } from '../../shared/models/videos/video-comment.model'
11import { CustomConfig } from '../../shared/models/server/custom-config.model' 10import { CustomConfig } from '../../shared/models/server/custom-config.model'
11import { CONFIG } from '../initializers/config'
12 12
13function getAuditIdFromRes (res: express.Response) { 13function 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 @@
1import { join } from 'path' 1import { join } from 'path'
2import { CONFIG } from '../initializers' 2import { CONFIG } from '../initializers/config'
3import { VideoCaptionModel } from '../models/video/video-caption' 3import { VideoCaptionModel } from '../models/video/video-caption'
4import * as srt2vtt from 'srt-to-vtt' 4import * as srt2vtt from 'srt-to-vtt'
5import { createReadStream, createWriteStream, remove, move } from 'fs-extra' 5import { 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'
2import 'express-validator' 2import 'express-validator'
3import 'multer' 3import 'multer'
4import * as validator from 'validator' 4import * as validator from 'validator'
5import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' 5import { CONSTRAINTS_FIELDS } from '../../initializers'
6import { VideoChannelModel } from '../../models/video/video-channel' 6import { VideoChannelModel } from '../../models/video/video-channel'
7import { exists } from './misc' 7import { 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 @@
1import { CONFIG, REMOTE_SCHEME } from '../../initializers' 1import { REMOTE_SCHEME, WEBSERVER } from '../../initializers'
2import { sanitizeHost } from '../core-utils' 2import { sanitizeHost } from '../core-utils'
3import { exists } from './misc' 3import { 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 @@
1import * as express from 'express' 1import * as express from 'express'
2import * as multer from 'multer' 2import * as multer from 'multer'
3import { CONFIG, REMOTE_SCHEME } from '../initializers' 3import { REMOTE_SCHEME } from '../initializers'
4import { logger } from './logger' 4import { logger } from './logger'
5import { deleteFileAsync, generateRandomString } from './utils' 5import { deleteFileAsync, generateRandomString } from './utils'
6import { extname } from 'path' 6import { extname } from 'path'
7import { isArray } from './custom-validators/misc' 7import { isArray } from './custom-validators/misc'
8import { CONFIG } from '../initializers/config'
8 9
9function buildNSFWFilter (res?: express.Response, paramNSFW?: string) { 10function 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
61function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { 62function 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 @@
1import * as ffmpeg from 'fluent-ffmpeg' 1import * as ffmpeg from 'fluent-ffmpeg'
2import { dirname, join } from 'path' 2import { dirname, join } from 'path'
3import { getTargetBitrate, VideoResolution } from '../../shared/models/videos' 3import { getTargetBitrate, VideoResolution } from '../../shared/models/videos'
4import { CONFIG, FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' 4import { FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants'
5import { processImage } from './image-utils' 5import { processImage } from './image-utils'
6import { logger } from './logger' 6import { logger } from './logger'
7import { checkFFmpegEncoders } from '../initializers/checker-before-init' 7import { checkFFmpegEncoders } from '../initializers/checker-before-init'
8import { remove, readFile, writeFile } from 'fs-extra' 8import { readFile, remove, writeFile } from 'fs-extra'
9import { CONFIG } from '../initializers/config'
9 10
10function computeResolutionsToTranscode (videoFileHeight: number) { 11function 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 @@
2import { mkdirpSync } from 'fs-extra' 2import { mkdirpSync } from 'fs-extra'
3import * as path from 'path' 3import * as path from 'path'
4import * as winston from 'winston' 4import * as winston from 'winston'
5import { CONFIG } from '../initializers' 5import { CONFIG } from '../initializers/config'
6import { omit } from 'lodash' 6import { omit } from 'lodash'
7 7
8const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT 8const 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 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { createWriteStream, remove } from 'fs-extra' 2import { createWriteStream, remove } from 'fs-extra'
3import * as request from 'request' 3import * as request from 'request'
4import { ACTIVITY_PUB, CONFIG } from '../initializers' 4import { ACTIVITY_PUB } from '../initializers'
5import { processImage } from './image-utils' 5import { processImage } from './image-utils'
6import { join } from 'path' 6import { join } from 'path'
7import { logger } from './logger' 7import { logger } from './logger'
8import { CONFIG } from '../initializers/config'
8 9
9function doRequest <T> ( 10function 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 @@
1import { CONFIG } from '../initializers'
2import { UserModel } from '../models/account/user' 1import { UserModel } from '../models/account/user'
3import * as ipaddr from 'ipaddr.js' 2import * as ipaddr from 'ipaddr.js'
3import { CONFIG } from '../initializers/config'
4
4const isCidr = require('is-cidr') 5const isCidr = require('is-cidr')
5 6
6async function isSignupAllowed () { 7async 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 @@
1import { ResultList } from '../../shared' 1import { ResultList } from '../../shared'
2import { CONFIG } from '../initializers'
3import { ApplicationModel } from '../models/application/application' 2import { ApplicationModel } from '../models/application/application'
4import { execPromise, execPromise2, pseudoRandomBytesPromise, sha256 } from './core-utils' 3import { execPromise, execPromise2, pseudoRandomBytesPromise, sha256 } from './core-utils'
5import { logger } from './logger' 4import { logger } from './logger'
@@ -7,6 +6,7 @@ import { join } from 'path'
7import { Instance as ParseTorrent } from 'parse-torrent' 6import { Instance as ParseTorrent } from 'parse-torrent'
8import { remove } from 'fs-extra' 7import { remove } from 'fs-extra'
9import * as memoizee from 'memoizee' 8import * as memoizee from 'memoizee'
9import { CONFIG } from '../initializers/config'
10 10
11function deleteFileAsync (path: string) { 11function 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'
3import { ActorModel } from '../models/activitypub/actor' 3import { ActorModel } from '../models/activitypub/actor'
4import { isTestInstance } from './core-utils' 4import { isTestInstance } from './core-utils'
5import { isActivityPubUrlValid } from './custom-validators/activitypub/misc' 5import { isActivityPubUrlValid } from './custom-validators/activitypub/misc'
6import { CONFIG } from '../initializers' 6import { WEBSERVER } from '../initializers/constants'
7 7
8const webfinger = new WebFinger({ 8const 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'
2import { generateVideoImportTmpPath } from './utils' 2import { generateVideoImportTmpPath } from './utils'
3import * as WebTorrent from 'webtorrent' 3import * as WebTorrent from 'webtorrent'
4import { createWriteStream, ensureDir, remove } from 'fs-extra' 4import { createWriteStream, ensureDir, remove } from 'fs-extra'
5import { CONFIG } from '../initializers' 5import { CONFIG } from '../initializers/config'
6import { dirname, join } from 'path' 6import { dirname, join } from 'path'
7 7
8async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) { 8async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName?: string }, timeout: number) {