-import express = require('express')
+import * as express from 'express'
-const db = require('../../../initializers/database')
+import { database as db } from '../../../initializers/database'
import { logger } from '../../../helpers'
import {
authenticate,
// ---------------------------------------------------------------------------
-function addVideoToBlacklist (req, res, next) {
+function addVideoToBlacklist (req: express.Request, res: express.Response, next: express.NextFunction) {
const videoInstance = res.locals.video
const toCreate = {
videoId: videoInstance.id
}
- db.BlacklistedVideo.create(toCreate).asCallback(function (err) {
- if (err) {
+ db.BlacklistedVideo.create(toCreate)
+ .then(() => res.type('json').status(204).end())
+ .catch(err => {
logger.error('Errors when blacklisting video ', { error: err })
return next(err)
- }
-
- return res.type('json').status(204).end()
- })
+ })
}