aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r--server/helpers/utils.ts16
1 files changed, 6 insertions, 10 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index bc76cfb26..1dcbd31c4 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -1,13 +1,15 @@
1import * as express from 'express'
2
1import { pseudoRandomBytes } from 'crypto' 3import { pseudoRandomBytes } from 'crypto'
2import { join } from 'path' 4import { join } from 'path'
3 5
4import { logger } from './logger' 6import { logger } from './logger'
5 7
6function badRequest (req, res, next) { 8function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) {
7 res.type('json').status(400).end() 9 res.type('json').status(400).end()
8} 10}
9 11
10function generateRandomString (size, callback) { 12function generateRandomString (size: number, callback: (err: Error, randomString?: string) => void) {
11 pseudoRandomBytes(size, function (err, raw) { 13 pseudoRandomBytes(size, function (err, raw) {
12 if (err) return callback(err) 14 if (err) return callback(err)
13 15
@@ -15,11 +17,6 @@ function generateRandomString (size, callback) {
15 }) 17 })
16} 18}
17 19
18function cleanForExit (webtorrentProcess) {
19 logger.info('Gracefully exiting.')
20 process.kill(-webtorrentProcess.pid)
21}
22
23function createEmptyCallback () { 20function createEmptyCallback () {
24 return function (err) { 21 return function (err) {
25 if (err) logger.error('Error in empty callback.', { error: err }) 22 if (err) logger.error('Error in empty callback.', { error: err })
@@ -27,10 +24,10 @@ function createEmptyCallback () {
27} 24}
28 25
29function isTestInstance () { 26function isTestInstance () {
30 return (process.env.NODE_ENV === 'test') 27 return process.env.NODE_ENV === 'test'
31} 28}
32 29
33function getFormatedObjects (objects, objectsTotal) { 30function getFormatedObjects (objects: any[], objectsTotal: number) {
34 const formatedObjects = [] 31 const formatedObjects = []
35 32
36 objects.forEach(function (object) { 33 objects.forEach(function (object) {
@@ -53,7 +50,6 @@ function root () {
53export { 50export {
54 badRequest, 51 badRequest,
55 createEmptyCallback, 52 createEmptyCallback,
56 cleanForExit,
57 generateRandomString, 53 generateRandomString,
58 isTestInstance, 54 isTestInstance,
59 getFormatedObjects, 55 getFormatedObjects,