aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/videos/index.ts1
-rw-r--r--server/helpers/core-utils.ts22
-rw-r--r--server/helpers/custom-validators/videos.ts1
-rw-r--r--server/helpers/index.ts1
-rw-r--r--server/helpers/utils.ts13
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/database.ts8
7 files changed, 30 insertions, 18 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index bfa018031..3b2ac4a6c 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -86,7 +86,6 @@ videosRouter.get('/',
86) 86)
87videosRouter.put('/:id', 87videosRouter.put('/:id',
88 authenticate, 88 authenticate,
89 reqFiles,
90 videosUpdateValidator, 89 videosUpdateValidator,
91 updateVideoRetryWrapper 90 updateVideoRetryWrapper
92) 91)
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
new file mode 100644
index 000000000..32b89b6dd
--- /dev/null
+++ b/server/helpers/core-utils.ts
@@ -0,0 +1,22 @@
1/*
2 Different from 'utils' because we don't not import other PeerTube modules.
3 Useful to avoid circular dependencies.
4*/
5
6import { join } from 'path'
7
8function isTestInstance () {
9 return process.env.NODE_ENV === 'test'
10}
11
12function root () {
13 // We are in /dist/helpers/utils.js
14 return join(__dirname, '..', '..', '..')
15}
16
17// ---------------------------------------------------------------------------
18
19export {
20 isTestInstance,
21 root
22}
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index c5ef4cb5f..8904975c0 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -1,5 +1,6 @@
1import { values } from 'lodash' 1import { values } from 'lodash'
2import * as validator from 'validator' 2import * as validator from 'validator'
3import 'multer'
3 4
4import { 5import {
5 CONSTRAINTS_FIELDS, 6 CONSTRAINTS_FIELDS,
diff --git a/server/helpers/index.ts b/server/helpers/index.ts
index e56bd21ad..78215fe10 100644
--- a/server/helpers/index.ts
+++ b/server/helpers/index.ts
@@ -1,3 +1,4 @@
1export * from './core-utils'
1export * from './logger' 2export * from './logger'
2export * from './custom-validators' 3export * from './custom-validators'
3export * from './database-utils' 4export * from './database-utils'
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 1dcbd31c4..8e489de96 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -23,10 +23,6 @@ function createEmptyCallback () {
23 } 23 }
24} 24}
25 25
26function isTestInstance () {
27 return process.env.NODE_ENV === 'test'
28}
29
30function getFormatedObjects (objects: any[], objectsTotal: number) { 26function getFormatedObjects (objects: any[], objectsTotal: number) {
31 const formatedObjects = [] 27 const formatedObjects = []
32 28
@@ -40,18 +36,11 @@ function getFormatedObjects (objects: any[], objectsTotal: number) {
40 } 36 }
41} 37}
42 38
43function root () {
44 // We are in /dist/helpers/utils.js
45 return join(__dirname, '..', '..', '..')
46}
47
48// --------------------------------------------------------------------------- 39// ---------------------------------------------------------------------------
49 40
50export { 41export {
51 badRequest, 42 badRequest,
52 createEmptyCallback, 43 createEmptyCallback,
53 generateRandomString, 44 generateRandomString,
54 isTestInstance, 45 getFormatedObjects
55 getFormatedObjects,
56 root
57} 46}
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 6dcb4bb91..b476ef928 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -2,7 +2,7 @@ import * as config from 'config'
2import { join } from 'path' 2import { join } from 'path'
3 3
4// Do not use barrels, remain constants as independent as possible 4// Do not use barrels, remain constants as independent as possible
5import { root, isTestInstance } from '../helpers/utils' 5import { root, isTestInstance } from '../helpers/core-utils'
6 6
7// --------------------------------------------------------------------------- 7// ---------------------------------------------------------------------------
8 8
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index 78ca5ab84..0ab9e98db 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -5,7 +5,7 @@ import * as Sequelize from 'sequelize'
5import { CONFIG } from './constants' 5import { CONFIG } from './constants'
6// Do not use barrel, we need to load database first 6// Do not use barrel, we need to load database first
7import { logger } from '../helpers/logger' 7import { logger } from '../helpers/logger'
8import { isTestInstance } from '../helpers/utils' 8import { isTestInstance } from '../helpers/core-utils'
9import { 9import {
10 ApplicationModel, 10 ApplicationModel,
11 AuthorModel, 11 AuthorModel,
@@ -80,9 +80,9 @@ database.init = function (silent: boolean, callback: (err: Error) => void) {
80 files.filter(function (file) { 80 files.filter(function (file) {
81 // For all models but not utils.js 81 // For all models but not utils.js
82 if ( 82 if (
83 file === 'index.js' || 83 file === 'index.js' || file === 'index.ts' ||
84 file === 'utils.js' || 84 file === 'utils.js' || file === 'utils.ts' ||
85 file.endsWith('-interface.js') || 85 file.endsWith('-interface.js') || file.endsWith('-interface.ts') ||
86 file.endsWith('.js.map') 86 file.endsWith('.js.map')
87 ) return false 87 ) return false
88 88