X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Futils.js;h=7e0c9823c5a3842ebbd648ce572368902eb42376;hb=a6fd2b30bf717eec14972a2175354781f5f43e77;hp=9c2d402e3105047615d26bfe4ebd016deed2810d;hpb=a6375e69668ea42e19531c6bc68dcd37f3f7cbd7;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/utils.js b/server/helpers/utils.js index 9c2d402e3..7e0c9823c 100644 --- a/server/helpers/utils.js +++ b/server/helpers/utils.js @@ -5,8 +5,14 @@ const crypto = require('crypto') const logger = require('./logger') const utils = { + badRequest, cleanForExit, - generateRandomString + generateRandomString, + isTestInstance +} + +function badRequest (req, res, next) { + res.type('json').status(400).end() } function generateRandomString (size, callback) { @@ -22,6 +28,10 @@ function cleanForExit (webtorrentProcess) { process.kill(-webtorrentProcess.pid) } +function isTestInstance () { + return (process.env.NODE_ENV === 'test') +} + // --------------------------------------------------------------------------- module.exports = utils