]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/utils.js
Server: we don't need the video name when removing a remote video
[github/Chocobozzz/PeerTube.git] / server / helpers / utils.js
index 9f27671b6f5712b8550dbfe4c5b378d6e703af66..9f4b145825758c304c4ef1aeb18402d16f90e364 100644 (file)
@@ -5,9 +5,15 @@ const crypto = require('crypto')
 const logger = require('./logger')
 
 const utils = {
+  badRequest,
   cleanForExit,
   generateRandomString,
-  isTestInstance
+  isTestInstance,
+  getFormatedObjects
+}
+
+function badRequest (req, res, next) {
+  res.type('json').status(400).end()
 }
 
 function generateRandomString (size, callback) {
@@ -27,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