X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Futils.js;h=9f4b145825758c304c4ef1aeb18402d16f90e364;hb=b981a525c37d226b3fa59287a6ce338f54583d0c;hp=7e0c9823c5a3842ebbd648ce572368902eb42376;hpb=a6fd2b30bf717eec14972a2175354781f5f43e77;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/utils.js b/server/helpers/utils.js index 7e0c9823c..9f4b14582 100644 --- a/server/helpers/utils.js +++ b/server/helpers/utils.js @@ -8,7 +8,8 @@ const utils = { badRequest, cleanForExit, generateRandomString, - isTestInstance + isTestInstance, + getFormatedObjects } function badRequest (req, res, next) { @@ -32,6 +33,19 @@ function isTestInstance () { return (process.env.NODE_ENV === 'test') } +function getFormatedObjects (objects, objectsTotal) { + const formatedObjects = [] + + objects.forEach(function (object) { + formatedObjects.push(object.toFormatedJSON()) + }) + + return { + total: objectsTotal, + data: formatedObjects + } +} + // --------------------------------------------------------------------------- module.exports = utils