]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/utils.ts
Update README schemas
[github/Chocobozzz/PeerTube.git] / server / helpers / utils.ts
index 1dcbd31c4c8ad1a7f463502a30ed1ca883277aeb..5b8d21f70d1cdfe0d9db79f7d625fae730184903 100644 (file)
@@ -1,7 +1,6 @@
 import * as express from 'express'
 
 import { pseudoRandomBytes } from 'crypto'
-import { join } from 'path'
 
 import { logger } from './logger'
 
@@ -23,12 +22,12 @@ function createEmptyCallback () {
   }
 }
 
-function isTestInstance () {
-  return process.env.NODE_ENV === 'test'
+interface FormatableToJSON {
+  toFormatedJSON()
 }
 
-function getFormatedObjects (objects: any[], objectsTotal: number) {
-  const formatedObjects = []
+function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], objectsTotal: number) {
+  const formatedObjects: U[] = []
 
   objects.forEach(function (object) {
     formatedObjects.push(object.toFormatedJSON())
@@ -40,18 +39,11 @@ function getFormatedObjects (objects: any[], objectsTotal: number) {
   }
 }
 
-function root () {
-  // We are in /dist/helpers/utils.js
-  return join(__dirname, '..', '..', '..')
-}
-
 // ---------------------------------------------------------------------------
 
 export {
   badRequest,
   createEmptyCallback,
   generateRandomString,
-  isTestInstance,
-  getFormatedObjects,
-  root
+  getFormatedObjects
 }