aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/pods.ts2
-rw-r--r--server/helpers/custom-validators/remote/videos.ts6
-rw-r--r--server/helpers/custom-validators/videos.ts2
-rw-r--r--server/helpers/database-utils.ts14
-rw-r--r--server/helpers/utils.ts2
5 files changed, 11 insertions, 15 deletions
diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts
index ec9f26cc8..0519def52 100644
--- a/server/helpers/custom-validators/pods.ts
+++ b/server/helpers/custom-validators/pods.ts
@@ -9,7 +9,7 @@ function isHostValid (host: string) {
9function isEachUniqueHostValid (hosts: string[]) { 9function isEachUniqueHostValid (hosts: string[]) {
10 return isArray(hosts) && 10 return isArray(hosts) &&
11 hosts.length !== 0 && 11 hosts.length !== 0 &&
12 hosts.every(function (host) { 12 hosts.every(host => {
13 return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host) 13 return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
14 }) 14 })
15} 15}
diff --git a/server/helpers/custom-validators/remote/videos.ts b/server/helpers/custom-validators/remote/videos.ts
index e14673cb3..b33d8c9be 100644
--- a/server/helpers/custom-validators/remote/videos.ts
+++ b/server/helpers/custom-validators/remote/videos.ts
@@ -33,7 +33,7 @@ const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS]
33 33
34function isEachRemoteRequestVideosValid (requests: any[]) { 34function isEachRemoteRequestVideosValid (requests: any[]) {
35 return isArray(requests) && 35 return isArray(requests) &&
36 requests.every(function (request) { 36 requests.every(request => {
37 const video = request.data 37 const video = request.data
38 38
39 if (!video) return false 39 if (!video) return false
@@ -63,7 +63,7 @@ function isEachRemoteRequestVideosValid (requests: any[]) {
63 63
64function isEachRemoteRequestVideosQaduValid (requests: any[]) { 64function isEachRemoteRequestVideosQaduValid (requests: any[]) {
65 return isArray(requests) && 65 return isArray(requests) &&
66 requests.every(function (request) { 66 requests.every(request => {
67 const video = request.data 67 const video = request.data
68 68
69 if (!video) return false 69 if (!video) return false
@@ -79,7 +79,7 @@ function isEachRemoteRequestVideosQaduValid (requests: any[]) {
79 79
80function isEachRemoteRequestVideosEventsValid (requests: any[]) { 80function isEachRemoteRequestVideosEventsValid (requests: any[]) {
81 return isArray(requests) && 81 return isArray(requests) &&
82 requests.every(function (request) { 82 requests.every(request => {
83 const eventData = request.data 83 const eventData = request.data
84 84
85 if (!eventData) return false 85 if (!eventData) return false
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index e335b09d1..62132acb1 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -68,7 +68,7 @@ function isVideoNameValid (value: string) {
68function isVideoTagsValid (tags: string[]) { 68function isVideoTagsValid (tags: string[]) {
69 return isArray(tags) && 69 return isArray(tags) &&
70 validator.isInt(tags.length.toString(), VIDEOS_CONSTRAINTS_FIELDS.TAGS) && 70 validator.isInt(tags.length.toString(), VIDEOS_CONSTRAINTS_FIELDS.TAGS) &&
71 tags.every(function (tag) { 71 tags.every(tag => {
72 return exists(tag) && validator.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG) 72 return exists(tag) && validator.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG)
73 }) 73 })
74} 74}
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index e174dc3e9..987e42eb0 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -8,13 +8,11 @@ type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[]
8function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) { 8function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) {
9 const args = options.arguments ? options.arguments : [] 9 const args = options.arguments ? options.arguments : []
10 10
11 return transactionRetryer( 11 return transactionRetryer(callback => {
12 function (callback) { 12 functionToRetry.apply(this, args)
13 functionToRetry.apply(this, args)
14 .then(result => callback(null, result)) 13 .then(result => callback(null, result))
15 .catch(err => callback(err)) 14 .catch(err => callback(err))
16 } 15 })
17 )
18 .catch(err => { 16 .catch(err => {
19 // Do not throw the error, continue the process 17 // Do not throw the error, continue the process
20 logger.error(options.errorMessage, err) 18 logger.error(options.errorMessage, err)
@@ -26,14 +24,12 @@ function transactionRetryer (func: Function) {
26 retry({ 24 retry({
27 times: 5, 25 times: 5,
28 26
29 errorFilter: function (err) { 27 errorFilter: err => {
30 const willRetry = (err.name === 'SequelizeDatabaseError') 28 const willRetry = (err.name === 'SequelizeDatabaseError')
31 logger.debug('Maybe retrying the transaction function.', { willRetry }) 29 logger.debug('Maybe retrying the transaction function.', { willRetry })
32 return willRetry 30 return willRetry
33 } 31 }
34 }, func, function (err) { 32 }, func, err => err ? rej(err) : res())
35 err ? rej(err) : res()
36 })
37 }) 33 })
38} 34}
39 35
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index e99a48393..9c08afb71 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -18,7 +18,7 @@ interface FormatableToJSON {
18function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) { 18function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) {
19 const formatedObjects: U[] = [] 19 const formatedObjects: U[] = []
20 20
21 objects.forEach(function (object) { 21 objects.forEach(object => {
22 formatedObjects.push(object.toFormatedJSON()) 22 formatedObjects.push(object.toFormatedJSON())
23 }) 23 })
24 24