mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Type functions
This commit is contained in:
parent
4d4e5cd4dc
commit
69818c9394
96 changed files with 990 additions and 544 deletions
|
@ -1,13 +1,15 @@
|
|||
import * as express from 'express'
|
||||
|
||||
import { pseudoRandomBytes } from 'crypto'
|
||||
import { join } from 'path'
|
||||
|
||||
import { logger } from './logger'
|
||||
|
||||
function badRequest (req, res, next) {
|
||||
function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
res.type('json').status(400).end()
|
||||
}
|
||||
|
||||
function generateRandomString (size, callback) {
|
||||
function generateRandomString (size: number, callback: (err: Error, randomString?: string) => void) {
|
||||
pseudoRandomBytes(size, function (err, raw) {
|
||||
if (err) return callback(err)
|
||||
|
||||
|
@ -15,11 +17,6 @@ function generateRandomString (size, callback) {
|
|||
})
|
||||
}
|
||||
|
||||
function cleanForExit (webtorrentProcess) {
|
||||
logger.info('Gracefully exiting.')
|
||||
process.kill(-webtorrentProcess.pid)
|
||||
}
|
||||
|
||||
function createEmptyCallback () {
|
||||
return function (err) {
|
||||
if (err) logger.error('Error in empty callback.', { error: err })
|
||||
|
@ -27,10 +24,10 @@ function createEmptyCallback () {
|
|||
}
|
||||
|
||||
function isTestInstance () {
|
||||
return (process.env.NODE_ENV === 'test')
|
||||
return process.env.NODE_ENV === 'test'
|
||||
}
|
||||
|
||||
function getFormatedObjects (objects, objectsTotal) {
|
||||
function getFormatedObjects (objects: any[], objectsTotal: number) {
|
||||
const formatedObjects = []
|
||||
|
||||
objects.forEach(function (object) {
|
||||
|
@ -53,7 +50,6 @@ function root () {
|
|||
export {
|
||||
badRequest,
|
||||
createEmptyCallback,
|
||||
cleanForExit,
|
||||
generateRandomString,
|
||||
isTestInstance,
|
||||
getFormatedObjects,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue