diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/core-utils.ts | 22 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 1 | ||||
-rw-r--r-- | server/helpers/index.ts | 1 | ||||
-rw-r--r-- | server/helpers/utils.ts | 13 |
4 files changed, 25 insertions, 12 deletions
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 | |||
6 | import { join } from 'path' | ||
7 | |||
8 | function isTestInstance () { | ||
9 | return process.env.NODE_ENV === 'test' | ||
10 | } | ||
11 | |||
12 | function root () { | ||
13 | // We are in /dist/helpers/utils.js | ||
14 | return join(__dirname, '..', '..', '..') | ||
15 | } | ||
16 | |||
17 | // --------------------------------------------------------------------------- | ||
18 | |||
19 | export { | ||
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 @@ | |||
1 | import { values } from 'lodash' | 1 | import { values } from 'lodash' |
2 | import * as validator from 'validator' | 2 | import * as validator from 'validator' |
3 | import 'multer' | ||
3 | 4 | ||
4 | import { | 5 | import { |
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 @@ | |||
1 | export * from './core-utils' | ||
1 | export * from './logger' | 2 | export * from './logger' |
2 | export * from './custom-validators' | 3 | export * from './custom-validators' |
3 | export * from './database-utils' | 4 | export * 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 | ||
26 | function isTestInstance () { | ||
27 | return process.env.NODE_ENV === 'test' | ||
28 | } | ||
29 | |||
30 | function getFormatedObjects (objects: any[], objectsTotal: number) { | 26 | function 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 | ||
43 | function root () { | ||
44 | // We are in /dist/helpers/utils.js | ||
45 | return join(__dirname, '..', '..', '..') | ||
46 | } | ||
47 | |||
48 | // --------------------------------------------------------------------------- | 39 | // --------------------------------------------------------------------------- |
49 | 40 | ||
50 | export { | 41 | export { |
51 | badRequest, | 42 | badRequest, |
52 | createEmptyCallback, | 43 | createEmptyCallback, |
53 | generateRandomString, | 44 | generateRandomString, |
54 | isTestInstance, | 45 | getFormatedObjects |
55 | getFormatedObjects, | ||
56 | root | ||
57 | } | 46 | } |