Remove any typing from server
This commit is contained in:
parent
33c4972d5b
commit
e6d4b0ff24
|
@ -23,6 +23,7 @@ import {
|
||||||
import {
|
import {
|
||||||
PodInstance
|
PodInstance
|
||||||
} from '../../models'
|
} from '../../models'
|
||||||
|
import { Pod as FormatedPod } from '../../../shared'
|
||||||
|
|
||||||
const podsRouter = express.Router()
|
const podsRouter = express.Router()
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ function addPods (req: express.Request, res: express.Response, next: express.Nex
|
||||||
|
|
||||||
function listPods (req: express.Request, res: express.Response, next: express.NextFunction) {
|
function listPods (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||||
db.Pod.list()
|
db.Pod.list()
|
||||||
.then(podsList => res.json(getFormatedObjects(podsList, podsList.length)))
|
.then(podsList => res.json(getFormatedObjects<FormatedPod, PodInstance>(podsList, podsList.length)))
|
||||||
.catch(err => next(err))
|
.catch(err => next(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,9 @@ import {
|
||||||
RemoteVideoCreateData,
|
RemoteVideoCreateData,
|
||||||
RemoteVideoUpdateData,
|
RemoteVideoUpdateData,
|
||||||
RemoteVideoRemoveData,
|
RemoteVideoRemoveData,
|
||||||
RemoteVideoReportAbuseData
|
RemoteVideoReportAbuseData,
|
||||||
|
ResultList,
|
||||||
|
Pod as FormatedPod
|
||||||
} from '../../shared'
|
} from '../../shared'
|
||||||
|
|
||||||
type QaduParam = { videoId: string, type: RequestVideoQaduType }
|
type QaduParam = { videoId: string, type: RequestVideoQaduType }
|
||||||
|
@ -268,8 +270,8 @@ export {
|
||||||
|
|
||||||
function computeForeignPodsList (host: string, podsScore: { [ host: string ]: number }) {
|
function computeForeignPodsList (host: string, podsScore: { [ host: string ]: number }) {
|
||||||
// TODO: type res
|
// TODO: type res
|
||||||
return getForeignPodsList(host).then((res: any) => {
|
return getForeignPodsList(host).then(res => {
|
||||||
const foreignPodsList = res.data
|
const foreignPodsList: { host: string }[] = res.data
|
||||||
|
|
||||||
// Let's give 1 point to the pod we ask the friends list
|
// Let's give 1 point to the pod we ask the friends list
|
||||||
foreignPodsList.push({ host })
|
foreignPodsList.push({ host })
|
||||||
|
@ -302,7 +304,7 @@ function computeWinningPods (hosts: string[], podsScore: { [ host: string ]: num
|
||||||
}
|
}
|
||||||
|
|
||||||
function getForeignPodsList (host: string) {
|
function getForeignPodsList (host: string) {
|
||||||
return new Promise((res, rej) => {
|
return new Promise< ResultList<FormatedPod> >((res, rej) => {
|
||||||
const path = '/api/' + API_VERSION + '/pods'
|
const path = '/api/' + API_VERSION + '/pods'
|
||||||
|
|
||||||
request.get(REMOTE_SCHEME.HTTP + '://' + host + path, function (err, response, body) {
|
request.get(REMOTE_SCHEME.HTTP + '://' + host + path, function (err, response, body) {
|
||||||
|
|
|
@ -68,11 +68,10 @@ function saveToken (token: TokenInfo, client: OAuthClientInstance, user: UserIns
|
||||||
userId: user.id
|
userId: user.id
|
||||||
}
|
}
|
||||||
|
|
||||||
return db.OAuthToken.create(tokenToCreate).then(function (tokenCreated: any) {
|
return db.OAuthToken.create(tokenToCreate).then(tokenCreated => {
|
||||||
tokenCreated.client = client
|
const tokenToReturn = Object.assign(tokenCreated, { client, user })
|
||||||
tokenCreated.user = user
|
|
||||||
|
|
||||||
return tokenCreated
|
return tokenToReturn
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ function associate (models) {
|
||||||
findOrCreateTags = function (tags: string[], transaction: Sequelize.Transaction) {
|
findOrCreateTags = function (tags: string[], transaction: Sequelize.Transaction) {
|
||||||
const tasks: Promise<TagInstance>[] = []
|
const tasks: Promise<TagInstance>[] = []
|
||||||
tags.forEach(tag => {
|
tags.forEach(tag => {
|
||||||
const query: any = {
|
const query: Sequelize.FindOrInitializeOptions<TagAttributes> = {
|
||||||
where: {
|
where: {
|
||||||
name: tag
|
name: tag
|
||||||
},
|
},
|
||||||
|
|
|
@ -696,23 +696,23 @@ loadAndPopulateAuthorAndPodAndTags = function (id: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, start: number, count: number, sort: string) {
|
searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, start: number, count: number, sort: string) {
|
||||||
const podInclude: any = {
|
const podInclude: Sequelize.IncludeOptions = {
|
||||||
model: Video['sequelize'].models.Pod,
|
model: Video['sequelize'].models.Pod,
|
||||||
required: false
|
required: false
|
||||||
}
|
}
|
||||||
|
|
||||||
const authorInclude: any = {
|
const authorInclude: Sequelize.IncludeOptions = {
|
||||||
model: Video['sequelize'].models.Author,
|
model: Video['sequelize'].models.Author,
|
||||||
include: [
|
include: [
|
||||||
podInclude
|
podInclude
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const tagInclude: any = {
|
const tagInclude: Sequelize.IncludeOptions = {
|
||||||
model: Video['sequelize'].models.Tag
|
model: Video['sequelize'].models.Tag
|
||||||
}
|
}
|
||||||
|
|
||||||
const query: any = {
|
const query: Sequelize.FindOptions = {
|
||||||
distinct: true,
|
distinct: true,
|
||||||
where: createBaseVideosWhere(),
|
where: createBaseVideosWhere(),
|
||||||
offset: start,
|
offset: start,
|
||||||
|
@ -723,10 +723,10 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s
|
||||||
// Make an exact search with the magnet
|
// Make an exact search with the magnet
|
||||||
if (field === 'magnetUri') {
|
if (field === 'magnetUri') {
|
||||||
const infoHash = magnetUtil.decode(value).infoHash
|
const infoHash = magnetUtil.decode(value).infoHash
|
||||||
query.where.infoHash = infoHash
|
query.where['infoHash'] = infoHash
|
||||||
} else if (field === 'tags') {
|
} else if (field === 'tags') {
|
||||||
const escapedValue = Video['sequelize'].escape('%' + value + '%')
|
const escapedValue = Video['sequelize'].escape('%' + value + '%')
|
||||||
query.where.id.$in = Video['sequelize'].literal(
|
query.where['id'].$in = Video['sequelize'].literal(
|
||||||
`(SELECT "VideoTags"."videoId"
|
`(SELECT "VideoTags"."videoId"
|
||||||
FROM "Tags"
|
FROM "Tags"
|
||||||
INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId"
|
INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId"
|
||||||
|
@ -830,14 +830,14 @@ function createThumbnail (video: VideoInstance, videoPath: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateImage (video: VideoInstance, videoPath: string, folder: string, imageName: string, size: string) {
|
function generateImage (video: VideoInstance, videoPath: string, folder: string, imageName: string, size: string) {
|
||||||
const options: any = {
|
const options = {
|
||||||
filename: imageName,
|
filename: imageName,
|
||||||
count: 1,
|
count: 1,
|
||||||
folder
|
folder
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size) {
|
if (size) {
|
||||||
options.size = size
|
options['size'] = size
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise<string>((res, rej) => {
|
return new Promise<string>((res, rej) => {
|
||||||
|
|
Loading…
Reference in New Issue