From 69818c9394366b954b6ba3bd697bd9d2b09f2a16 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 10 Jun 2017 22:15:25 +0200 Subject: Type functions --- server/controllers/api/clients.ts | 4 +-- server/controllers/api/config.ts | 2 +- server/controllers/api/index.ts | 2 +- server/controllers/api/pods.ts | 17 +++++++------ server/controllers/api/remote/pods.ts | 2 +- server/controllers/api/remote/videos.ts | 40 ++++++++++++++++-------------- server/controllers/api/requests.ts | 5 ++-- server/controllers/api/users.ts | 22 ++++++++-------- server/controllers/api/videos/abuse.ts | 9 ++++--- server/controllers/api/videos/blacklist.ts | 2 +- server/controllers/api/videos/index.ts | 29 +++++++++++----------- server/controllers/api/videos/rate.ts | 7 +++--- 12 files changed, 75 insertions(+), 66 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/clients.ts b/server/controllers/api/clients.ts index f6499556a..8c460096b 100644 --- a/server/controllers/api/clients.ts +++ b/server/controllers/api/clients.ts @@ -1,6 +1,6 @@ import * as express from 'express' -import { CONFIG } from '../../initializers'; +import { CONFIG } from '../../initializers' import { logger } from '../../helpers' import { database as db } from '../../initializers/database' @@ -9,7 +9,7 @@ const clientsRouter = express.Router() clientsRouter.get('/local', getLocalClient) // Get the client credentials for the PeerTube front end -function getLocalClient (req, res, next) { +function getLocalClient (req: express.Request, res: express.Response, next: express.NextFunction) { const serverHostname = CONFIG.WEBSERVER.HOSTNAME const serverPort = CONFIG.WEBSERVER.PORT let headerHostShouldBe = serverHostname diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 57c9398ec..c63981797 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -7,7 +7,7 @@ const configRouter = express.Router() configRouter.get('/', getConfig) // Get the client credentials for the PeerTube front end -function getConfig (req, res, next) { +function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { res.json({ signup: { enabled: CONFIG.SIGNUP.ENABLED diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts index 98004544d..ac3972ac6 100644 --- a/server/controllers/api/index.ts +++ b/server/controllers/api/index.ts @@ -28,6 +28,6 @@ export { apiRouter } // --------------------------------------------------------------------------- -function pong (req, res, next) { +function pong (req: express.Request, res: express.Response, next: express.NextFunction) { return res.send('pong').status(200).end() } diff --git a/server/controllers/api/pods.ts b/server/controllers/api/pods.ts index a028c4ab9..283105f6c 100644 --- a/server/controllers/api/pods.ts +++ b/server/controllers/api/pods.ts @@ -21,6 +21,9 @@ import { setBodyHostPort, setBodyHostsPort } from '../../middlewares' +import { + PodInstance +} from '../../models' const podsRouter = express.Router() @@ -51,10 +54,10 @@ export { // --------------------------------------------------------------------------- -function addPods (req, res, next) { +function addPods (req: express.Request, res: express.Response, next: express.NextFunction) { const informations = req.body - waterfall([ + waterfall([ function addPod (callback) { const pod = db.Pod.build(informations) pod.save().asCallback(function (err, podCreated) { @@ -63,7 +66,7 @@ function addPods (req, res, next) { }) }, - function sendMyVideos (podCreated, callback) { + function sendMyVideos (podCreated: PodInstance, callback) { sendOwnedVideosToPod(podCreated.id) callback(null) @@ -86,7 +89,7 @@ function addPods (req, res, next) { }) } -function listPods (req, res, next) { +function listPods (req: express.Request, res: express.Response, next: express.NextFunction) { db.Pod.list(function (err, podsList) { if (err) return next(err) @@ -94,8 +97,8 @@ function listPods (req, res, next) { }) } -function makeFriendsController (req, res, next) { - const hosts = req.body.hosts +function makeFriendsController (req: express.Request, res: express.Response, next: express.NextFunction) { + const hosts = req.body.hosts as string[] makeFriends(hosts, function (err) { if (err) { @@ -109,7 +112,7 @@ function makeFriendsController (req, res, next) { res.type('json').status(204).end() } -function quitFriendsController (req, res, next) { +function quitFriendsController (req: express.Request, res: express.Response, next: express.NextFunction) { quitFriends(function (err) { if (err) return next(err) diff --git a/server/controllers/api/remote/pods.ts b/server/controllers/api/remote/pods.ts index 9c9d2164d..b0d6642c1 100644 --- a/server/controllers/api/remote/pods.ts +++ b/server/controllers/api/remote/pods.ts @@ -21,7 +21,7 @@ export { // --------------------------------------------------------------------------- -function removePods (req, res, next) { +function removePods (req: express.Request, res: express.Response, next: express.NextFunction) { const host = req.body.signature.host waterfall([ diff --git a/server/controllers/api/remote/videos.ts b/server/controllers/api/remote/videos.ts index d97a3db31..d9cc08fb4 100644 --- a/server/controllers/api/remote/videos.ts +++ b/server/controllers/api/remote/videos.ts @@ -1,4 +1,5 @@ import * as express from 'express' +import * as Sequelize from 'sequelize' import { eachSeries, waterfall } from 'async' import { database as db } from '../../../initializers/database' @@ -23,6 +24,7 @@ import { startSerializableTransaction } from '../../../helpers' import { quickAndDirtyUpdatesVideoToFriends } from '../../../lib' +import { PodInstance, VideoInstance } from '../../../models' const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] @@ -64,7 +66,7 @@ export { // --------------------------------------------------------------------------- -function remoteVideos (req, res, next) { +function remoteVideos (req: express.Request, res: express.Response, next: express.NextFunction) { const requests = req.body.data const fromPod = res.locals.secure.pod @@ -89,7 +91,7 @@ function remoteVideos (req, res, next) { return res.type('json').status(204).end() } -function remoteVideosQadu (req, res, next) { +function remoteVideosQadu (req: express.Request, res: express.Response, next: express.NextFunction) { const requests = req.body.data const fromPod = res.locals.secure.pod @@ -104,7 +106,7 @@ function remoteVideosQadu (req, res, next) { return res.type('json').status(204).end() } -function remoteVideosEvents (req, res, next) { +function remoteVideosEvents (req: express.Request, res: express.Response, next: express.NextFunction) { const requests = req.body.data const fromPod = res.locals.secure.pod @@ -119,7 +121,7 @@ function remoteVideosEvents (req, res, next) { return res.type('json').status(204).end() } -function processVideosEventsRetryWrapper (eventData, fromPod, finalCallback) { +function processVideosEventsRetryWrapper (eventData: any, fromPod: PodInstance, finalCallback: (err: Error) => void) { const options = { arguments: [ eventData, fromPod ], errorMessage: 'Cannot process videos events with many retries.' @@ -128,7 +130,7 @@ function processVideosEventsRetryWrapper (eventData, fromPod, finalCallback) { retryTransactionWrapper(processVideosEvents, options, finalCallback) } -function processVideosEvents (eventData, fromPod, finalCallback) { +function processVideosEvents (eventData: any, fromPod: PodInstance, finalCallback: (err: Error) => void) { waterfall([ startSerializableTransaction, @@ -187,7 +189,7 @@ function processVideosEvents (eventData, fromPod, finalCallback) { commitTransaction - ], function (err, t) { + ], function (err: Error, t: Sequelize.Transaction) { if (err) { logger.debug('Cannot process a video event.', { error: err }) return rollbackTransaction(err, t, finalCallback) @@ -198,7 +200,7 @@ function processVideosEvents (eventData, fromPod, finalCallback) { }) } -function quickAndDirtyUpdateVideoRetryWrapper (videoData, fromPod, finalCallback) { +function quickAndDirtyUpdateVideoRetryWrapper (videoData: any, fromPod: PodInstance, finalCallback: (err: Error) => void) { const options = { arguments: [ videoData, fromPod ], errorMessage: 'Cannot update quick and dirty the remote video with many retries.' @@ -207,7 +209,7 @@ function quickAndDirtyUpdateVideoRetryWrapper (videoData, fromPod, finalCallback retryTransactionWrapper(quickAndDirtyUpdateVideo, options, finalCallback) } -function quickAndDirtyUpdateVideo (videoData, fromPod, finalCallback) { +function quickAndDirtyUpdateVideo (videoData: any, fromPod: PodInstance, finalCallback: (err: Error) => void) { let videoName waterfall([ @@ -243,7 +245,7 @@ function quickAndDirtyUpdateVideo (videoData, fromPod, finalCallback) { commitTransaction - ], function (err, t) { + ], function (err: Error, t: Sequelize.Transaction) { if (err) { logger.debug('Cannot quick and dirty update the remote video.', { error: err }) return rollbackTransaction(err, t, finalCallback) @@ -255,7 +257,7 @@ function quickAndDirtyUpdateVideo (videoData, fromPod, finalCallback) { } // Handle retries on fail -function addRemoteVideoRetryWrapper (videoToCreateData, fromPod, finalCallback) { +function addRemoteVideoRetryWrapper (videoToCreateData: any, fromPod: PodInstance, finalCallback: (err: Error) => void) { const options = { arguments: [ videoToCreateData, fromPod ], errorMessage: 'Cannot insert the remote video with many retries.' @@ -264,7 +266,7 @@ function addRemoteVideoRetryWrapper (videoToCreateData, fromPod, finalCallback) retryTransactionWrapper(addRemoteVideo, options, finalCallback) } -function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { +function addRemoteVideo (videoToCreateData: any, fromPod: PodInstance, finalCallback: (err: Error) => void) { logger.debug('Adding remote video "%s".', videoToCreateData.remoteId) waterfall([ @@ -359,7 +361,7 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { commitTransaction - ], function (err, t) { + ], function (err: Error, t: Sequelize.Transaction) { if (err) { // This is just a debug because we will retry the insert logger.debug('Cannot insert the remote video.', { error: err }) @@ -372,7 +374,7 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { } // Handle retries on fail -function updateRemoteVideoRetryWrapper (videoAttributesToUpdate, fromPod, finalCallback) { +function updateRemoteVideoRetryWrapper (videoAttributesToUpdate: any, fromPod: PodInstance, finalCallback: (err: Error) => void) { const options = { arguments: [ videoAttributesToUpdate, fromPod ], errorMessage: 'Cannot update the remote video with many retries' @@ -381,7 +383,7 @@ function updateRemoteVideoRetryWrapper (videoAttributesToUpdate, fromPod, finalC retryTransactionWrapper(updateRemoteVideo, options, finalCallback) } -function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) { +function updateRemoteVideo (videoAttributesToUpdate: any, fromPod: PodInstance, finalCallback: (err: Error) => void) { logger.debug('Updating remote video "%s".', videoAttributesToUpdate.remoteId) waterfall([ @@ -435,7 +437,7 @@ function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) { commitTransaction - ], function (err, t) { + ], function (err: Error, t: Sequelize.Transaction) { if (err) { // This is just a debug because we will retry the insert logger.debug('Cannot update the remote video.', { error: err }) @@ -447,7 +449,7 @@ function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) { }) } -function removeRemoteVideo (videoToRemoveData, fromPod, callback) { +function removeRemoteVideo (videoToRemoveData: any, fromPod: PodInstance, callback: (err: Error) => void) { // We need the instance because we have to remove some other stuffs (thumbnail etc) fetchRemoteVideo(fromPod.host, videoToRemoveData.remoteId, function (err, video) { // Do not return the error, continue the process @@ -465,7 +467,7 @@ function removeRemoteVideo (videoToRemoveData, fromPod, callback) { }) } -function reportAbuseRemoteVideo (reportData, fromPod, callback) { +function reportAbuseRemoteVideo (reportData: any, fromPod: PodInstance, callback: (err: Error) => void) { fetchOwnedVideo(reportData.videoRemoteId, function (err, video) { if (err || !video) { if (!err) err = new Error('video not found') @@ -494,7 +496,7 @@ function reportAbuseRemoteVideo (reportData, fromPod, callback) { }) } -function fetchOwnedVideo (id, callback) { +function fetchOwnedVideo (id: string, callback: (err: Error, video?: VideoInstance) => void) { db.Video.load(id, function (err, video) { if (err || !video) { if (!err) err = new Error('video not found') @@ -507,7 +509,7 @@ function fetchOwnedVideo (id, callback) { }) } -function fetchRemoteVideo (podHost, remoteId, callback) { +function fetchRemoteVideo (podHost: string, remoteId: string, callback: (err: Error, video?: VideoInstance) => void) { db.Video.loadByHostAndRemoteId(podHost, remoteId, function (err, video) { if (err || !video) { if (!err) err = new Error('video not found') diff --git a/server/controllers/api/requests.ts b/server/controllers/api/requests.ts index ff4b4ac1a..2c18fe046 100644 --- a/server/controllers/api/requests.ts +++ b/server/controllers/api/requests.ts @@ -2,6 +2,7 @@ import * as express from 'express' import { parallel } from 'async' import { + BaseRequestScheduler, getRequestScheduler, getRequestVideoQaduScheduler, getRequestVideoEventScheduler @@ -24,7 +25,7 @@ export { // --------------------------------------------------------------------------- -function getStatsRequests (req, res, next) { +function getStatsRequests (req: express.Request, res: express.Response, next: express.NextFunction) { parallel({ requestScheduler: buildRequestSchedulerFunction(getRequestScheduler()), requestVideoQaduScheduler: buildRequestSchedulerFunction(getRequestVideoQaduScheduler()), @@ -38,7 +39,7 @@ function getStatsRequests (req, res, next) { // --------------------------------------------------------------------------- -function buildRequestSchedulerFunction (requestScheduler) { +function buildRequestSchedulerFunction (requestScheduler: BaseRequestScheduler) { return function (callback) { requestScheduler.remainingRequestsCount(function (err, count) { if (err) return callback(err) diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 44c5ec13c..ffe5881e5 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts @@ -76,7 +76,7 @@ export { // --------------------------------------------------------------------------- -function ensureRegistrationEnabled (req, res, next) { +function ensureRegistrationEnabled (req: express.Request, res: express.Response, next: express.NextFunction) { const registrationEnabled = CONFIG.SIGNUP.ENABLED if (registrationEnabled === true) { @@ -86,7 +86,7 @@ function ensureRegistrationEnabled (req, res, next) { return res.status(400).send('User registration is not enabled.') } -function createUser (req, res, next) { +function createUser (req: express.Request, res: express.Response, next: express.NextFunction) { const user = db.User.build({ username: req.body.username, password: req.body.password, @@ -95,14 +95,14 @@ function createUser (req, res, next) { role: USER_ROLES.USER }) - user.save().asCallback(function (err, createdUser) { + user.save().asCallback(function (err) { if (err) return next(err) return res.type('json').status(204).end() }) } -function getUserInformation (req, res, next) { +function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) { db.User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) { if (err) return next(err) @@ -110,9 +110,9 @@ function getUserInformation (req, res, next) { }) } -function getUserVideoRating (req, res, next) { - const videoId = req.params.videoId - const userId = res.locals.oauth.token.User.id +function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) { + const videoId = '' + req.params.videoId + const userId = +res.locals.oauth.token.User.id db.UserVideoRate.load(userId, videoId, null, function (err, ratingObj) { if (err) return next(err) @@ -126,7 +126,7 @@ function getUserVideoRating (req, res, next) { }) } -function listUsers (req, res, next) { +function listUsers (req: express.Request, res: express.Response, next: express.NextFunction) { db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) { if (err) return next(err) @@ -134,7 +134,7 @@ function listUsers (req, res, next) { }) } -function removeUser (req, res, next) { +function removeUser (req: express.Request, res: express.Response, next: express.NextFunction) { waterfall([ function loadUser (callback) { db.User.loadById(req.params.id, callback) @@ -153,7 +153,7 @@ function removeUser (req, res, next) { }) } -function updateUser (req, res, next) { +function updateUser (req: express.Request, res: express.Response, next: express.NextFunction) { db.User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) { if (err) return next(err) @@ -168,6 +168,6 @@ function updateUser (req, res, next) { }) } -function success (req, res, next) { +function success (req: express.Request, res: express.Response, next: express.NextFunction) { res.end() } diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts index 68db025b7..78e8e8b3d 100644 --- a/server/controllers/api/videos/abuse.ts +++ b/server/controllers/api/videos/abuse.ts @@ -1,4 +1,5 @@ import * as express from 'express' +import * as Sequelize from 'sequelize' import { waterfall } from 'async' import { database as db } from '../../../initializers/database' @@ -46,7 +47,7 @@ export { // --------------------------------------------------------------------------- -function listVideoAbuses (req, res, next) { +function listVideoAbuses (req: express.Request, res: express.Response, next: express.NextFunction) { db.VideoAbuse.listForApi(req.query.start, req.query.count, req.query.sort, function (err, abusesList, abusesTotal) { if (err) return next(err) @@ -54,7 +55,7 @@ function listVideoAbuses (req, res, next) { }) } -function reportVideoAbuseRetryWrapper (req, res, next) { +function reportVideoAbuseRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { const options = { arguments: [ req, res ], errorMessage: 'Cannot report abuse to the video with many retries.' @@ -67,7 +68,7 @@ function reportVideoAbuseRetryWrapper (req, res, next) { }) } -function reportVideoAbuse (req, res, finalCallback) { +function reportVideoAbuse (req: express.Request, res: express.Response, finalCallback: (err: Error) => void) { const videoInstance = res.locals.video const reporterUsername = res.locals.oauth.token.User.username @@ -105,7 +106,7 @@ function reportVideoAbuse (req, res, finalCallback) { commitTransaction - ], function andFinally (err, t) { + ], function andFinally (err: Error, t: Sequelize.Transaction) { if (err) { logger.debug('Cannot update the video.', { error: err }) return rollbackTransaction(err, t, finalCallback) diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index 58960798b..4b42fc2d7 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts @@ -25,7 +25,7 @@ export { // --------------------------------------------------------------------------- -function addVideoToBlacklist (req, res, next) { +function addVideoToBlacklist (req: express.Request, res: express.Response, next: express.NextFunction) { const videoInstance = res.locals.video const toCreate = { diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index b82b0936f..bfa018031 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -1,4 +1,5 @@ import * as express from 'express' +import * as Sequelize from 'sequelize' import * as fs from 'fs' import * as multer from 'multer' import * as path from 'path' @@ -124,21 +125,21 @@ export { // --------------------------------------------------------------------------- -function listVideoCategories (req, res, next) { +function listVideoCategories (req: express.Request, res: express.Response, next: express.NextFunction) { res.json(VIDEO_CATEGORIES) } -function listVideoLicences (req, res, next) { +function listVideoLicences (req: express.Request, res: express.Response, next: express.NextFunction) { res.json(VIDEO_LICENCES) } -function listVideoLanguages (req, res, next) { +function listVideoLanguages (req: express.Request, res: express.Response, next: express.NextFunction) { res.json(VIDEO_LANGUAGES) } // Wrapper to video add that retry the function if there is a database error // We need this because we run the transaction in SERIALIZABLE isolation that can fail -function addVideoRetryWrapper (req, res, next) { +function addVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { const options = { arguments: [ req, res, req.files.videofile[0] ], errorMessage: 'Cannot insert the video with many retries.' @@ -152,7 +153,7 @@ function addVideoRetryWrapper (req, res, next) { }) } -function addVideo (req, res, videoFile, finalCallback) { +function addVideo (req: express.Request, res: express.Response, videoFile: Express.Multer.File, finalCallback: (err: Error) => void) { const videoInfos = req.body waterfall([ @@ -190,7 +191,7 @@ function addVideo (req, res, videoFile, finalCallback) { language: videoInfos.language, nsfw: videoInfos.nsfw, description: videoInfos.description, - duration: videoFile.duration, + duration: videoFile['duration'], // duration was added by a previous middleware authorId: author.id } @@ -254,7 +255,7 @@ function addVideo (req, res, videoFile, finalCallback) { commitTransaction - ], function andFinally (err, t) { + ], function andFinally (err: Error, t: Sequelize.Transaction) { if (err) { // This is just a debug because we will retry the insert logger.debug('Cannot insert the video.', { error: err }) @@ -266,7 +267,7 @@ function addVideo (req, res, videoFile, finalCallback) { }) } -function updateVideoRetryWrapper (req, res, next) { +function updateVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { const options = { arguments: [ req, res ], errorMessage: 'Cannot update the video with many retries.' @@ -280,7 +281,7 @@ function updateVideoRetryWrapper (req, res, next) { }) } -function updateVideo (req, res, finalCallback) { +function updateVideo (req: express.Request, res: express.Response, finalCallback: (err: Error) => void) { const videoInstance = res.locals.video const videoFieldsSave = videoInstance.toJSON() const videoInfosToUpdate = req.body @@ -341,7 +342,7 @@ function updateVideo (req, res, finalCallback) { commitTransaction - ], function andFinally (err, t) { + ], function andFinally (err: Error, t: Sequelize.Transaction) { if (err) { logger.debug('Cannot update the video.', { error: err }) @@ -361,7 +362,7 @@ function updateVideo (req, res, finalCallback) { }) } -function getVideo (req, res, next) { +function getVideo (req: express.Request, res: express.Response, next: express.NextFunction) { const videoInstance = res.locals.video if (videoInstance.isOwned()) { @@ -393,7 +394,7 @@ function getVideo (req, res, next) { res.json(videoInstance.toFormatedJSON()) } -function listVideos (req, res, next) { +function listVideos (req: express.Request, res: express.Response, next: express.NextFunction) { db.Video.listForApi(req.query.start, req.query.count, req.query.sort, function (err, videosList, videosTotal) { if (err) return next(err) @@ -401,7 +402,7 @@ function listVideos (req, res, next) { }) } -function removeVideo (req, res, next) { +function removeVideo (req: express.Request, res: express.Response, next: express.NextFunction) { const videoInstance = res.locals.video videoInstance.destroy().asCallback(function (err) { @@ -414,7 +415,7 @@ function removeVideo (req, res, next) { }) } -function searchVideos (req, res, next) { +function searchVideos (req: express.Request, res: express.Response, next: express.NextFunction) { db.Video.searchAndPopulateAuthorAndPodAndTags( req.params.value, req.query.field, req.query.start, req.query.count, req.query.sort, function (err, videosList, videosTotal) { diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 1bc575675..afdd099f8 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -1,4 +1,5 @@ import * as express from 'express' +import * as Sequelize from 'sequelize' import { waterfall } from 'async' import { database as db } from '../../../initializers/database' @@ -39,7 +40,7 @@ export { // --------------------------------------------------------------------------- -function rateVideoRetryWrapper (req, res, next) { +function rateVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { const options = { arguments: [ req, res ], errorMessage: 'Cannot update the user video rate.' @@ -52,7 +53,7 @@ function rateVideoRetryWrapper (req, res, next) { }) } -function rateVideo (req, res, finalCallback) { +function rateVideo (req: express.Request, res: express.Response, finalCallback: (err: Error) => void) { const rateType = req.body.rating const videoInstance = res.locals.video const userInstance = res.locals.oauth.token.User @@ -168,7 +169,7 @@ function rateVideo (req, res, finalCallback) { commitTransaction - ], function (err, t) { + ], function (err: Error, t: Sequelize.Transaction) { if (err) { // This is just a debug because we will retry the insert logger.debug('Cannot add the user video rate.', { error: err }) -- cgit v1.2.3