Upgrade server packages
This commit is contained in:
parent
604e02abcb
commit
53abc4c272
|
@ -115,7 +115,7 @@
|
|||
"standard": "^10.0.0",
|
||||
"supertest": "^3.0.0",
|
||||
"tslint": "^5.7.0",
|
||||
"tslint-config-standard": "^6.0.0",
|
||||
"tslint-config-standard": "^7.0.0",
|
||||
"webtorrent": "^0.98.0"
|
||||
},
|
||||
"scripty": {
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
videoRateValidator,
|
||||
asyncMiddleware
|
||||
} from '../../../middlewares'
|
||||
import { UserVideoRateUpdate, VideoRateType } from '../../../../shared'
|
||||
import { UserVideoRateUpdate } from '../../../../shared'
|
||||
|
||||
const rateVideoRouter = express.Router()
|
||||
|
||||
|
@ -73,7 +73,7 @@ async function rateVideo (req: express.Request, res: express.Response) {
|
|||
if (rateType === 'none') { // Destroy previous rate
|
||||
await previousRate.destroy()
|
||||
} else { // Update previous rate
|
||||
previousRate.type = rateType as VideoRateType
|
||||
previousRate.type = rateType
|
||||
|
||||
await previousRate.save()
|
||||
}
|
||||
|
|
|
@ -122,9 +122,6 @@ async function generateWatchHtmlPage (req: express.Request, res: express.Respons
|
|||
videoPromise
|
||||
])
|
||||
|
||||
file = file as Buffer
|
||||
video = video as VideoInstance
|
||||
|
||||
const html = file.toString()
|
||||
|
||||
// Let Angular application handle errors
|
||||
|
|
|
@ -103,11 +103,11 @@ const writeFilePromise = promisify2WithVoid<string, any>(writeFile)
|
|||
const readdirPromise = promisify1<string, string[]>(readdir)
|
||||
const mkdirpPromise = promisify1<string, string>(mkdirp)
|
||||
const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes)
|
||||
const accessPromise = promisify1WithVoid<string|Buffer>(access)
|
||||
const accessPromise = promisify1WithVoid<string | Buffer>(access)
|
||||
const opensslExecPromise = promisify2WithVoid<string, any>(openssl.exec)
|
||||
const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare)
|
||||
const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt)
|
||||
const bcryptHashPromise = promisify2<any, string|number, string>(bcrypt.hash)
|
||||
const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash)
|
||||
const createTorrentPromise = promisify2<string, any, any>(createTorrent)
|
||||
const rimrafPromise = promisify1WithVoid<string>(rimraf)
|
||||
const statPromise = promisify1<string, Stats>(stat)
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as retry from 'async/retry'
|
|||
import { logger } from './logger'
|
||||
|
||||
type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] }
|
||||
function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) {
|
||||
function retryTransactionWrapper (functionToRetry: (...args) => Promise<any>, options: RetryTransactionWrapperOptions) {
|
||||
const args = options.arguments ? options.arguments : []
|
||||
|
||||
return transactionRetryer(callback => {
|
||||
|
|
|
@ -40,7 +40,7 @@ function checkSignature (publicKey: string, data: string, hexSignature: string)
|
|||
return isValid
|
||||
}
|
||||
|
||||
async function sign (data: string|Object) {
|
||||
async function sign (data: string | Object) {
|
||||
const sign = crypto.createSign(SIGNATURE_ALGORITHM)
|
||||
|
||||
let dataString: string
|
||||
|
@ -71,13 +71,13 @@ async function createCertsIfNotExist () {
|
|||
return
|
||||
}
|
||||
|
||||
return await createCerts()
|
||||
return createCerts()
|
||||
}
|
||||
|
||||
async function cryptPassword (password: string) {
|
||||
const salt = await bcryptGenSaltPromise(BCRYPT_SALT_SIZE)
|
||||
|
||||
return await bcryptHashPromise(password, salt)
|
||||
return bcryptHashPromise(password, salt)
|
||||
}
|
||||
|
||||
function getMyPrivateCert () {
|
||||
|
|
|
@ -13,7 +13,7 @@ import { sign } from './peertube-crypto'
|
|||
|
||||
type MakeRetryRequestParams = {
|
||||
url: string,
|
||||
method: 'GET'|'POST',
|
||||
method: 'GET' | 'POST',
|
||||
json: Object
|
||||
}
|
||||
function makeRetryRequest (params: MakeRetryRequestParams) {
|
||||
|
@ -31,7 +31,7 @@ function makeRetryRequest (params: MakeRetryRequestParams) {
|
|||
}
|
||||
|
||||
type MakeSecureRequestParams = {
|
||||
method: 'GET'|'POST'
|
||||
method: 'GET' | 'POST'
|
||||
toPod: PodInstance
|
||||
path: string
|
||||
data?: Object
|
||||
|
|
|
@ -34,7 +34,7 @@ async function up (utils: {
|
|||
// Create one author per user that does not already exist
|
||||
const users = await utils.db.User.findAll()
|
||||
for (const user of users) {
|
||||
const author = await utils.db.Author.find({ where: { userId: user.id }})
|
||||
const author = await utils.db.Author.find({ where: { userId: user.id } })
|
||||
if (!author) {
|
||||
await utils.db.Author.create({
|
||||
name: user.username,
|
||||
|
@ -72,7 +72,7 @@ async function up (utils: {
|
|||
const rawVideos = await utils.sequelize.query(query, options)
|
||||
|
||||
for (const rawVideo of rawVideos) {
|
||||
const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId }})
|
||||
const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } })
|
||||
|
||||
const video = await utils.db.Video.findById(rawVideo.id)
|
||||
video.channelId = videoChannel.id
|
||||
|
|
|
@ -3,10 +3,9 @@ import * as express from 'express'
|
|||
|
||||
import { database as db } from '../../initializers/database'
|
||||
import { checkErrors } from './utils'
|
||||
import { logger, isEachUniqueHostValid } from '../../helpers'
|
||||
import { logger, isEachUniqueHostValid, isTestInstance } from '../../helpers'
|
||||
import { CONFIG } from '../../initializers'
|
||||
import { hasFriends } from '../../lib'
|
||||
import { isTestInstance } from '../../helpers'
|
||||
|
||||
const makeFriendsValidator = [
|
||||
body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import * as Promise from 'bluebird'
|
||||
|
||||
import { getSort } from '../utils'
|
||||
import { getSort, addMethodsToModel } from '../utils'
|
||||
import {
|
||||
cryptPassword,
|
||||
comparePassword,
|
||||
|
@ -13,7 +13,6 @@ import {
|
|||
} from '../../helpers'
|
||||
import { UserRight, USER_ROLE_LABELS, hasUserRight } from '../../../shared'
|
||||
|
||||
import { addMethodsToModel } from '../utils'
|
||||
import {
|
||||
UserInstance,
|
||||
UserAttributes,
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import * as safeBuffer from 'safe-buffer'
|
||||
const Buffer = safeBuffer.Buffer
|
||||
import * as magnetUtil from 'magnet-uri'
|
||||
import { map } from 'lodash'
|
||||
import { map, maxBy, truncate } from 'lodash'
|
||||
import * as parseTorrent from 'parse-torrent'
|
||||
import { join } from 'path'
|
||||
import * as Sequelize from 'sequelize'
|
||||
import * as Promise from 'bluebird'
|
||||
import { maxBy, truncate } from 'lodash'
|
||||
|
||||
import { TagInstance } from './tag-interface'
|
||||
import {
|
||||
|
|
|
@ -106,7 +106,7 @@ describe('Test video abuses API validators', function () {
|
|||
it('Should fail with a wrong video', async function () {
|
||||
const wrongPath = '/api/v1/videos/blabla/abuse'
|
||||
const fields = {}
|
||||
await makePostBodyRequest({ url: server.url, path: wrongPath, token: server.accessToken, fields})
|
||||
await makePostBodyRequest({ url: server.url, path: wrongPath, token: server.accessToken, fields })
|
||||
})
|
||||
|
||||
it('Should fail with a non authenticated user', async function () {
|
||||
|
|
|
@ -25,12 +25,12 @@ describe('Test advanced friends', function () {
|
|||
|
||||
async function makeFriendsWrapper (podNumber: number) {
|
||||
const server = servers[podNumber - 1]
|
||||
return await makeFriends(server.url, server.accessToken)
|
||||
return makeFriends(server.url, server.accessToken)
|
||||
}
|
||||
|
||||
async function quitFriendsWrapper (podNumber: number) {
|
||||
const server = servers[podNumber - 1]
|
||||
return await quitFriends(server.url, server.accessToken)
|
||||
return quitFriends(server.url, server.accessToken)
|
||||
}
|
||||
|
||||
async function removeFriendWrapper (podNumber: number, podNumberToRemove: number) {
|
||||
|
@ -42,12 +42,12 @@ describe('Test advanced friends', function () {
|
|||
let friendsList = res.body.data
|
||||
let podToRemove = friendsList.find(friend => (friend.host === serverToRemove.host))
|
||||
|
||||
return await quitOneFriend(server.url, server.accessToken, podToRemove.id)
|
||||
return quitOneFriend(server.url, server.accessToken, podToRemove.id)
|
||||
}
|
||||
|
||||
async function getFriendsListWrapper (podNumber: number) {
|
||||
const server = servers[podNumber - 1]
|
||||
return await getFriendsList(server.url)
|
||||
return getFriendsList(server.url)
|
||||
}
|
||||
|
||||
async function uploadVideoWrapper (podNumber: number) {
|
||||
|
@ -56,11 +56,11 @@ describe('Test advanced friends', function () {
|
|||
}
|
||||
const server = servers[podNumber - 1]
|
||||
|
||||
return await uploadVideo(server.url, server.accessToken, videoAttributes)
|
||||
return uploadVideo(server.url, server.accessToken, videoAttributes)
|
||||
}
|
||||
|
||||
async function getVideosWrapper (podNumber: number) {
|
||||
return await getVideosList(servers[podNumber - 1].url)
|
||||
return getVideosList(servers[podNumber - 1].url)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
|
@ -80,11 +80,15 @@ start()
|
|||
async function start () {
|
||||
const servers = await runServers(numberOfPods)
|
||||
|
||||
process.on('exit', async () => await exitServers(servers, flushAtExit))
|
||||
process.on('exit', async () => {
|
||||
await exitServers(servers, flushAtExit)
|
||||
|
||||
return
|
||||
})
|
||||
process.on('SIGINT', goodbye)
|
||||
process.on('SIGTERM', goodbye)
|
||||
|
||||
console.log('Servers runned')
|
||||
console.log('Servers ran')
|
||||
initializeRequestsPerServer(servers)
|
||||
|
||||
let checking = false
|
||||
|
@ -150,10 +154,8 @@ function getRandomNumServer (servers) {
|
|||
}
|
||||
|
||||
async function runServers (numberOfPods: number) {
|
||||
let servers = null
|
||||
|
||||
// Run servers
|
||||
servers = await flushAndRunMultipleServers(numberOfPods)
|
||||
const servers: ServerInfo[] = (await flushAndRunMultipleServers(numberOfPods))
|
||||
.map(s => Object.assign({ requestsNumber: 0 }, s))
|
||||
|
||||
// Get the access tokens
|
||||
await setAccessTokensToServers(servers)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import * as program from 'commander'
|
||||
import * as Promise from 'bluebird'
|
||||
import { isAbsolute } from 'path'
|
||||
import { join } from 'path'
|
||||
import { isAbsolute, join } from 'path'
|
||||
|
||||
import { readdirPromise } from '../../../helpers/core-utils'
|
||||
import { execCLI } from '../../utils'
|
||||
|
|
|
@ -33,7 +33,7 @@ interface ServerInfo {
|
|||
}
|
||||
}
|
||||
|
||||
async function flushAndRunMultipleServers (totalServers) {
|
||||
function flushAndRunMultipleServers (totalServers) {
|
||||
let apps = []
|
||||
let i = 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue