1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Type models

This commit is contained in:
Chocobozzz 2017-05-22 20:58:25 +02:00
parent 65fcc3119c
commit e02643f32e
76 changed files with 1710 additions and 816 deletions

View file

@ -1,7 +1,7 @@
import { each, eachLimit, eachSeries, series, waterfall } from 'async'
import request = require('request')
const db = require('../initializers/database')
import { database as db } from '../initializers/database'
import {
API_VERSION,
CONFIG,
@ -329,7 +329,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) {
// Flush pool requests
requestScheduler.forceSend()
eachLimit(podsList, REQUESTS_IN_PARALLEL, function (pod: any, callbackEach) {
eachLimit(podsList, REQUESTS_IN_PARALLEL, function (pod: { host: string }, callbackEach) {
const params = {
url: REMOTE_SCHEME.HTTP + '://' + pod.host + '/api/' + API_VERSION + '/pods/',
method: 'POST',
@ -340,7 +340,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) {
}
}
makeRetryRequest(params, function (err, res, body) {
makeRetryRequest(params, function (err, res, body: { cert: string, email: string }) {
if (err) {
logger.error('Error with adding %s pod.', pod.host, { error: err })
// Don't break the process

View file

@ -1,4 +1,4 @@
const db = require('../../../initializers/database')
import { database as db } from '../../../initializers/database'
import { logger } from '../../../helpers'
import { addVideoToFriends } from '../../../lib'

View file

@ -1,6 +1,6 @@
import { forever, queue } from 'async'
const db = require('../../initializers/database')
import { database as db } from '../../initializers/database'
import {
JOBS_FETCHING_INTERVAL,
JOBS_FETCH_LIMIT_PER_CYCLE,
@ -24,7 +24,7 @@ class JobScheduler {
logger.info('Jobs scheduler activated.')
const jobsQueue = queue(this.processJob)
const jobsQueue = queue(this.processJob.bind(this))
// Finish processing jobs from a previous start
const state = JOB_STATES.PROCESSING
@ -58,7 +58,7 @@ class JobScheduler {
})
}
createJob (transaction, handlerName, handlerInputData, callback) {
createJob (transaction, handlerName: string, handlerInputData: object, callback) {
const createQuery = {
state: JOB_STATES.PENDING,
handlerName,

View file

@ -1,4 +1,4 @@
const db = require('../initializers/database')
import { database as db } from '../initializers/database'
import { logger } from '../helpers'
// ---------------------------------------------------------------------------
@ -72,7 +72,7 @@ function saveToken (token, client, user) {
userId: user.id
}
return db.OAuthToken.create(tokenToCreate).then(function (tokenCreated) {
return db.OAuthToken.create(tokenToCreate).then(function (tokenCreated: any) {
tokenCreated.client = client
tokenCreated.user = user

View file

@ -1,6 +1,6 @@
import { eachLimit } from 'async/eachLimit'
import * as eachLimit from 'async/eachLimit'
const db = require('../../initializers/database')
import { database as db } from '../../initializers/database'
import { logger, makeSecureRequest } from '../../helpers'
import {
API_VERSION,

View file

@ -1,4 +1,4 @@
const db = require('../../initializers/database')
import { database as db } from '../../initializers/database'
import { BaseRequestScheduler } from './base-request-scheduler'
import { logger } from '../../helpers'
import {
@ -59,13 +59,14 @@ class RequestScheduler extends BaseRequestScheduler {
const toIds = options.toIds
const transaction = options.transaction
const pods = []
// TODO: check the setPods works
const podIds = []
// If there are no destination pods abort
if (toIds.length === 0) return callback(null)
toIds.forEach(toPod => {
pods.push(db.Pod.build({ id: toPod }))
podIds.push(toPod)
})
const createQuery = {
@ -83,7 +84,7 @@ class RequestScheduler extends BaseRequestScheduler {
return db.Request.create(createQuery, dbRequestOptions).asCallback((err, request) => {
if (err) return callback(err)
return request.setPods(pods, dbRequestOptions).asCallback(callback)
return request.setPods(podIds, dbRequestOptions).asCallback(callback)
})
}

View file

@ -1,4 +1,4 @@
const db = require('../../initializers/database')
import { database as db } from '../../initializers/database'
import { BaseRequestScheduler } from './base-request-scheduler'
import {
REQUESTS_VIDEO_EVENT_LIMIT_PODS,

View file

@ -1,4 +1,4 @@
const db = require('../../initializers/database')
import { database as db } from '../../initializers/database'
import { BaseRequestScheduler } from './base-request-scheduler'
import { logger } from '../../helpers'
import {