import {
PodInstance
} from '../../models'
+import { Pod as FormatedPod } from '../../../shared'
const podsRouter = express.Router()
function listPods (req: express.Request, res: express.Response, next: express.NextFunction) {
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))
}
RemoteVideoCreateData,
RemoteVideoUpdateData,
RemoteVideoRemoveData,
- RemoteVideoReportAbuseData
+ RemoteVideoReportAbuseData,
+ ResultList,
+ Pod as FormatedPod
} from '../../shared'
type QaduParam = { videoId: string, type: RequestVideoQaduType }
function computeForeignPodsList (host: string, podsScore: { [ host: string ]: number }) {
// TODO: type res
- return getForeignPodsList(host).then((res: any) => {
- const foreignPodsList = res.data
+ return getForeignPodsList(host).then(res => {
+ const foreignPodsList: { host: string }[] = res.data
// Let's give 1 point to the pod we ask the friends list
foreignPodsList.push({ host })
}
function getForeignPodsList (host: string) {
- return new Promise((res, rej) => {
+ return new Promise< ResultList<FormatedPod> >((res, rej) => {
const path = '/api/' + API_VERSION + '/pods'
request.get(REMOTE_SCHEME.HTTP + '://' + host + path, function (err, response, body) {
userId: user.id
}
- return db.OAuthToken.create(tokenToCreate).then(function (tokenCreated: any) {
- tokenCreated.client = client
- tokenCreated.user = user
+ return db.OAuthToken.create(tokenToCreate).then(tokenCreated => {
+ const tokenToReturn = Object.assign(tokenCreated, { client, user })
- return tokenCreated
+ return tokenToReturn
})
}
findOrCreateTags = function (tags: string[], transaction: Sequelize.Transaction) {
const tasks: Promise<TagInstance>[] = []
tags.forEach(tag => {
- const query: any = {
+ const query: Sequelize.FindOrInitializeOptions<TagAttributes> = {
where: {
name: tag
},
}
searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, start: number, count: number, sort: string) {
- const podInclude: any = {
+ const podInclude: Sequelize.IncludeOptions = {
model: Video['sequelize'].models.Pod,
required: false
}
- const authorInclude: any = {
+ const authorInclude: Sequelize.IncludeOptions = {
model: Video['sequelize'].models.Author,
include: [
podInclude
]
}
- const tagInclude: any = {
+ const tagInclude: Sequelize.IncludeOptions = {
model: Video['sequelize'].models.Tag
}
- const query: any = {
+ const query: Sequelize.FindOptions = {
distinct: true,
where: createBaseVideosWhere(),
offset: start,
// Make an exact search with the magnet
if (field === 'magnetUri') {
const infoHash = magnetUtil.decode(value).infoHash
- query.where.infoHash = infoHash
+ query.where['infoHash'] = infoHash
} else if (field === 'tags') {
const escapedValue = Video['sequelize'].escape('%' + value + '%')
- query.where.id.$in = Video['sequelize'].literal(
+ query.where['id'].$in = Video['sequelize'].literal(
`(SELECT "VideoTags"."videoId"
FROM "Tags"
INNER JOIN "VideoTags" ON "Tags"."id" = "VideoTags"."tagId"
}
function generateImage (video: VideoInstance, videoPath: string, folder: string, imageName: string, size: string) {
- const options: any = {
+ const options = {
filename: imageName,
count: 1,
folder
}
if (size) {
- options.size = size
+ options['size'] = size
}
return new Promise<string>((res, rej) => {