Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

esModuleInterop to true

Chocobozzz41fb13c330de
diff --git a/package.json b/package.json
index f627a9a349..b217e67cab 100644
--- a/package.json
+++ b/package.json
@@ -151,6 +151,7 @@
"@types/async": "^3.0.0",
"@types/async-lock": "^1.1.0",
"@types/bcrypt": "^5.0.0",
+ "@types/bencode": "^2.0.0",
"@types/bluebird": "^3.5.33",
"@types/body-parser": "^1.16.3",
"@types/bull": "^3.15.0",
@@ -159,6 +160,7 @@
"@types/chai-json-schema": "^1.4.3",
"@types/chai-xml": "^0.3.1",
"@types/config": "^0.0.39",
+ "@types/create-torrent": "^5.0.0",
"@types/express": "4.17.9",
"@types/express-rate-limit": "^5.0.0",
"@types/fluent-ffmpeg": "^2.1.16",
diff --git a/scripts/migrations/peertube-2.1.ts b/scripts/migrations/peertube-2.1.ts
index e17e581663..4bbc203c18 100644
--- a/scripts/migrations/peertube-2.1.ts
+++ b/scripts/migrations/peertube-2.1.ts
@@ -8,7 +8,7 @@ import { HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@serv
import { pathExists, stat, writeFile } from 'fs-extra'
import { createTorrentPromise } from '@server/helpers/webtorrent'
import { CONFIG } from '@server/initializers/config'
-import * as parseTorrent from 'parse-torrent'
+import parseTorrent from 'parse-torrent'
import { logger } from '@server/helpers/logger'
run()
diff --git a/scripts/print-transcode-command.ts b/scripts/print-transcode-command.ts
index d833632150..352145252c 100644
--- a/scripts/print-transcode-command.ts
+++ b/scripts/print-transcode-command.ts
@@ -2,7 +2,7 @@ import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { program } from 'commander'
-import * as ffmpeg from 'fluent-ffmpeg'
+import ffmpeg from 'fluent-ffmpeg'
import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils'
import { exit } from 'process'
import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/video-transcoding-profiles'
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts
index 5b029d215a..00141fec1a 100755
--- a/scripts/prune-storage.ts
+++ b/scripts/prune-storage.ts
@@ -1,14 +1,14 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
-import * as prompt from 'prompt'
+import { start, get } from 'prompt'
import { join, basename } from 'path'
import { CONFIG } from '../server/initializers/config'
import { VideoModel } from '../server/models/video/video'
import { initDatabaseModels } from '../server/initializers/database'
import { readdir, remove, stat } from 'fs-extra'
import { VideoRedundancyModel } from '../server/models/redundancy/video-redundancy'
-import * as Bluebird from 'bluebird'
+import { map } from 'bluebird'
import { getUUIDFromFilename } from '../server/helpers/utils'
import { ThumbnailModel } from '../server/models/video/thumbnail'
import { ActorImageModel } from '../server/models/actor/actor-image'
@@ -78,7 +78,7 @@ async function pruneDirectory (directory: string, existFun: ExistFun) {
const files = await readdir(directory)
const toDelete: string[] = []
- await Bluebird.map(files, async file => {
+ await map(files, async file => {
const filePath = join(directory, file)
if (await existFun(filePath) !== true) {
@@ -141,7 +141,7 @@ async function doesRedundancyExist (filePath: string) {
async function askConfirmation () {
return new Promise((res, rej) => {
- prompt.start()
+ start()
const schema = {
properties: {
confirm: {
@@ -154,7 +154,7 @@ async function askConfirmation () {
}
}
}
- prompt.get(schema, function (err, result) {
+ get(schema, function (err, result) {
if (err) return rej(err)
return res(result.confirm?.match(/y/) !== null)
diff --git a/scripts/regenerate-thumbnails.ts b/scripts/regenerate-thumbnails.ts
index 078f3830bf..8075f90bab 100644
--- a/scripts/regenerate-thumbnails.ts
+++ b/scripts/regenerate-thumbnails.ts
@@ -1,7 +1,7 @@
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
-import * as Bluebird from 'bluebird'
+import { map } from 'bluebird'
import { program } from 'commander'
import { pathExists, remove } from 'fs-extra'
import { generateImageFilename, processImage } from '@server/helpers/image-utils'
@@ -23,7 +23,7 @@ async function run () {
const videos = await VideoModel.listLocal()
- await Bluebird.map(videos, v => {
+ await map(videos, v => {
return processVideo(v)
.catch(err => console.error('Cannot process video %s.', v.url, err))
}, { concurrency: 20 })
diff --git a/server.ts b/server.ts
index bfc7ee1450..9af83cde9f 100644
--- a/server.ts
+++ b/server.ts
@@ -7,13 +7,13 @@ if (isTestInstance()) {
}
// ----------- Node modules -----------
-import * as express from 'express'
-import * as morgan from 'morgan'
-import * as cors from 'cors'
-import * as cookieParser from 'cookie-parser'
-import * as helmet from 'helmet'
-import * as useragent from 'useragent'
-import * as anonymize from 'ip-anonymize'
+import express from 'express'
+import morgan, { token } from 'morgan'
+import cors from 'cors'
+import cookieParser from 'cookie-parser'
+import { frameguard } from 'helmet'
+import { parse } from 'useragent'
+import anonymize from 'ip-anonymize'
import { program as cli } from 'commander'
process.title = 'peertube'
@@ -61,7 +61,7 @@ if (CONFIG.CSP.ENABLED) {
}
if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) {
- app.use(helmet.frameguard({
+ app.use(frameguard({
action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts
}))
}
@@ -148,16 +148,16 @@ if (isTestInstance()) {
}
// For the logger
-morgan.token('remote-addr', (req: express.Request) => {
+token('remote-addr', (req: express.Request) => {
if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') {
return anonymize(req.ip, 16, 16)
}
return req.ip
})
-morgan.token('user-agent', (req: express.Request) => {
+token('user-agent', (req: express.Request) => {
if (req.get('DNT') === '1') {
- return useragent.parse(req.get('user-agent')).family
+ return parse(req.get('user-agent')).family
}
return req.get('user-agent')
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index bef4bc068c..c4e3cec6b4 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -1,5 +1,5 @@
-import * as cors from 'cors'
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
import { getServerActor } from '@server/models/application/application'
import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models'
import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts
index 30662990a0..ece4edff0c 100644
--- a/server/controllers/activitypub/inbox.ts
+++ b/server/controllers/activitypub/inbox.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { InboxManager } from '@server/lib/activitypub/inbox-manager'
import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
diff --git a/server/controllers/activitypub/index.ts b/server/controllers/activitypub/index.ts
index 7e81902af7..8c681820ad 100644
--- a/server/controllers/activitypub/index.ts
+++ b/server/controllers/activitypub/index.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { activityPubClientRouter } from './client'
import { inboxRouter } from './inbox'
import { outboxRouter } from './outbox'
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts
index 22328da7f3..bdf9d138bf 100644
--- a/server/controllers/activitypub/outbox.ts
+++ b/server/controllers/activitypub/outbox.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { Activity } from '../../../shared/models/activitypub/activity'
import { VideoPrivacy } from '../../../shared/models/videos'
import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
diff --git a/server/controllers/activitypub/utils.ts b/server/controllers/activitypub/utils.ts
index 19bdd58eb2..f851ef652d 100644
--- a/server/controllers/activitypub/utils.ts
+++ b/server/controllers/activitypub/utils.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
function activityPubResponse (data: any, res: express.Response) {
return res.type('application/activity+json; charset=utf-8')
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index e851365e92..72c418e749 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { logger } from '@server/helpers/logger'
import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation'
import { Notifier } from '@server/lib/notifier'
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index 55e2aaf62d..75679b0f44 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { pickCommonVideoQuery } from '@server/helpers/query'
import { getServerActor } from '@server/models/application/application'
import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts
index 62121ece5a..d27c3c73e6 100644
--- a/server/controllers/api/bulk.ts
+++ b/server/controllers/api/bulk.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { removeComment } from '@server/lib/video-comment'
import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk'
import { VideoCommentModel } from '@server/models/video/video-comment'
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index ee733a38c8..d542f62aa3 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { remove, writeJSON } from 'fs-extra'
import { snakeCase } from 'lodash'
import validator from 'validator'
diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts
index 68d8c2ea49..d1c672f3fc 100644
--- a/server/controllers/api/custom-page.ts
+++ b/server/controllers/api/custom-page.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { ServerConfigManager } from '@server/lib/server-config-manager'
import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
import { HttpStatusCode, UserRight } from '@shared/models'
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index 93b14dadba..9949b378a0 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -1,6 +1,6 @@
-import * as cors from 'cors'
-import * as express from 'express'
-import * as RateLimit from 'express-rate-limit'
+import cors from 'cors'
+import express from 'express'
+import RateLimit from 'express-rate-limit'
import { HttpStatusCode } from '../../../shared/models'
import { badRequest } from '../../helpers/express-utils'
import { CONFIG } from '../../initializers/config'
diff --git a/server/controllers/api/jobs.ts b/server/controllers/api/jobs.ts
index 9e333322b2..7001674bb0 100644
--- a/server/controllers/api/jobs.ts
+++ b/server/controllers/api/jobs.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { ResultList } from '../../../shared'
import { Job, JobState, JobType } from '../../../shared/models'
import { UserRight } from '../../../shared/models/users'
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts
index f95f06864d..4990fb0df2 100644
--- a/server/controllers/api/oauth-clients.ts
+++ b/server/controllers/api/oauth-clients.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { OAuthClientLocal } from '../../../shared'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { logger } from '../../helpers/logger'
diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts
index 2dfac15ef3..5b16232e2a 100644
--- a/server/controllers/api/overviews.ts
+++ b/server/controllers/api/overviews.ts
@@ -1,5 +1,5 @@
-import * as express from 'express'
-import * as memoizee from 'memoizee'
+import express from 'express'
+import memoizee from 'memoizee'
import { logger } from '@server/helpers/logger'
import { Hooks } from '@server/lib/plugins/hooks'
import { VideoModel } from '@server/models/video/video'
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index 3a9ef34e8a..2de7fe41f4 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { logger } from '@server/helpers/logger'
import { getFormattedObjects } from '@server/helpers/utils'
import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index'
diff --git a/server/controllers/api/search/index.ts b/server/controllers/api/search/index.ts
index 67adbb3079..39efc0b10c 100644
--- a/server/controllers/api/search/index.ts
+++ b/server/controllers/api/search/index.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { searchChannelsRouter } from './search-video-channels'
import { searchPlaylistsRouter } from './search-video-playlists'
import { searchVideosRouter } from './search-videos'
diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts
index eef2225063..25173ac20b 100644
--- a/server/controllers/api/search/search-video-channels.ts
+++ b/server/controllers/api/search/search-video-channels.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { sanitizeUrl } from '@server/helpers/core-utils'
import { pickSearchChannelQuery } from '@server/helpers/query'
import { doJSONRequest } from '@server/helpers/requests'
diff --git a/server/controllers/api/search/search-video-playlists.ts b/server/controllers/api/search/search-video-playlists.ts
index 0a56f19b7c..b28f11c792 100644
--- a/server/controllers/api/search/search-video-playlists.ts
+++ b/server/controllers/api/search/search-video-playlists.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { sanitizeUrl } from '@server/helpers/core-utils'
import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils'
import { logger } from '@server/helpers/logger'
diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts
index 4a6ce0de4e..eb7ce08414 100644
--- a/server/controllers/api/search/search-videos.ts
+++ b/server/controllers/api/search/search-videos.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { sanitizeUrl } from '@server/helpers/core-utils'
import { pickSearchVideoQuery } from '@server/helpers/query'
import { doJSONRequest } from '@server/helpers/requests'
diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts
index b315e99cf2..09ff50f694 100644
--- a/server/controllers/api/server/contact.ts
+++ b/server/controllers/api/server/contact.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { ContactForm } from '../../../../shared/models/server'
import { Emailer } from '../../../lib/emailer'
diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts
index 0601b89ceb..093e6a03c9 100644
--- a/server/controllers/api/server/debug.ts
+++ b/server/controllers/api/server/debug.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { InboxManager } from '@server/lib/activitypub/inbox-manager'
import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
import { Debug, SendDebugCommand } from '@shared/models'
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index cbe6b7e4f5..2e0fd25ebb 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { getServerActor } from '@server/models/application/application'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserRight } from '../../../../shared/models/users'
diff --git a/server/controllers/api/server/index.ts b/server/controllers/api/server/index.ts
index 32fefefc04..b20718d096 100644
--- a/server/controllers/api/server/index.ts
+++ b/server/controllers/api/server/index.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { contactRouter } from './contact'
import { debugRouter } from './debug'
import { serverFollowsRouter } from './follows'
diff --git a/server/controllers/api/server/logs.ts b/server/controllers/api/server/logs.ts
index 39eceb6547..dfd5491aa5 100644
--- a/server/controllers/api/server/logs.ts
+++ b/server/controllers/api/server/logs.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { readdir, readFile } from 'fs-extra'
import { join } from 'path'
import { logger, mtimeSortFilesDesc } from '@server/helpers/logger'
diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts
index e36c8d2db4..9f43d3e4e9 100644
--- a/server/controllers/api/server/redundancy.ts
+++ b/server/controllers/api/server/redundancy.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { JobQueue } from '@server/lib/job-queue'
import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts
index b3ee50d855..740f95da3d 100644
--- a/server/controllers/api/server/server-blocklist.ts
+++ b/server/controllers/api/server/server-blocklist.ts
@@ -1,5 +1,5 @@
import 'multer'
-import * as express from 'express'
+import express from 'express'
import { logger } from '@server/helpers/logger'
import { getServerActor } from '@server/models/application/application'
import { UserNotificationModel } from '@server/models/user/user-notification'
diff --git a/server/controllers/api/server/stats.ts b/server/controllers/api/server/stats.ts
index 397702548b..d661144ca6 100644
--- a/server/controllers/api/server/stats.ts
+++ b/server/controllers/api/server/stats.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { StatsManager } from '@server/lib/stat-manager'
import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
import { asyncMiddleware } from '../../../middlewares'
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index be800e8b5d..bc47e5fec6 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -1,5 +1,5 @@
-import * as express from 'express'
-import * as RateLimit from 'express-rate-limit'
+import express from 'express'
+import RateLimit from 'express-rate-limit'
import { tokensRouter } from '@server/controllers/api/users/token'
import { Hooks } from '@server/lib/plugins/hooks'
import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index a98d792188..83b774d3c8 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -1,5 +1,5 @@
import 'multer'
-import * as express from 'express'
+import express from 'express'
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger'
import { Hooks } from '@server/lib/plugins/hooks'
import { AttributesOnly } from '@shared/core-utils'
diff --git a/server/controllers/api/users/my-abuses.ts b/server/controllers/api/users/my-abuses.ts
index fcd0ce3fce..103c3d3326 100644
--- a/server/controllers/api/users/my-abuses.ts
+++ b/server/controllers/api/users/my-abuses.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { AbuseModel } from '@server/models/abuse/abuse'
import {
abuseListForUserValidator,
diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts
index 24fff83e33..0b56645cf3 100644
--- a/server/controllers/api/users/my-blocklist.ts
+++ b/server/controllers/api/users/my-blocklist.ts
@@ -1,5 +1,5 @@
import 'multer'
-import * as express from 'express'
+import express from 'express'
import { logger } from '@server/helpers/logger'
import { UserNotificationModel } from '@server/models/user/user-notification'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts
index a6e7231030..2fcb25acf5 100644
--- a/server/controllers/api/users/my-history.ts
+++ b/server/controllers/api/users/my-history.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { getFormattedObjects } from '../../../helpers/utils'
import { sequelizeTypescript } from '../../../initializers/database'
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index 3beee07c02..d107a306e1 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -1,5 +1,5 @@
import 'multer'
-import * as express from 'express'
+import express from 'express'
import { UserNotificationModel } from '@server/models/user/user-notification'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserNotificationSetting } from '../../../../shared/models/users'
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts
index 26a715704b..e3c0cf089a 100644
--- a/server/controllers/api/users/my-subscriptions.ts
+++ b/server/controllers/api/users/my-subscriptions.ts
@@ -1,5 +1,5 @@
import 'multer'
-import * as express from 'express'
+import express from 'express'
import { pickCommonVideoQuery } from '@server/helpers/query'
import { sendUndoFollow } from '@server/lib/activitypub/send'
import { VideoChannelModel } from '@server/models/video/video-channel'
diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/controllers/api/users/my-video-playlists.ts
index 76e741ba54..f55ea2ec44 100644
--- a/server/controllers/api/users/my-video-playlists.ts
+++ b/server/controllers/api/users/my-video-playlists.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
import { asyncMiddleware, authenticate } from '../../../middlewares'
import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists'
diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.ts
index b405ddbf41..d5dbe921c7 100644
--- a/server/controllers/api/users/token.ts
+++ b/server/controllers/api/users/token.ts
@@ -1,5 +1,5 @@
-import * as express from 'express'
-import * as RateLimit from 'express-rate-limit'
+import express from 'express'
+import RateLimit from 'express-rate-limit'
import { logger } from '@server/helpers/logger'
import { buildUUID } from '@server/helpers/uuid'
import { CONFIG } from '@server/initializers/config'
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index a0c6601d94..b79dc5933e 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { pickCommonVideoQuery } from '@server/helpers/query'
import { Hooks } from '@server/lib/plugins/hooks'
import { getServerActor } from '@server/models/application/application'
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index 4971d0a772..2f81cf43c1 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { join } from 'path'
import { uuidToShort } from '@server/helpers/uuid'
import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists'
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts
index 6bc768471c..de65c74f10 100644
--- a/server/controllers/api/videos/blacklist.ts
+++ b/server/controllers/api/videos/blacklist.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist'
import { UserRight, VideoBlacklistCreate } from '../../../../shared'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts
index 4008de60fc..2d2213327c 100644
--- a/server/controllers/api/videos/captions.ts
+++ b/server/controllers/api/videos/captions.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { MVideoCaption } from '@server/types/models'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index cb696f652c..23bba90891 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model'
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index de9a5308a1..39fc577885 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -1,7 +1,7 @@
-import * as express from 'express'
+import express from 'express'
import { move, readFile } from 'fs-extra'
-import * as magnetUtil from 'magnet-uri'
-import * as parseTorrent from 'parse-torrent'
+import { decode } from 'magnet-uri'
+import parseTorrent, { Instance } from 'parse-torrent'
import { join } from 'path'
import { ServerConfigManager } from '@server/lib/server-config-manager'
import { setVideoTags } from '@server/lib/video'
@@ -329,7 +329,7 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express.
torrentfile.path = newTorrentPath
const buf = await readFile(torrentfile.path)
- const parsedTorrent = parseTorrent(buf) as parseTorrent.Instance
+ const parsedTorrent = parseTorrent(buf) as Instance
if (parsedTorrent.files.length !== 1) {
cleanUpReqFiles(req)
@@ -349,7 +349,7 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express.
function processMagnetURI (body: VideoImportCreate) {
const magnetUri = body.magnetUri
- const parsed = magnetUtil.decode(magnetUri)
+ const parsed = decode(magnetUri)
return {
name: extractNameFromArray(parsed.name),
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 10833d48bf..c0c77f3f74 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import toInt from 'validator/lib/toInt'
import { pickCommonVideoQuery } from '@server/helpers/query'
import { doJSONRequest } from '@server/helpers/requests'
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index 151ff354b7..efafe64e9a 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { createReqFiles } from '@server/helpers/express-utils'
import { buildUUID, uuidToShort } from '@server/helpers/uuid'
import { CONFIG } from '@server/initializers/config'
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts
index f48acbc681..043861ac3c 100644
--- a/server/controllers/api/videos/ownership.ts
+++ b/server/controllers/api/videos/ownership.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { MVideoFullLight } from '@server/types/models'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos'
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 96f6cd886b..c9cc16644e 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { UserVideoRateUpdate } from '../../../../shared'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { logger } from '../../../helpers/logger'
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts
index 49639060bd..a98a3e67c1 100644
--- a/server/controllers/api/videos/update.ts
+++ b/server/controllers/api/videos/update.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { Transaction } from 'sequelize/types'
import { changeVideoChannelShare } from '@server/lib/activitypub/share'
import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index 5c740c0410..7ffda749d5 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { move } from 'fs-extra'
import { basename } from 'path'
import { getLowercaseExtension } from '@server/helpers/core-utils'
diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts
index 05c75e543c..e8c28b6138 100644
--- a/server/controllers/api/videos/watching.ts
+++ b/server/controllers/api/videos/watching.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { UserWatchingVideo } from '../../../../shared'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import {
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts
index de04116086..63db345bfe 100644
--- a/server/controllers/bots.ts
+++ b/server/controllers/bots.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { truncate } from 'lodash'
import { SitemapStream, streamToPromise } from 'sitemap'
import { buildNSFWFilter } from '../helpers/express-utils'
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index ba3c54440a..d81e35ec3d 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { constants, promises as fs } from 'fs'
import { readFile } from 'fs-extra'
import { join } from 'path'
diff --git a/server/controllers/download.ts b/server/controllers/download.ts
index ffe40d57e3..8da710669c 100644
--- a/server/controllers/download.ts
+++ b/server/controllers/download.ts
@@ -1,5 +1,5 @@
-import * as cors from 'cors'
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
import { logger } from '@server/helpers/logger'
import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
import { Hooks } from '@server/lib/plugins/hooks'
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts
index 9fa70a7c8c..5ac2e43a1c 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -1,5 +1,5 @@
-import * as express from 'express'
-import * as Feed from 'pfeed'
+import express from 'express'
+import Feed from 'pfeed'
import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils'
import { VideoFilter } from '../../shared/models/videos/video-query.type'
import { buildNSFWFilter } from '../helpers/express-utils'
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts
index 632e4dcd8d..a4076ee56b 100644
--- a/server/controllers/lazy-static.ts
+++ b/server/controllers/lazy-static.ts
@@ -1,5 +1,5 @@
-import * as cors from 'cors'
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { logger } from '../helpers/logger'
diff --git a/server/controllers/live.ts b/server/controllers/live.ts
index 95d5c01357..81008f120d 100644
--- a/server/controllers/live.ts
+++ b/server/controllers/live.ts
@@ -1,5 +1,5 @@
-import * as cors from 'cors'
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
import { mapToJSON } from '@server/helpers/core-utils'
import { LiveSegmentShaStore } from '@server/lib/live'
import { HttpStatusCode } from '@shared/models'
diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts
index 11ab3f10ab..28fffc9e1d 100644
--- a/server/controllers/plugins.ts
+++ b/server/controllers/plugins.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { join } from 'path'
import { logger } from '@server/helpers/logger'
import { optionalAuthenticate } from '@server/middlewares/auth'
diff --git a/server/controllers/services.ts b/server/controllers/services.ts
index 8c0af9ff75..8a8a954860 100644
--- a/server/controllers/services.ts
+++ b/server/controllers/services.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER, THUMBNAILS_SIZE } from '../initializers/constants'
import { asyncMiddleware, oembedValidator } from '../middlewares'
import { accountNameWithHostGetValidator } from '../middlewares/validators'
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 912d7e36c8..1c04e4b11e 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -1,5 +1,5 @@
-import * as cors from 'cors'
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
import { join } from 'path'
import { serveIndexHTML } from '@server/lib/client-html'
import { ServerConfigManager } from '@server/lib/server-config-manager'
diff --git a/server/controllers/tracker.ts b/server/controllers/tracker.ts
index 37f8f12c98..da9c68c6cf 100644
--- a/server/controllers/tracker.ts
+++ b/server/controllers/tracker.ts
@@ -1,7 +1,7 @@
-import * as bitTorrentTracker from 'bittorrent-tracker'
-import * as express from 'express'
-import * as http from 'http'
-import * as proxyAddr from 'proxy-addr'
+import { Server as TrackerServer } from 'bittorrent-tracker'
+import express from 'express'
+import { createServer } from 'http'
+import proxyAddr from 'proxy-addr'
import { Server as WebSocketServer } from 'ws'
import { Redis } from '@server/lib/redis'
import { logger } from '../helpers/logger'
@@ -10,8 +10,6 @@ import { TRACKER_RATE_LIMITS } from '../initializers/constants'
import { VideoFileModel } from '../models/video/video-file'
import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
-const TrackerServer = bitTorrentTracker.Server
-
const trackerRouter = express.Router()
let peersIps = {}
@@ -86,7 +84,7 @@ trackerRouter.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { a
trackerRouter.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' }))
function createWebsocketTrackerServer (app: express.Application) {
- const server = http.createServer(app)
+ const server = createServer(app)
const wss = new WebSocketServer({ noServer: true })
wss.on('connection', function (ws, req) {
diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts
index 885e4498f0..29ce011660 100644
--- a/server/controllers/webfinger.ts
+++ b/server/controllers/webfinger.ts
@@ -1,5 +1,5 @@
-import * as cors from 'cors'
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
import { WEBSERVER } from '@server/initializers/constants'
import { asyncMiddleware } from '../middlewares'
import { webfingerValidator } from '../middlewares/validators'
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts
index e0754b501b..8b56d2d509 100644
--- a/server/helpers/activitypub.ts
+++ b/server/helpers/activitypub.ts
@@ -1,4 +1,4 @@
-import * as Bluebird from 'bluebird'
+import Bluebird from 'bluebird'
import { URL } from 'url'
import validator from 'validator'
import { ContextType } from '@shared/models/activitypub/context'
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts
index 884bd187d3..5f2e870e38 100644
--- a/server/helpers/audit-logger.ts
+++ b/server/helpers/audit-logger.ts
@@ -1,9 +1,9 @@
import { diff } from 'deep-object-diff'
-import * as express from 'express'
-import * as flatten from 'flat'
+import express from 'express'
+import flatten from 'flat'
import { chain } from 'lodash'
-import * as path from 'path'
-import * as winston from 'winston'
+import { join } from 'path'
+import { addColors, config, createLogger, format, transports } from 'winston'
import { AUDIT_LOG_FILENAME } from '@server/initializers/constants'
import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared'
import { CustomConfig } from '../../shared/models/server/custom-config.model'
@@ -21,23 +21,23 @@ enum AUDIT_TYPE {
DELETE = 'delete'
}
-const colors = winston.config.npm.colors
-colors.audit = winston.config.npm.colors.info
+const colors = config.npm.colors
+colors.audit = config.npm.colors.info
-winston.addColors(colors)
+addColors(colors)
-const auditLogger = winston.createLogger({
+const auditLogger = createLogger({
levels: { audit: 0 },
transports: [
- new winston.transports.File({
- filename: path.join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME),
+ new transports.File({
+ filename: join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME),
level: 'audit',
maxsize: 5242880,
maxFiles: 5,
- format: winston.format.combine(
- winston.format.timestamp(),
+ format: format.combine(
+ format.timestamp(),
labelFormatter(),
- winston.format.splat(),
+ format.splat(),
jsonLoggerFormat
)
})
@@ -84,9 +84,9 @@ abstract class EntityAuditView {
constructor (private readonly keysToKeep: string[], private readonly prefix: string, private readonly entityInfos: object) { }
toLogKeys (): object {
- return chain(flatten(this.entityInfos, { delimiter: '-', safe: true }))
+ return chain(flatten<object, any>(this.entityInfos, { delimiter: '-', safe: true }))
.pick(this.keysToKeep)
- .mapKeys((value, key) => `${this.prefix}-${key}`)
+ .mapKeys((_value, key) => `${this.prefix}-${key}`)
.value()
}
}
diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.ts
index ca03f7a490..f6e5b9784b 100644
--- a/server/helpers/captions-utils.ts
+++ b/server/helpers/captions-utils.ts
@@ -1,10 +1,10 @@
import { createReadStream, createWriteStream, move, remove } from 'fs-extra'
import { join } from 'path'
-import * as srt2vtt from 'srt-to-vtt'
+import srt2vtt from 'srt-to-vtt'
+import { Transform } from 'stream'
import { MVideoCaption } from '@server/types/models'
import { CONFIG } from '../initializers/config'
import { pipelinePromise } from './core-utils'
-import { Transform } from 'stream'
async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) {
const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 9abc532d28..7f28cfc8b1 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -9,7 +9,7 @@ import { exec, ExecOptions } from 'child_process'
import { BinaryToTextEncoding, createHash, randomBytes } from 'crypto'
import { truncate } from 'lodash'
import { basename, extname, isAbsolute, join, resolve } from 'path'
-import * as pem from 'pem'
+import { createPrivateKey as createPrivateKey_1, getPublicKey as getPublicKey_1 } from 'pem'
import { pipeline } from 'stream'
import { URL } from 'url'
import { promisify } from 'util'
@@ -281,8 +281,8 @@ function promisify2<T, U, A> (func: (arg1: T, arg2: U, cb: (err: any, result: A)
}
const randomBytesPromise = promisify1<number, Buffer>(randomBytes)
-const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey)
-const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey)
+const createPrivateKey = promisify1<number, { key: string }>(createPrivateKey_1)
+const getPublicKey = promisify1<string, { publicKey: string }>(getPublicKey_1)
const execPromise2 = promisify2<string, any, string>(exec)
const execPromise = promisify1<string, string>(exec)
const pipelinePromise = promisify(pipeline)
diff --git a/server/helpers/custom-jsonld-signature.ts b/server/helpers/custom-jsonld-signature.ts
index 56f10086c6..3c706e372e 100644
--- a/server/helpers/custom-jsonld-signature.ts
+++ b/server/helpers/custom-jsonld-signature.ts
@@ -1,7 +1,8 @@
-import * as AsyncLRU from 'async-lru'
-import * as jsonld from 'jsonld'
+import AsyncLRU from 'async-lru'
import { logger } from './logger'
+import jsonld = require('jsonld')
+
const CACHE = {
'https://w3id.org/security/v1': {
'@context': {
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index b33e088ebe..c3604fbad0 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -1,6 +1,6 @@
import { UploadFilesForCheck } from 'express'
import { values } from 'lodash'
-import * as magnetUtil from 'magnet-uri'
+import magnetUtil from 'magnet-uri'
import validator from 'validator'
import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
import {
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index ec35295df2..aedcc5e640 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -1,5 +1,5 @@
-import * as retry from 'async/retry'
-import * as Bluebird from 'bluebird'
+import retry from 'async/retry'
+import Bluebird from 'bluebird'
import { Transaction } from 'sequelize'
import { Model } from 'sequelize-typescript'
import { sequelizeTypescript } from '@server/initializers/database'
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts
index c299b70f13..38fe6926ba 100644
--- a/server/helpers/express-utils.ts
+++ b/server/helpers/express-utils.ts
@@ -1,5 +1,5 @@
-import * as express from 'express'
-import * as multer from 'multer'
+import express from 'express'
+import multer, { diskStorage } from 'multer'
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { CONFIG } from '../initializers/config'
import { REMOTE_SCHEME } from '../initializers/constants'
@@ -70,7 +70,7 @@ function createReqFiles (
mimeTypes: { [id: string]: string | string[] },
destinations: { [fieldName: string]: string }
) {
- const storage = multer.diskStorage({
+ const storage = diskStorage({
destination: (req, file, cb) => {
cb(null, destinations[file.fieldname])
},
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index a99c9ee7c7..54fd031b75 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -1,5 +1,5 @@
import { Job } from 'bull'
-import * as ffmpeg from 'fluent-ffmpeg'
+import ffmpeg, { FfmpegCommand, FilterSpecification, getAvailableEncoders } from 'fluent-ffmpeg'
import { readFile, remove, writeFile } from 'fs-extra'
import { dirname, join } from 'path'
import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
@@ -42,7 +42,7 @@ async function checkFFmpegEncoders (peertubeAvailableEncoders: AvailableEncoders
return supportedEncoders
}
- const getAvailableEncodersPromise = promisify0(ffmpeg.getAvailableEncoders)
+ const getAvailableEncodersPromise = promisify0(getAvailableEncoders)
const availableFFmpegEncoders = await getAvailableEncodersPromise()
const searchEncoders = new Set<string>()
@@ -191,7 +191,7 @@ type TranscodeOptions =
| QuickTranscodeOptions
const builders: {
- [ type in TranscodeOptionsType ]: (c: ffmpeg.FfmpegCommand, o?: TranscodeOptions) => Promise<ffmpeg.FfmpegCommand> | ffmpeg.FfmpegCommand
+ [ type in TranscodeOptionsType ]: (c: FfmpegCommand, o?: TranscodeOptions) => Promise<FfmpegCommand> | FfmpegCommand
} = {
'quick-transcode': buildQuickTranscodeCommand,
'hls': buildHLSVODCommand,
@@ -241,7 +241,7 @@ async function getLiveTranscodingCommand (options: {
const varStreamMap: string[] = []
- const complexFilter: ffmpeg.FilterSpecification[] = [
+ const complexFilter: FilterSpecification[] = [
{
inputs: '[v:0]',
filter: 'split',
@@ -353,7 +353,7 @@ function buildStreamSuffix (base: string, streamNum?: number) {
// ---------------------------------------------------------------------------
function addDefaultEncoderGlobalParams (options: {
- command: ffmpeg.FfmpegCommand
+ command: FfmpegCommand
}) {
const { command } = options
@@ -370,7 +370,7 @@ function addDefaultEncoderGlobalParams (options: {
}
function addDefaultEncoderParams (options: {
- command: ffmpeg.FfmpegCommand
+ command: FfmpegCommand
encoder: 'libx264' | string
streamNum?: number
fps?: number
@@ -390,7 +390,7 @@ function addDefaultEncoderParams (options: {
}
}
-function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, masterPlaylistName: string) {
+function addDefaultLiveHLSParams (command: FfmpegCommand, outPath: string, masterPlaylistName: string) {
command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS)
command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE)
command.outputOption('-hls_flags delete_segments+independent_segments')
@@ -405,7 +405,7 @@ function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string
// Transcode VOD command builders
// ---------------------------------------------------------------------------
-async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: TranscodeOptions) {
+async function buildx264VODCommand (command: FfmpegCommand, options: TranscodeOptions) {
let fps = await getVideoFileFPS(options.inputPath)
fps = computeFPS(fps, options.resolution)
@@ -422,7 +422,7 @@ async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: Tran
return command
}
-async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) {
+async function buildAudioMergeCommand (command: FfmpegCommand, options: MergeAudioTranscodeOptions) {
command = command.loop(undefined)
const scaleFilterValue = getScaleCleanerValue()
@@ -437,13 +437,13 @@ async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: M
return command
}
-function buildOnlyAudioCommand (command: ffmpeg.FfmpegCommand, _options: OnlyAudioTranscodeOptions) {
+function buildOnlyAudioCommand (command: FfmpegCommand, _options: OnlyAudioTranscodeOptions) {
command = presetOnlyAudio(command)
return command
}
-function buildQuickTranscodeCommand (command: ffmpeg.FfmpegCommand) {
+function buildQuickTranscodeCommand (command: FfmpegCommand) {
command = presetCopy(command)
command = command.outputOption('-map_metadata -1') // strip all metadata
@@ -452,7 +452,7 @@ function buildQuickTranscodeCommand (command: ffmpeg.FfmpegCommand) {
return command
}
-function addCommonHLSVODCommandOptions (command: ffmpeg.FfmpegCommand, outputPath: string) {
+function addCommonHLSVODCommandOptions (command: FfmpegCommand, outputPath: string) {
return command.outputOption('-hls_time 4')
.outputOption('-hls_list_size 0')
.outputOption('-hls_playlist_type vod')
@@ -462,7 +462,7 @@ function addCommonHLSVODCommandOptions (command: ffmpeg.FfmpegCommand, outputPat
.outputOption('-hls_flags single_file')
}
-async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTranscodeOptions) {
+async function buildHLSVODCommand (command: FfmpegCommand, options: HLSTranscodeOptions) {
const videoPath = getHLSVideoPath(options)
if (options.copyCodecs) command = presetCopy(command)
@@ -474,7 +474,7 @@ async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTr
return command
}
-function buildHLSVODFromTSCommand (command: ffmpeg.FfmpegCommand, options: HLSFromTSTranscodeOptions) {
+function buildHLSVODFromTSCommand (command: FfmpegCommand, options: HLSFromTSTranscodeOptions) {
const videoPath = getHLSVideoPath(options)
command.outputOption('-c copy')
@@ -571,7 +571,7 @@ async function getEncoderBuilderResult (options: EncoderOptionsBuilderParams & {
}
async function presetVideo (options: {
- command: ffmpeg.FfmpegCommand
+ command: FfmpegCommand
input: string
transcodeOptions: TranscodeOptions
fps?: number
@@ -640,21 +640,21 @@ async function presetVideo (options: {
return localCommand
}
-function presetCopy (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand {
+function presetCopy (command: FfmpegCommand): FfmpegCommand {
return command
.format('mp4')
.videoCodec('copy')
.audioCodec('copy')
}
-function presetOnlyAudio (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand {
+function presetOnlyAudio (command: FfmpegCommand): FfmpegCommand {
return command
.format('mp4')
.audioCodec('copy')
.noVideo()
}
-function applyEncoderOptions (command: ffmpeg.FfmpegCommand, options: EncoderOptions): ffmpeg.FfmpegCommand {
+function applyEncoderOptions (command: FfmpegCommand, options: EncoderOptions): FfmpegCommand {
return command
.inputOptions(options.inputOptions ?? [])
.outputOptions(options.outputOptions ?? [])
@@ -714,7 +714,7 @@ function getFFmpegVersion () {
}
async function runCommand (options: {
- command: ffmpeg.FfmpegCommand
+ command: FfmpegCommand
silent?: boolean // false
job?: Job
}) {
diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts
index e58444b072..8381dee84f 100644
--- a/server/helpers/ffprobe-utils.ts
+++ b/server/helpers/ffprobe-utils.ts
@@ -1,4 +1,4 @@
-import * as ffmpeg from 'fluent-ffmpeg'
+import { ffprobe, FfprobeData } from 'fluent-ffmpeg'
import { getMaxBitrate } from '@shared/core-utils'
import { VideoFileMetadata, VideoResolution, VideoTranscodingFPS } from '../../shared/models/videos'
import { CONFIG } from '../initializers/config'
@@ -12,8 +12,8 @@ import { logger } from './logger'
*/
function ffprobePromise (path: string) {
- return new Promise<ffmpeg.FfprobeData>((res, rej) => {
- ffmpeg.ffprobe(path, (err, data) => {
+ return new Promise<FfprobeData>((res, rej) => {
+ ffprobe(path, (err, data) => {
if (err) return rej(err)
return res(data)
@@ -21,7 +21,7 @@ function ffprobePromise (path: string) {
})
}
-async function getAudioStream (videoPath: string, existingProbe?: ffmpeg.FfprobeData) {
+async function getAudioStream (videoPath: string, existingProbe?: FfprobeData) {
// without position, ffprobe considers the last input only
// we make it consider the first input only
// if you pass a file path to pos, then ffprobe acts on that file directly
@@ -76,7 +76,7 @@ function getMaxAudioBitrate (type: 'aac' | 'mp3' | string, bitrate: number) {
}
}
-async function getVideoStreamSize (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<{ width: number, height: number }> {
+async function getVideoStreamSize (path: string, existingProbe?: FfprobeData): Promise<{ width: number, height: number }> {
const videoStream = await getVideoStreamFromFile(path, existingProbe)
return videoStream === null
@@ -127,7 +127,7 @@ async function getVideoStreamCodec (path: string) {
return `${videoCodec}.${baseProfile}${level}`
}
-async function getAudioStreamCodec (path: string, existingProbe?: ffmpeg.FfprobeData) {
+async function getAudioStreamCodec (path: string, existingProbe?: FfprobeData) {
const { audioStream } = await getAudioStream(path, existingProbe)
if (!audioStream) return ''
@@ -143,7 +143,7 @@ async function getAudioStreamCodec (path: string, existingProbe?: ffmpeg.Ffprobe
return 'mp4a.40.2' // Fallback
}
-async function getVideoFileResolution (path: string, existingProbe?: ffmpeg.FfprobeData) {
+async function getVideoFileResolution (path: string, existingProbe?: FfprobeData) {
const size = await getVideoStreamSize(path, existingProbe)
return {
@@ -155,7 +155,7 @@ async function getVideoFileResolution (path: string, existingProbe?: ffmpeg.Ffpr
}
}
-async function getVideoFileFPS (path: string, existingProbe?: ffmpeg.FfprobeData) {
+async function getVideoFileFPS (path: string, existingProbe?: FfprobeData) {
const videoStream = await getVideoStreamFromFile(path, existingProbe)
if (videoStream === null) return 0
@@ -173,13 +173,13 @@ async function getVideoFileFPS (path: string, existingProbe?: ffmpeg.FfprobeData
return 0
}
-async function getMetadataFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
+async function getMetadataFromFile (path: string, existingProbe?: FfprobeData) {
const metadata = existingProbe || await ffprobePromise(path)
return new VideoFileMetadata(metadata)
}
-async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<number> {
+async function getVideoFileBitrate (path: string, existingProbe?: FfprobeData): Promise<number> {
const metadata = await getMetadataFromFile(path, existingProbe)
let bitrate = metadata.format.bit_rate as number
@@ -194,13 +194,13 @@ async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.Ffprobe
return undefined
}
-async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
+async function getDurationFromVideoFile (path: string, existingProbe?: FfprobeData) {
const metadata = await getMetadataFromFile(path, existingProbe)
return Math.round(metadata.format.duration)
}
-async function getVideoStreamFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) {
+async function getVideoStreamFromFile (path: string, existingProbe?: FfprobeData) {
const metadata = await getMetadataFromFile(path, existingProbe)
return metadata.streams.find(s => s.codec_type === 'video') || null
@@ -243,7 +243,7 @@ async function canDoQuickTranscode (path: string): Promise<boolean> {
await canDoQuickAudioTranscode(path, probe)
}
-async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> {
+async function canDoQuickVideoTranscode (path: string, probe?: FfprobeData): Promise<boolean> {
const videoStream = await getVideoStreamFromFile(path, probe)
const fps = await getVideoFileFPS(path, probe)
const bitRate = await getVideoFileBitrate(path, probe)
@@ -262,7 +262,7 @@ async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeDat
return true
}
-async function canDoQuickAudioTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> {
+async function canDoQuickAudioTranscode (path: string, probe?: FfprobeData): Promise<boolean> {
const parsedAudio = await getAudioStream(path, probe)
if (!parsedAudio.audioStream) return true
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts
index c76ed545bb..033be2c509 100644
--- a/server/helpers/image-utils.ts
+++ b/server/helpers/image-utils.ts
@@ -1,5 +1,5 @@
import { copy, readFile, remove, rename } from 'fs-extra'
-import * as Jimp from 'jimp'
+import Jimp, { read } from 'jimp'
import { getLowercaseExtension } from './core-utils'
import { convertWebPToJPG, processGIF } from './ffmpeg-utils'
import { logger } from './logger'
@@ -47,7 +47,7 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt
const inputBuffer = await readFile(path)
try {
- jimpInstance = await Jimp.read(inputBuffer)
+ jimpInstance = await read(inputBuffer)
} catch (err) {
logger.debug('Cannot read %s with jimp. Try to convert the image using ffmpeg first.', path, { err })
@@ -55,7 +55,7 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt
await convertWebPToJPG(path, newName)
await rename(newName, path)
- jimpInstance = await Jimp.read(path)
+ jimpInstance = await read(path)
}
await remove(destination)
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index 20c3c3edba..4bd00e5034 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -1,9 +1,9 @@
// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
import { mkdirpSync, stat } from 'fs-extra'
import { omit } from 'lodash'
-import * as path from 'path'
+import { join } from 'path'
import { format as sqlFormat } from 'sql-formatter'
-import * as winston from 'winston'
+import { createLogger, format, transports } from 'winston'
import { FileTransportOptions } from 'winston/lib/winston/transports'
import { CONFIG } from '../initializers/config'
import { LOG_FILENAME } from '../initializers/constants'
@@ -47,7 +47,7 @@ function getLoggerReplacer () {
}
}
-const consoleLoggerFormat = winston.format.printf(info => {
+const consoleLoggerFormat = format.printf(info => {
const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ]
const obj = omit(info, ...toOmit)
@@ -71,24 +71,24 @@ const consoleLoggerFormat = winston.format.printf(info => {
return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`
})
-const jsonLoggerFormat = winston.format.printf(info => {
+const jsonLoggerFormat = format.printf(info => {
return JSON.stringify(info, getLoggerReplacer())
})
-const timestampFormatter = winston.format.timestamp({
+const timestampFormatter = format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss.SSS'
})
const labelFormatter = (suffix?: string) => {
- return winston.format.label({
+ return format.label({
label: suffix ? `${label} ${suffix}` : label
})
}
const fileLoggerOptions: FileTransportOptions = {
- filename: path.join(CONFIG.STORAGE.LOG_DIR, LOG_FILENAME),
+ filename: join(CONFIG.STORAGE.LOG_DIR, LOG_FILENAME),
handleExceptions: true,
- format: winston.format.combine(
- winston.format.timestamp(),
+ format: format.combine(
+ format.timestamp(),
jsonLoggerFormat
)
}
@@ -101,19 +101,19 @@ if (CONFIG.LOG.ROTATION.ENABLED) {
const logger = buildLogger()
function buildLogger (labelSuffix?: string) {
- return winston.createLogger({
+ return createLogger({
level: CONFIG.LOG.LEVEL,
- format: winston.format.combine(
+ format: format.combine(
labelFormatter(labelSuffix),
- winston.format.splat()
+ format.splat()
),
transports: [
- new winston.transports.File(fileLoggerOptions),
- new winston.transports.Console({
+ new transports.File(fileLoggerOptions),
+ new transports.Console({
handleExceptions: true,
- format: winston.format.combine(
+ format: format.combine(
timestampFormatter,
- winston.format.colorize(),
+ format.colorize(),
consoleLoggerFormat
)
})
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts
index bc6f1d0748..66060bde29 100644
--- a/server/helpers/peertube-crypto.ts
+++ b/server/helpers/peertube-crypto.ts
@@ -1,16 +1,16 @@
+import { compare, genSalt, hash } from 'bcrypt'
+import { createSign, createVerify } from 'crypto'
import { Request } from 'express'
+import { cloneDeep } from 'lodash'
import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants'
+import { MActor } from '../types/models'
import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils'
import { jsonld } from './custom-jsonld-signature'
import { logger } from './logger'
-import { cloneDeep } from 'lodash'
-import { createSign, createVerify } from 'crypto'
-import * as bcrypt from 'bcrypt'
-import { MActor } from '../types/models'
-const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare)
-const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt)
-const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash)
+const bcryptComparePromise = promisify2<any, string, boolean>(compare)
+const bcryptGenSaltPromise = promisify1<number, string>(genSalt)
+const bcryptHashPromise = promisify2<any, string | number, string>(hash)
const httpSignature = require('http-signature')
@@ -129,7 +129,7 @@ export {
// ---------------------------------------------------------------------------
-function hash (obj: any): Promise<any> {
+function hashObject (obj: any): Promise<any> {
return jsonld.promises
.normalize(obj, {
algorithm: 'URDNA2015',
@@ -151,12 +151,12 @@ function createSignatureHash (signature: any) {
delete signatureCopy.id
delete signatureCopy.signatureValue
- return hash(signatureCopy)
+ return hashObject(signatureCopy)
}
function createDocWithoutSignatureHash (doc: any) {
const docWithoutSignature = cloneDeep(doc)
delete docWithoutSignature.signature
- return hash(docWithoutSignature)
+ return hashObject(docWithoutSignature)
}
diff --git a/server/helpers/uuid.ts b/server/helpers/uuid.ts
index 3eb06c773b..f3c80e046f 100644
--- a/server/helpers/uuid.ts
+++ b/server/helpers/uuid.ts
@@ -1,9 +1,9 @@
-import * as short from 'short-uuid'
+import short, { uuid } from 'short-uuid'
const translator = short()
function buildUUID () {
- return short.uuid()
+ return uuid()
}
function uuidToShort (uuid: string) {
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts
index 813ebc2361..83b46e0854 100644
--- a/server/helpers/webtorrent.ts
+++ b/server/helpers/webtorrent.ts
@@ -1,10 +1,11 @@
-import * as bencode from 'bencode'
-import * as createTorrent from 'create-torrent'
+import { decode, encode } from 'bencode'
+import createTorrent from 'create-torrent'
import { createWriteStream, ensureDir, readFile, remove, writeFile } from 'fs-extra'
-import * as magnetUtil from 'magnet-uri'
-import * as parseTorrent from 'parse-torrent'
+import magnetUtil from 'magnet-uri'
+import parseTorrent from 'parse-torrent'
import { dirname, join } from 'path'
-import * as WebTorrent from 'webtorrent'
+import { pipeline } from 'stream'
+import WebTorrent, { Instance, TorrentFile } from 'webtorrent'
import { isArray } from '@server/helpers/custom-validators/misc'
import { WEBSERVER } from '@server/initializers/constants'
import { generateTorrentFileName } from '@server/lib/paths'
@@ -17,7 +18,6 @@ import { promisify2 } from './core-utils'
import { logger } from './logger'
import { generateVideoImportTmpPath } from './utils'
import { extractVideo } from './video'
-import { pipeline } from 'stream'
const createTorrentPromise = promisify2<string, any, any>(createTorrent)
@@ -33,7 +33,7 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName
return new Promise<string>((res, rej) => {
const webtorrent = new WebTorrent()
- let file: WebTorrent.TorrentFile
+ let file: TorrentFile
const torrentId = target.magnetUri || join(CONFIG.STORAGE.TORRENTS_DIR, target.torrentName)
@@ -126,7 +126,7 @@ async function updateTorrentUrls (videoOrPlaylist: MVideo | MStreamingPlaylistVi
const oldTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename)
const torrentContent = await readFile(oldTorrentPath)
- const decoded = bencode.decode(torrentContent)
+ const decoded = decode(torrentContent)
decoded['announce-list'] = buildAnnounceList()
decoded.announce = decoded['announce-list'][0][0]
@@ -138,7 +138,7 @@ async function updateTorrentUrls (videoOrPlaylist: MVideo | MStreamingPlaylistVi
logger.info('Updating torrent URLs %s -> %s.', oldTorrentPath, newTorrentPath)
- await writeFile(newTorrentPath, bencode.encode(decoded))
+ await writeFile(newTorrentPath, encode(decoded))
await remove(join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename))
videoFile.torrentFilename = newTorrentFilename
@@ -180,7 +180,7 @@ export {
// ---------------------------------------------------------------------------
function safeWebtorrentDestroy (
- webtorrent: WebTorrent.Instance,
+ webtorrent: Instance,
torrentId: string,
downloadedFile?: { directoryPath: string, filepath: string },
torrentName?: string
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index 09f5872749..c0a6c41ab3 100644
--- a/server/initializers/checker-after-init.ts
+++ b/server/initializers/checker-after-init.ts
@@ -1,4 +1,4 @@
-import * as config from 'config'
+import { util, has, get } from 'config'
import { uniq } from 'lodash'
import { URL } from 'url'
import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils'
@@ -18,8 +18,8 @@ async function checkActivityPubUrls () {
const parsed = new URL(actor.url)
if (WEBSERVER.HOST !== parsed.host) {
- const NODE_ENV = config.util.getEnv('NODE_ENV')
- const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR')
+ const NODE_ENV = util.getEnv('NODE_ENV')
+ const NODE_CONFIG_DIR = util.getEnv('NODE_CONFIG_DIR')
logger.warn(
'It seems PeerTube was started (and created some data) with another domain name. ' +
@@ -36,7 +36,7 @@ async function checkActivityPubUrls () {
function checkConfig () {
// Moved configuration keys
- if (config.has('services.csp-logger')) {
+ if (has('services.csp-logger')) {
logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
}
@@ -97,7 +97,7 @@ function checkConfig () {
// Check storage directory locations
if (isProdInstance()) {
- const configStorage = config.get('storage')
+ const configStorage = get('storage')
for (const key of Object.keys(configStorage)) {
if (configStorage[key].startsWith('storage/')) {
logger.warn(
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 93c0191214..16dc137c0e 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -1,7 +1,10 @@
-import * as config from 'config'
+import { IConfig } from 'config'
import { parseSemVersion, promisify0 } from '../helpers/core-utils'
import { logger } from '../helpers/logger'
+// Special behaviour for config because we can reload it
+const config: IConfig = require('config')
+
// ONLY USE CORE MODULES IN THIS FILE!
// Check the config files
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 0e684eef86..be9fc61f08 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -1,4 +1,4 @@
-import * as bytes from 'bytes'
+import bytes from 'bytes'
import { IConfig } from 'config'
import decache from 'decache'
import { dirname, join } from 'path'
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 676f886533..75daeb5d89 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -1,15 +1,15 @@
-import * as passwordGenerator from 'password-generator'
+import { ensureDir, remove } from 'fs-extra'
+import passwordGenerator from 'password-generator'
import { UserRole } from '../../shared'
import { logger } from '../helpers/logger'
import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
-import { UserModel } from '../models/user/user'
import { ApplicationModel } from '../models/application/application'
import { OAuthClientModel } from '../models/oauth/oauth-client'
+import { UserModel } from '../models/user/user'
import { applicationExist, clientsExist, usersExist } from './checker-after-init'
+import { CONFIG } from './config'
import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants'
import { sequelizeTypescript } from './database'
-import { ensureDir, remove } from 'fs-extra'
-import { CONFIG } from './config'
async function installApplication () {
try {
diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts
index 77203ae241..7d7c9f8cba 100644
--- a/server/initializers/migrator.ts
+++ b/server/initializers/migrator.ts
@@ -1,9 +1,9 @@
-import * as path from 'path'
+import { readdir } from 'fs-extra'
+import { join } from 'path'
+import { QueryTypes } from 'sequelize'
import { logger } from '../helpers/logger'
import { LAST_MIGRATION_VERSION } from './constants'
import { sequelizeTypescript } from './database'
-import { readdir } from 'fs-extra'
-import { QueryTypes } from 'sequelize'
async function migrate () {
const tables = await sequelizeTypescript.getQueryInterface().showAllTables()
@@ -58,7 +58,7 @@ export {
// ---------------------------------------------------------------------------
async function getMigrationScripts () {
- const files = await readdir(path.join(__dirname, 'migrations'))
+ const files = await readdir(join(__dirname, 'migrations'))
const filesToMigrate: {
version: string
script: string
@@ -88,7 +88,7 @@ async function executeMigration (actualVersion: number, entity: { version: strin
const migrationScriptName = entity.script
logger.info('Executing %s migration script.', migrationScriptName)
- const migrationScript = require(path.join(__dirname, 'migrations', migrationScriptName))
+ const migrationScript = require(join(__dirname, 'migrations', migrationScriptName))
return sequelizeTypescript.transaction(async t => {
const options = {
diff --git a/server/lib/activitypub/actors/webfinger.ts b/server/lib/activitypub/actors/webfinger.ts
index 1c7ec47174..5532f05bd8 100644
--- a/server/lib/activitypub/actors/webfinger.ts
+++ b/server/lib/activitypub/actors/webfinger.ts
@@ -1,4 +1,4 @@
-import * as WebFinger from 'webfinger.js'
+import WebFinger from 'webfinger.js'
import { isProdInstance } from '@server/helpers/core-utils'
import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants'
diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts
index 28ff5225a0..336129b822 100644
--- a/server/lib/activitypub/crawl.ts
+++ b/server/lib/activitypub/crawl.ts
@@ -1,13 +1,13 @@
-import { retryTransactionWrapper } from '@server/helpers/database-utils'
-import * as Bluebird from 'bluebird'
+import Bluebird from 'bluebird'
import { URL } from 'url'
+import { retryTransactionWrapper } from '@server/helpers/database-utils'
import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
import { logger } from '../../helpers/logger'
import { doJSONRequest } from '../../helpers/requests'
import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants'
type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
-type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>)
+type CleanerFunction = (startedDate: Date) => Promise<any>
async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) {
let url = argUrl
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts
index ea3e61ac5d..b152d709c3 100644
--- a/server/lib/activitypub/playlists/create-update.ts
+++ b/server/lib/activitypub/playlists/create-update.ts
@@ -1,4 +1,4 @@
-import * as Bluebird from 'bluebird'
+import { map } from 'bluebird'
import { getAPId } from '@server/helpers/activitypub'
import { isArray } from '@server/helpers/custom-validators/misc'
import { logger, loggerTagsFactory } from '@server/helpers/logger'
@@ -24,7 +24,7 @@ import {
const lTags = loggerTagsFactory('ap', 'video-playlist')
async function createAccountPlaylists (playlistUrls: string[]) {
- await Bluebird.map(playlistUrls, async playlistUrl => {
+ await map(playlistUrls, async playlistUrl => {
try {
const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl)
if (exists === true) return
@@ -140,7 +140,7 @@ async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MV
async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) {
const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = []
- await Bluebird.map(elementUrls, async elementUrl => {
+ await map(elementUrls, async elementUrl => {
try {
const { elementObject } = await fetchRemotePlaylistElement(elementUrl)
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts
index 1ff01a1751..b18761174f 100644
--- a/server/lib/activitypub/share.ts
+++ b/server/lib/activitypub/share.ts
@@ -1,4 +1,4 @@
-import * as Bluebird from 'bluebird'
+import { map } from 'bluebird'
import { Transaction } from 'sequelize'
import { getServerActor } from '@server/models/application/application'
import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
@@ -38,7 +38,7 @@ async function changeVideoChannelShare (
}
async function addVideoShares (shareUrls: string[], video: MVideoId) {
- await Bluebird.map(shareUrls, async shareUrl => {
+ await map(shareUrls, async shareUrl => {
try {
await addVideoShare(shareUrl, video)
} catch (err) {
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts
index 6b7f9504fd..2a14790fe6 100644
--- a/server/lib/activitypub/video-comments.ts
+++ b/server/lib/activitypub/video-comments.ts
@@ -1,4 +1,4 @@
-import * as Bluebird from 'bluebird'
+import { map } from 'bluebird'
import { checkUrlsSameHost } from '../../helpers/activitypub'
import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments'
import { logger } from '../../helpers/logger'
@@ -18,7 +18,7 @@ type ResolveThreadParams = {
type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
async function addVideoComments (commentUrls: string[]) {
- return Bluebird.map(commentUrls, async commentUrl => {
+ return map(commentUrls, async commentUrl => {
try {
await resolveThread({ url: commentUrl, isVideo: false })
} catch (err) {
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts
index 9fb97ef843..04aa5eae94 100644
--- a/server/lib/activitypub/video-rates.ts
+++ b/server/lib/activitypub/video-rates.ts
@@ -1,4 +1,4 @@
-import * as Bluebird from 'bluebird'
+import { map } from 'bluebird'
import { Transaction } from 'sequelize'
import { doJSONRequest } from '@server/helpers/requests'
import { VideoRateType } from '../../../shared/models/videos'
@@ -15,7 +15,7 @@ import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlBy
const lTags = loggerTagsFactory('ap', 'video-rate', 'create')
async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) {
- await Bluebird.map(ratesUrl, async rateUrl => {
+ await map(ratesUrl, async rateUrl => {
try {
await createRate(rateUrl, video, rate)
} catch (err) {
diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
index bd9ed45a9d..62354ab566 100644
--- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
+++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
@@ -1,5 +1,5 @@
import { maxBy, minBy } from 'lodash'
-import * as magnetUtil from 'magnet-uri'
+import magnetUtil from 'magnet-uri'
import { basename } from 'path'
import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos'
import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos'
diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts
index ae728d080b..f2ef0a78af 100644
--- a/server/lib/auth/oauth-model.ts
+++ b/server/lib/auth/oauth-model.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { AccessDeniedError } from 'oauth2-server'
import { PluginManager } from '@server/lib/plugins/plugin-manager'
import { ActorModel } from '@server/models/actor/actor'
diff --git a/server/lib/auth/oauth.ts b/server/lib/auth/oauth.ts
index a97681c86b..497773536e 100644
--- a/server/lib/auth/oauth.ts
+++ b/server/lib/auth/oauth.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import {
InvalidClientError,
InvalidGrantError,
diff --git a/server/lib/auth/tokens-cache.ts b/server/lib/auth/tokens-cache.ts
index b027ce69a4..410708a352 100644
--- a/server/lib/auth/tokens-cache.ts
+++ b/server/lib/auth/tokens-cache.ts
@@ -1,4 +1,4 @@
-import * as LRUCache from 'lru-cache'
+import LRUCache from 'lru-cache'
import { MOAuthTokenUser } from '@server/types/models'
import { LRU_CACHE } from '../../initializers/constants'
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index e093d35f73..3b0a68f4d6 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { readFile } from 'fs-extra'
import { join } from 'path'
import validator from 'validator'
diff --git a/server/lib/files-cache/abstract-video-static-file-cache.ts b/server/lib/files-cache/abstract-video-static-file-cache.ts
index af66689a0c..a7ac88525c 100644
--- a/server/lib/files-cache/abstract-video-static-file-cache.ts
+++ b/server/lib/files-cache/abstract-video-static-file-cache.ts
@@ -1,6 +1,6 @@
import { remove } from 'fs-extra'
import { logger } from '../../helpers/logger'
-import * as memoizee from 'memoizee'
+import memoizee from 'memoizee'
type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined
diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts
index 56e2b0cebc..d5e4508fea 100644
--- a/server/lib/job-queue/handlers/activitypub-cleaner.ts
+++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts
@@ -1,5 +1,5 @@
-import * as Bluebird from 'bluebird'
-import * as Bull from 'bull'
+import { map } from 'bluebird'
+import { Job } from 'bull'
import { checkUrlsSameHost } from '@server/helpers/activitypub'
import {
isAnnounceActivityValid,
@@ -18,14 +18,14 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat
// Job to clean remote interactions off local videos
-async function processActivityPubCleaner (_job: Bull.Job) {
+async function processActivityPubCleaner (_job: Job) {
logger.info('Processing ActivityPub cleaner.')
{
const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos()
const { bodyValidator, deleter, updater } = rateOptionsFactory()
- await Bluebird.map(rateUrls, async rateUrl => {
+ await map(rateUrls, async rateUrl => {
try {
const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter)
@@ -44,7 +44,7 @@ async function processActivityPubCleaner (_job: Bull.Job) {
const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos()
const { bodyValidator, deleter, updater } = shareOptionsFactory()
- await Bluebird.map(shareUrls, async shareUrl => {
+ await map(shareUrls, async shareUrl => {
try {
await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter)
} catch (err) {
@@ -57,7 +57,7 @@ async function processActivityPubCleaner (_job: Bull.Job) {
const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos()
const { bodyValidator, deleter, updater } = commentOptionsFactory()
- await Bluebird.map(commentUrls, async commentUrl => {
+ await map(commentUrls, async commentUrl => {
try {
await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter)
} catch (err) {
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts
index f896d7af4c..91e3d33c60 100644
--- a/server/lib/job-queue/handlers/activitypub-follow.ts
+++ b/server/lib/job-queue/handlers/activitypub-follow.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url'
import { ActivitypubFollowPayload } from '@shared/models'
import { sanitizeHost } from '../../../helpers/core-utils'
@@ -13,7 +13,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activi
import { sendFollow } from '../../activitypub/send'
import { Notifier } from '../../notifier'
-async function processActivityPubFollow (job: Bull.Job) {
+async function processActivityPubFollow (job: Job) {
const payload = job.data as ActivitypubFollowPayload
const host = payload.host
diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
index d4b328635a..9b0bb6574a 100644
--- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
@@ -1,5 +1,5 @@
-import * as Bluebird from 'bluebird'
-import * as Bull from 'bull'
+import { map } from 'bluebird'
+import { Job } from 'bull'
import { ActivitypubHttpBroadcastPayload } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { doRequest } from '../../../helpers/requests'
@@ -7,7 +7,7 @@ import { BROADCAST_CONCURRENCY } from '../../../initializers/constants'
import { ActorFollowScoreCache } from '../../files-cache'
import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
-async function processActivityPubHttpBroadcast (job: Bull.Job) {
+async function processActivityPubHttpBroadcast (job: Job) {
logger.info('Processing ActivityPub broadcast in job %d.', job.id)
const payload = job.data as ActivitypubHttpBroadcastPayload
@@ -25,7 +25,7 @@ async function processActivityPubHttpBroadcast (job: Bull.Job) {
const badUrls: string[] = []
const goodUrls: string[] = []
- await Bluebird.map(payload.uris, uri => {
+ await map(payload.uris, uri => {
return doRequest(uri, options)
.then(() => goodUrls.push(uri))
.catch(() => badUrls.push(uri))
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
index ab9675cae7..46016a0a7f 100644
--- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
@@ -13,7 +13,7 @@ import { addVideoShares } from '../../activitypub/share'
import { addVideoComments } from '../../activitypub/video-comments'
import { createRates } from '../../activitypub/video-rates'
-async function processActivityPubHttpFetcher (job: Bull.Job) {
+async function processActivityPubHttpFetcher (job: Job) {
logger.info('Processing ActivityPub fetcher in job %d.', job.id)
const payload = job.data as ActivitypubHttpFetcherPayload
diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts
index 9e561c6b75..9be50837f2 100644
--- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts
@@ -1,11 +1,11 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { ActivitypubHttpUnicastPayload } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { doRequest } from '../../../helpers/requests'
import { ActorFollowScoreCache } from '../../files-cache'
import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
-async function processActivityPubHttpUnicast (job: Bull.Job) {
+async function processActivityPubHttpUnicast (job: Job) {
logger.info('Processing ActivityPub unicast in job %d.', job.id)
const payload = job.data as ActivitypubHttpUnicastPayload
diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts
index d97e50ebc4..5037992d22 100644
--- a/server/lib/job-queue/handlers/activitypub-refresher.ts
+++ b/server/lib/job-queue/handlers/activitypub-refresher.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists'
import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos'
import { loadVideoByUrl } from '@server/lib/model-loaders'
@@ -8,7 +8,7 @@ import { ActorModel } from '../../../models/actor/actor'
import { VideoPlaylistModel } from '../../../models/video/video-playlist'
import { refreshActorIfNeeded } from '../../activitypub/actors'
-async function refreshAPObject (job: Bull.Job) {
+async function refreshAPObject (job: Job) {
const payload = job.data as RefreshPayload
logger.info('Processing AP refresher in job %d for %s.', job.id, payload.url)
diff --git a/server/lib/job-queue/handlers/actor-keys.ts b/server/lib/job-queue/handlers/actor-keys.ts
index 60ac61afd2..9d5a65376a 100644
--- a/server/lib/job-queue/handlers/actor-keys.ts
+++ b/server/lib/job-queue/handlers/actor-keys.ts
@@ -1,10 +1,10 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors'
import { ActorModel } from '@server/models/actor/actor'
import { ActorKeysPayload } from '@shared/models'
import { logger } from '../../../helpers/logger'
-async function processActorKeys (job: Bull.Job) {
+async function processActorKeys (job: Job) {
const payload = job.data as ActorKeysPayload
logger.info('Processing actor keys in job %d.', job.id)
diff --git a/server/lib/job-queue/handlers/email.ts b/server/lib/job-queue/handlers/email.ts
index 3157731e2e..6fc1caa84b 100644
--- a/server/lib/job-queue/handlers/email.ts
+++ b/server/lib/job-queue/handlers/email.ts
@@ -1,9 +1,9 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
+import { EmailPayload } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { Emailer } from '../../emailer'
-import { EmailPayload } from '@shared/models'
-async function processEmail (job: Bull.Job) {
+async function processEmail (job: Job) {
const payload = job.data as EmailPayload
logger.info('Processing email in job %d.', job.id)
diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts
index f3b8726eb1..0bebc0fc24 100644
--- a/server/lib/job-queue/handlers/move-to-object-storage.ts
+++ b/server/lib/job-queue/handlers/move-to-object-storage.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { remove } from 'fs-extra'
import { join } from 'path'
import { logger } from '@server/helpers/logger'
@@ -12,7 +12,7 @@ import { VideoJobInfoModel } from '@server/models/video/video-job-info'
import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models'
import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared'
-export async function processMoveToObjectStorage (job: Bull.Job) {
+export async function processMoveToObjectStorage (job: Job) {
const payload = job.data as MoveObjectStoragePayload
logger.info('Moving video %s in job %d.', payload.videoUUID, job.id)
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts
index e8ee1f7596..e6c918e6cb 100644
--- a/server/lib/job-queue/handlers/video-file-import.ts
+++ b/server/lib/job-queue/handlers/video-file-import.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { copy, stat } from 'fs-extra'
import { getLowercaseExtension } from '@server/helpers/core-utils'
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
@@ -16,7 +16,7 @@ import { VideoModel } from '../../../models/video/video'
import { VideoFileModel } from '../../../models/video/video-file'
import { createHlsJobIfEnabled } from './video-transcoding'
-async function processVideoFileImport (job: Bull.Job) {
+async function processVideoFileImport (job: Job) {
const payload = job.data as VideoFileImportPayload
logger.info('Processing video file import in job %d.', job.id)
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts
index a5fa204f55..bdbf07a067 100644
--- a/server/lib/job-queue/handlers/video-import.ts
+++ b/server/lib/job-queue/handlers/video-import.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { move, remove, stat } from 'fs-extra'
import { getLowercaseExtension } from '@server/helpers/core-utils'
import { retryTransactionWrapper } from '@server/helpers/database-utils'
@@ -37,7 +37,7 @@ import { federateVideoIfNeeded } from '../../activitypub/videos'
import { Notifier } from '../../notifier'
import { generateVideoMiniature } from '../../thumbnail'
-async function processVideoImport (job: Bull.Job) {
+async function processVideoImport (job: Job) {
const payload = job.data as VideoImportPayload
if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload)
@@ -52,7 +52,7 @@ export {
// ---------------------------------------------------------------------------
-async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentPayload) {
+async function processTorrentImport (job: Job, payload: VideoImportTorrentPayload) {
logger.info('Processing torrent video import in job %d.', job.id)
const videoImport = await getVideoImportOrDie(payload.videoImportId)
@@ -68,7 +68,7 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP
return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options)
}
-async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) {
+async function processYoutubeDLImport (job: Job, payload: VideoImportYoutubeDLPayload) {
logger.info('Processing youtubeDL video import in job %d.', job.id)
const videoImport = await getVideoImportOrDie(payload.videoImportId)
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index 9ccf724c2d..a04cfa2c90 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { pathExists, readdir, remove } from 'fs-extra'
import { join } from 'path'
import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils'
@@ -17,7 +17,7 @@ import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models'
import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
import { logger } from '../../../helpers/logger'
-async function processVideoLiveEnding (job: Bull.Job) {
+async function processVideoLiveEnding (job: Job) {
const payload = job.data as VideoLiveEndingPayload
function logError () {
diff --git a/server/lib/job-queue/handlers/video-redundancy.ts b/server/lib/job-queue/handlers/video-redundancy.ts
index 6296dab052..9cb7a65891 100644
--- a/server/lib/job-queue/handlers/video-redundancy.ts
+++ b/server/lib/job-queue/handlers/video-redundancy.ts
@@ -1,9 +1,9 @@
-import * as Bull from 'bull'
-import { logger } from '../../../helpers/logger'
+import { Job } from 'bull'
import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler'
import { VideoRedundancyPayload } from '@shared/models'
+import { logger } from '../../../helpers/logger'
-async function processVideoRedundancy (job: Bull.Job) {
+async function processVideoRedundancy (job: Job) {
const payload = job.data as VideoRedundancyPayload
logger.info('Processing video redundancy in job %d.', job.id)
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 5a93c4ed1a..20880cdc1a 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import { Job } from 'bull'
import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
import { VideoPathManager } from '@server/lib/video-path-manager'
@@ -25,7 +25,7 @@ import {
transcodeNewWebTorrentResolution
} from '../../transcoding/video-transcoding'
-type HandlerFunction = (job: Bull.Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
+type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = {
'new-resolution-to-hls': handleHLSJob,
@@ -36,7 +36,7 @@ const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } =
const lTags = loggerTagsFactory('transcoding')
-async function processVideoTranscoding (job: Bull.Job) {
+async function processVideoTranscoding (job: Job) {
const payload = job.data as VideoTranscodingPayload
logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
@@ -64,7 +64,7 @@ async function processVideoTranscoding (job: Bull.Job) {
// Job handlers
// ---------------------------------------------------------------------------
-async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) {
+async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) {
logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid))
const videoFileInput = payload.copyCodecs
@@ -90,7 +90,7 @@ async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, vide
}
async function handleNewWebTorrentResolutionJob (
- job: Bull.Job,
+ job: Job,
payload: NewResolutionTranscodingPayload,
video: MVideoFullLight,
user: MUserId
@@ -104,7 +104,7 @@ async function handleNewWebTorrentResolutionJob (
await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload)
}
-async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
+async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid))
await mergeAudioVideofile(video, payload.resolution, job)
@@ -114,7 +114,7 @@ async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudio
await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user)
}
-async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
+async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid))
const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job)
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts
index 7a3a1bf822..4cda12b575 100644
--- a/server/lib/job-queue/job-queue.ts
+++ b/server/lib/job-queue/job-queue.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull'
+import Bull, { Job, JobOptions, Queue } from 'bull'
import { jobStates } from '@server/helpers/custom-validators/jobs'
import { CONFIG } from '@server/initializers/config'
import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy'
@@ -30,12 +30,12 @@ import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unica
import { refreshAPObject } from './handlers/activitypub-refresher'
import { processActorKeys } from './handlers/actor-keys'
import { processEmail } from './handlers/email'
+import { processMoveToObjectStorage } from './handlers/move-to-object-storage'
import { processVideoFileImport } from './handlers/video-file-import'
import { processVideoImport } from './handlers/video-import'
import { processVideoLiveEnding } from './handlers/video-live-ending'
import { processVideoTranscoding } from './handlers/video-transcoding'
import { processVideosViews } from './handlers/video-views'
-import { processMoveToObjectStorage } from './handlers/move-to-object-storage'
type CreateJobArgument =
{ type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } |
@@ -59,7 +59,7 @@ export type CreateJobOptions = {
priority?: number
}
-const handlers: { [id in JobType]: (job: Bull.Job) => Promise<any> } = {
+const handlers: { [id in JobType]: (job: Job) => Promise<any> } = {
'activitypub-http-broadcast': processActivityPubHttpBroadcast,
'activitypub-http-unicast': processActivityPubHttpUnicast,
'activitypub-http-fetcher': processActivityPubHttpFetcher,
@@ -99,7 +99,7 @@ class JobQueue {
private static instance: JobQueue
- private queues: { [id in JobType]?: Bull.Queue } = {}
+ private queues: { [id in JobType]?: Queue } = {}
private initialized = false
private jobRedisPrefix: string
@@ -160,7 +160,7 @@ class JobQueue {
return
}
- const jobArgs: Bull.JobOptions = {
+ const jobArgs: JobOptions = {
backoff: { delay: 60 * 1000, type: 'exponential' },
attempts: JOB_ATTEMPTS[obj.type],
timeout: JOB_TTL[obj.type],
@@ -177,11 +177,11 @@ class JobQueue {
count: number
asc?: boolean
jobType: JobType
- }): Promise<Bull.Job[]> {
+ }): Promise<Job[]> {
const { state, start, count, asc, jobType } = options
const states = state ? [ state ] : jobStates
- let results: Bull.Job[] = []
+ let results: Job[] = []
const filteredJobTypes = this.filterJobTypes(jobType)
diff --git a/server/lib/live/shared/muxing-session.ts b/server/lib/live/shared/muxing-session.ts
index 0c9fb0cb63..a6907142d2 100644
--- a/server/lib/live/shared/muxing-session.ts
+++ b/server/lib/live/shared/muxing-session.ts
@@ -1,6 +1,6 @@
-import * as Bluebird from 'bluebird'
-import * as chokidar from 'chokidar'
+import { mapSeries } from 'bluebird'
+import { FSWatcher, watch } from 'chokidar'
import { FfmpegCommand } from 'fluent-ffmpeg'
import { appendFile, ensureDir, readFile, stat } from 'fs-extra'
import { basename, join } from 'path'
@@ -67,8 +67,8 @@ class MuxingSession extends EventEmitter {
private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {}
- private tsWatcher: chokidar.FSWatcher
- private masterWatcher: chokidar.FSWatcher
+ private tsWatcher: FSWatcher
+ private masterWatcher: FSWatcher
private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => {
return isAbleToUploadVideo(userId, 1000)
@@ -197,7 +197,7 @@ class MuxingSession extends EventEmitter {
}
private watchMasterFile (outPath: string) {
- this.masterWatcher = chokidar.watch(outPath + '/' + this.streamingPlaylist.playlistFilename)
+ this.masterWatcher = watch(outPath + '/' + this.streamingPlaylist.playlistFilename)
this.masterWatcher.on('add', () => {
this.emit('master-playlist-created', { videoId: this.videoId })
@@ -210,7 +210,7 @@ class MuxingSession extends EventEmitter {
private watchTSFiles (outPath: string) {
const startStreamDateTime = new Date().getTime()
- this.tsWatcher = chokidar.watch(outPath + '/*.ts')
+ this.tsWatcher = watch(outPath + '/*.ts')
const playlistIdMatcher = /^([\d+])-/
@@ -306,7 +306,7 @@ class MuxingSession extends EventEmitter {
}
private processSegments (hlsVideoPath: string, segmentPaths: string[]) {
- Bluebird.mapSeries(segmentPaths, async previousSegment => {
+ mapSeries(segmentPaths, async previousSegment => {
// Add sha hash of previous segments, because ffmpeg should have finished generating them
await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment)
diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.ts
index 77667f6b0b..821a92b912 100644
--- a/server/lib/local-actor.ts
+++ b/server/lib/local-actor.ts
@@ -1,6 +1,6 @@
import 'multer'
import { queue } from 'async'
-import * as LRUCache from 'lru-cache'
+import LRUCache from 'lru-cache'
import { join } from 'path'
import { getLowercaseExtension } from '@server/helpers/core-utils'
import { buildUUID } from '@server/helpers/uuid'
diff --git a/server/lib/peertube-socket.ts b/server/lib/peertube-socket.ts
index 0740e378e6..901435dea7 100644
--- a/server/lib/peertube-socket.ts
+++ b/server/lib/peertube-socket.ts
@@ -1,23 +1,23 @@
-import { Server } from 'http'
-import * as SocketIO from 'socket.io'
+import { Server as HTTPServer } from 'http'
+import { Namespace, Server as SocketServer, Socket } from 'socket.io'
+import { isIdValid } from '@server/helpers/custom-validators/misc'
import { MVideo } from '@server/types/models'
import { UserNotificationModelForApi } from '@server/types/models/user'
import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models'
import { logger } from '../helpers/logger'
import { authenticateSocket } from '../middlewares'
-import { isIdValid } from '@server/helpers/custom-validators/misc'
class PeerTubeSocket {
private static instance: PeerTubeSocket
- private userNotificationSockets: { [ userId: number ]: SocketIO.Socket[] } = {}
- private liveVideosNamespace: SocketIO.Namespace
+ private userNotificationSockets: { [ userId: number ]: Socket[] } = {}
+ private liveVideosNamespace: Namespace
private constructor () {}
- init (server: Server) {
- const io = new SocketIO.Server(server)
+ init (server: HTTPServer) {
+ const io = new SocketServer(server)
io.of('/user-notifications')
.use(authenticateSocket)
diff --git a/server/lib/plugins/hooks.ts b/server/lib/plugins/hooks.ts
index 5e97b52a01..327aaece2d 100644
--- a/server/lib/plugins/hooks.ts
+++ b/server/lib/plugins/hooks.ts
@@ -1,4 +1,4 @@
-import * as Bluebird from 'bluebird'
+import Bluebird from 'bluebird'
import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models'
import { logger } from '../../helpers/logger'
import { PluginManager } from './plugin-manager'
diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts
index 8487672bac..e26776f450 100644
--- a/server/lib/plugins/plugin-helpers-builder.ts
+++ b/server/lib/plugins/plugin-helpers-builder.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { join } from 'path'
import { buildLogger } from '@server/helpers/logger'
import { CONFIG } from '@server/initializers/config'
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 6599bcccaf..d4d2a7edc3 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -1,5 +1,5 @@
import decache from 'decache'
-import * as express from 'express'
+import express from 'express'
import { createReadStream, createWriteStream } from 'fs'
import { ensureDir, outputFile, readJSON } from 'fs-extra'
import { basename, join } from 'path'
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts
index af533effd8..acca9309a7 100644
--- a/server/lib/plugins/register-helpers.ts
+++ b/server/lib/plugins/register-helpers.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { logger } from '@server/helpers/logger'
import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth'
import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory'
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index 62641e313a..d1d88d853d 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { createClient, RedisClient } from 'redis'
import { logger } from '../helpers/logger'
import { generateRandomString } from '../helpers/utils'
diff --git a/server/lib/schedulers/abstract-scheduler.ts b/server/lib/schedulers/abstract-scheduler.ts
index 0e60889117..f3d51a22e0 100644
--- a/server/lib/schedulers/abstract-scheduler.ts
+++ b/server/lib/schedulers/abstract-scheduler.ts
@@ -1,5 +1,5 @@
+import Bluebird from 'bluebird'
import { logger } from '../../helpers/logger'
-import * as Bluebird from 'bluebird'
export abstract class AbstractScheduler {
diff --git a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts b/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
index 1acea79985..099fa56513 100644
--- a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
+++ b/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
@@ -1,4 +1,4 @@
-import * as bluebird from 'bluebird'
+import { map } from 'bluebird'
import { readdir, remove, stat } from 'fs-extra'
import { logger, loggerTagsFactory } from '@server/helpers/logger'
import { getResumableUploadPath } from '@server/helpers/upload'
@@ -32,7 +32,7 @@ export class RemoveDanglingResumableUploadsScheduler extends AbstractScheduler {
logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags())
try {
- await bluebird.map(metafiles, metafile => {
+ await map(metafiles, metafile => {
return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs)
}, { concurrency: 5 })
} catch (error) {
diff --git a/server/lib/search.ts b/server/lib/search.ts
index b643a4055e..2f4c5eed9b 100644
--- a/server/lib/search.ts
+++ b/server/lib/search.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { CONFIG } from '@server/initializers/config'
import { AccountBlocklistModel } from '@server/models/account/account-blocklist'
import { getServerActor } from '@server/models/application/application'
diff --git a/server/lib/signup.ts b/server/lib/signup.ts
index 8fa81e601d..3c1397a128 100644
--- a/server/lib/signup.ts
+++ b/server/lib/signup.ts
@@ -1,6 +1,6 @@
-import { UserModel } from '../models/user/user'
-import * as ipaddr from 'ipaddr.js'
+import { IPv4, IPv6, parse, subnetMatch } from 'ipaddr.js'
import { CONFIG } from '../initializers/config'
+import { UserModel } from '../models/user/user'
const isCidr = require('is-cidr')
@@ -22,7 +22,7 @@ async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: st
function isSignupAllowedForCurrentIP (ip: string) {
if (!ip) return false
- const addr = ipaddr.parse(ip)
+ const addr = parse(ip)
const excludeList = [ 'blacklist' ]
let matched = ''
@@ -32,23 +32,23 @@ function isSignupAllowedForCurrentIP (ip: string) {
}
if (addr.kind() === 'ipv4') {
- const addrV4 = ipaddr.IPv4.parse(ip)
+ const addrV4 = IPv4.parse(ip)
const rangeList = {
whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr))
- .map(cidr => ipaddr.IPv4.parseCIDR(cidr)),
+ .map(cidr => IPv4.parseCIDR(cidr)),
blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr))
- .map(cidr => ipaddr.IPv4.parseCIDR(cidr))
+ .map(cidr => IPv4.parseCIDR(cidr))
}
- matched = ipaddr.subnetMatch(addrV4, rangeList, 'unknown')
+ matched = subnetMatch(addrV4, rangeList, 'unknown')
} else if (addr.kind() === 'ipv6') {
- const addrV6 = ipaddr.IPv6.parse(ip)
+ const addrV6 = IPv6.parse(ip)
const rangeList = {
whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr))
- .map(cidr => ipaddr.IPv6.parseCIDR(cidr)),
+ .map(cidr => IPv6.parseCIDR(cidr)),
blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr))
- .map(cidr => ipaddr.IPv6.parseCIDR(cidr))
+ .map(cidr => IPv6.parseCIDR(cidr))
}
- matched = ipaddr.subnetMatch(addrV6, rangeList, 'unknown')
+ matched = subnetMatch(addrV6, rangeList, 'unknown')
}
return !excludeList.includes(matched)
diff --git a/server/lib/stat-manager.ts b/server/lib/stat-manager.ts
index 3c5e0a93e0..03063793d8 100644
--- a/server/lib/stat-manager.ts
+++ b/server/lib/stat-manager.ts
@@ -1,14 +1,14 @@
+import { mapSeries } from 'bluebird'
import { CONFIG } from '@server/initializers/config'
-import { UserModel } from '@server/models/user/user'
import { ActorFollowModel } from '@server/models/actor/actor-follow'
import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
+import { UserModel } from '@server/models/user/user'
import { VideoModel } from '@server/models/video/video'
import { VideoChannelModel } from '@server/models/video/video-channel'
import { VideoCommentModel } from '@server/models/video/video-comment'
import { VideoFileModel } from '@server/models/video/video-file'
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models'
-import * as Bluebird from 'bluebird'
class StatsManager {
@@ -107,7 +107,7 @@ class StatsManager {
strategies.push({ strategy: 'manual', size: null })
- return Bluebird.mapSeries(strategies, r => {
+ return mapSeries(strategies, r => {
return VideoRedundancyModel.getStats(r.strategy)
.then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size }))
})
diff --git a/server/middlewares/auth.ts b/server/middlewares/auth.ts
index 9e6327b237..c5424be979 100644
--- a/server/middlewares/auth.ts
+++ b/server/middlewares/auth.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { Socket } from 'socket.io'
import { getAccessToken } from '@server/lib/auth/oauth-model'
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
diff --git a/server/middlewares/cache/shared/api-cache.ts b/server/middlewares/cache/shared/api-cache.ts
index f9f7b1b673..f8846dcfcd 100644
--- a/server/middlewares/cache/shared/api-cache.ts
+++ b/server/middlewares/cache/shared/api-cache.ts
@@ -1,7 +1,7 @@
// Thanks: https://github.com/kwhitley/apicache
// We duplicated the library because it is unmaintened and prevent us to upgrade to recent NodeJS versions
-import * as express from 'express'
+import express from 'express'
import { OutgoingHttpHeaders } from 'http'
import { isTestInstance, parseDurationToMs } from '@server/helpers/core-utils'
import { logger } from '@server/helpers/logger'
diff --git a/server/middlewares/csp.ts b/server/middlewares/csp.ts
index 0ee44bf478..e2a75a17eb 100644
--- a/server/middlewares/csp.ts
+++ b/server/middlewares/csp.ts
@@ -1,4 +1,4 @@
-import * as helmet from 'helmet'
+import { contentSecurityPolicy } from 'helmet'
import { CONFIG } from '../initializers/config'
const baseDirectives = Object.assign({},
@@ -22,12 +22,12 @@ const baseDirectives = Object.assign({},
CONFIG.WEBSERVER.SCHEME === 'https' ? { upgradeInsecureRequests: [] } : {}
)
-const baseCSP = helmet.contentSecurityPolicy({
+const baseCSP = contentSecurityPolicy({
directives: baseDirectives,
reportOnly: CONFIG.CSP.REPORT_ONLY
})
-const embedCSP = helmet.contentSecurityPolicy({
+const embedCSP = contentSecurityPolicy({
directives: Object.assign({}, baseDirectives, { frameAncestors: [ '*' ] }),
reportOnly: CONFIG.CSP.REPORT_ONLY
})
diff --git a/server/middlewares/doc.ts b/server/middlewares/doc.ts
index 3db85c68d9..eef76acaa0 100644
--- a/server/middlewares/doc.ts
+++ b/server/middlewares/doc.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
function openapiOperationDoc (options: {
url?: string
diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts
index af5a9c29a0..6c52ce7bd9 100644
--- a/server/middlewares/error.ts
+++ b/server/middlewares/error.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details'
import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/pagination.ts b/server/middlewares/pagination.ts
index b59717d7bc..9812af9e48 100644
--- a/server/middlewares/pagination.ts
+++ b/server/middlewares/pagination.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { PAGINATION } from '../initializers/constants'
function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts
index cf70d901e3..ebfa03e6ca 100644
--- a/server/middlewares/servers.ts
+++ b/server/middlewares/servers.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { getHostWithPort } from '../helpers/express-utils'
diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts
index 0600ccd155..4588958988 100644
--- a/server/middlewares/sort.ts
+++ b/server/middlewares/sort.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { SortType } from '../models/utils'
const setDefaultSort = setDefaultSortFactory('-createdAt')
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index c8c694f055..ea95b16c2d 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { UserRight } from '../../shared'
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { logger } from '../helpers/logger'
diff --git a/server/middlewares/validators/abuse.ts b/server/middlewares/validators/abuse.ts
index f4d9c3af20..22f66c8cff 100644
--- a/server/middlewares/validators/abuse.ts
+++ b/server/middlewares/validators/abuse.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query } from 'express-validator'
import {
areAbusePredefinedReasonsValid,
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index 599eb10bb2..e529c831d5 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { param } from 'express-validator'
import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts
index d24e4427b7..e296b8be74 100644
--- a/server/middlewares/validators/activitypub/activity.ts
+++ b/server/middlewares/validators/activitypub/activity.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { getServerActor } from '@server/models/application/application'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity'
diff --git a/server/middlewares/validators/activitypub/pagination.ts b/server/middlewares/validators/activitypub/pagination.ts
index c8ec34eb6a..c542d41731 100644
--- a/server/middlewares/validators/activitypub/pagination.ts
+++ b/server/middlewares/validators/activitypub/pagination.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { query } from 'express-validator'
import { PAGINATION } from '@server/initializers/constants'
import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/middlewares/validators/activitypub/signature.ts
index f2f7d58487..642bcefe0d 100644
--- a/server/middlewares/validators/activitypub/signature.ts
+++ b/server/middlewares/validators/activitypub/signature.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body } from 'express-validator'
import {
isSignatureCreatorValid,
diff --git a/server/middlewares/validators/actor-image.ts b/server/middlewares/validators/actor-image.ts
index 49daadd619..c7e9f391c8 100644
--- a/server/middlewares/validators/actor-image.ts
+++ b/server/middlewares/validators/actor-image.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body } from 'express-validator'
import { isActorImageFile } from '@server/helpers/custom-validators/actor-images'
import { cleanUpReqFiles } from '../../helpers/express-utils'
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts
index f15b293e95..b7749e204c 100644
--- a/server/middlewares/validators/blocklist.ts
+++ b/server/middlewares/validators/blocklist.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param } from 'express-validator'
import { getServerActor } from '@server/models/application/application'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
diff --git a/server/middlewares/validators/bulk.ts b/server/middlewares/validators/bulk.ts
index 6fec581493..1cfc7481ee 100644
--- a/server/middlewares/validators/bulk.ts
+++ b/server/middlewares/validators/bulk.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body } from 'express-validator'
import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk'
import { HttpStatusCode, UserRight } from '@shared/models'
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index 1aeadbe65f..16a840667d 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body } from 'express-validator'
import { isIntOrNull } from '@server/helpers/custom-validators/misc'
import { isEmailEnabled } from '@server/initializers/config'
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index d29bebf647..f8ebaf6ed8 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { param, query } from 'express-validator'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts
index 16abdd096c..df4cefe281 100644
--- a/server/middlewares/validators/follows.ts
+++ b/server/middlewares/validators/follows.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query } from 'express-validator'
import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows'
import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors'
diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts
index 5d89d167f6..4de90548b0 100644
--- a/server/middlewares/validators/jobs.ts
+++ b/server/middlewares/validators/jobs.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { param, query } from 'express-validator'
import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
import { logger, loggerTagsFactory } from '../../helpers/logger'
diff --git a/server/middlewares/validators/logs.ts b/server/middlewares/validators/logs.ts
index c55baaee38..03c1c4df15 100644
--- a/server/middlewares/validators/logs.ts
+++ b/server/middlewares/validators/logs.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { query } from 'express-validator'
import { isValidLogLevel } from '../../helpers/custom-validators/logs'
import { isDateValid } from '../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index e5fc0c277d..5e47211b57 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { query } from 'express-validator'
import { join } from 'path'
import { loadVideo } from '@server/lib/model-loaders'
diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.ts
index 74eae251e0..8e4922b9d4 100644
--- a/server/middlewares/validators/pagination.ts
+++ b/server/middlewares/validators/pagination.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { query } from 'express-validator'
import { PAGINATION } from '@server/initializers/constants'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 3fb2176b9d..21171af236 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query, ValidationChain } from 'express-validator'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { PluginType } from '../../../shared/models/plugins/plugin.type'
diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts
index f1b2ff5cd9..d31b216f59 100644
--- a/server/middlewares/validators/redundancy.ts
+++ b/server/middlewares/validators/redundancy.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query } from 'express-validator'
import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts
index 27d0e541d6..e6ec8642ad 100644
--- a/server/middlewares/validators/search.ts
+++ b/server/middlewares/validators/search.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { query } from 'express-validator'
import { isSearchTargetValid } from '@server/helpers/custom-validators/search'
import { isHostValid } from '@server/helpers/custom-validators/servers'
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts
index 29fdc13d28..10bbefe388 100644
--- a/server/middlewares/validators/server.ts
+++ b/server/middlewares/validators/server.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body } from 'express-validator'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
diff --git a/server/middlewares/validators/shared/utils.ts b/server/middlewares/validators/shared/utils.ts
index 4f08560af5..5c66ad500f 100644
--- a/server/middlewares/validators/shared/utils.ts
+++ b/server/middlewares/validators/shared/utils.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { param, query, validationResult } from 'express-validator'
import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/shared/video-channels.ts b/server/middlewares/validators/shared/video-channels.ts
index 3fc3d012a6..7c0c89267b 100644
--- a/server/middlewares/validators/shared/video-channels.ts
+++ b/server/middlewares/validators/shared/video-channels.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { VideoChannelModel } from '@server/models/video/video-channel'
import { MChannelBannerAccountDefault } from '@server/types/models'
import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/validators/shared/video-comments.ts b/server/middlewares/validators/shared/video-comments.ts
index 60132fb6e0..386ae911f2 100644
--- a/server/middlewares/validators/shared/video-comments.ts
+++ b/server/middlewares/validators/shared/video-comments.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { VideoCommentModel } from '@server/models/video/video-comment'
import { MVideoId } from '@server/types/models'
import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/validators/shared/video-imports.ts b/server/middlewares/validators/shared/video-imports.ts
index 50b49ffcb6..69fda4b324 100644
--- a/server/middlewares/validators/shared/video-imports.ts
+++ b/server/middlewares/validators/shared/video-imports.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { VideoImportModel } from '@server/models/video/video-import'
import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/validators/shared/video-ownerships.ts b/server/middlewares/validators/shared/video-ownerships.ts
index 93a23ef40e..680613cda4 100644
--- a/server/middlewares/validators/shared/video-ownerships.ts
+++ b/server/middlewares/validators/shared/video-ownerships.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/validators/shared/video-playlists.ts b/server/middlewares/validators/shared/video-playlists.ts
index 3f67681797..4342fe5527 100644
--- a/server/middlewares/validators/shared/video-playlists.ts
+++ b/server/middlewares/validators/shared/video-playlists.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
import { MVideoPlaylist } from '@server/types/models'
import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts
index 2953b9505b..7b9fee8588 100644
--- a/server/middlewares/validators/themes.ts
+++ b/server/middlewares/validators/themes.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { param } from 'express-validator'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isSafePath } from '../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.ts
index 1db0d9b264..f9be266278 100644
--- a/server/middlewares/validators/user-history.ts
+++ b/server/middlewares/validators/user-history.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, query } from 'express-validator'
import { exists, isDateValid } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/user-notifications.ts b/server/middlewares/validators/user-notifications.ts
index 2f8e7686ef..4a7577d32e 100644
--- a/server/middlewares/validators/user-notifications.ts
+++ b/server/middlewares/validators/user-notifications.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, query } from 'express-validator'
import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc'
import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts
index df57777714..48ce90d7b0 100644
--- a/server/middlewares/validators/user-subscriptions.ts
+++ b/server/middlewares/validators/user-subscriptions.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query } from 'express-validator'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index c6977fcd9d..c06b85862d 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query } from 'express-validator'
import { omit } from 'lodash'
import { Hooks } from '@server/lib/plugins/hooks'
diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts
index 3a4937b7b6..de11e69f2a 100644
--- a/server/middlewares/validators/videos/video-blacklist.ts
+++ b/server/middlewares/validators/videos/video-blacklist.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, query } from 'express-validator'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/middlewares/validators/videos/video-captions.ts
index 6bc127e01a..38321ccf9a 100644
--- a/server/middlewares/validators/videos/video-captions.ts
+++ b/server/middlewares/validators/videos/video-captions.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param } from 'express-validator'
import { UserRight } from '../../../../shared'
import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions'
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts
index 3b5693d231..fc717abf64 100644
--- a/server/middlewares/validators/videos/video-channels.ts
+++ b/server/middlewares/validators/videos/video-channels.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query } from 'express-validator'
import { VIDEO_CHANNELS } from '@server/initializers/constants'
import { MChannelAccountDefault, MUser } from '@server/types/models'
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 61c2ed92f8..3ea8bdcbbe 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query } from 'express-validator'
import { MUserAccountUrl } from '@server/types/models'
import { UserRight } from '../../../../shared'
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts
index 52b839e569..640139c739 100644
--- a/server/middlewares/validators/videos/video-imports.ts
+++ b/server/middlewares/validators/videos/video-imports.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body } from 'express-validator'
import { isPreImportVideoAccepted } from '@server/lib/moderation'
import { Hooks } from '@server/lib/plugins/hooks'
diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts
index 97e8b4510a..6c7601e052 100644
--- a/server/middlewares/validators/videos/video-live.ts
+++ b/server/middlewares/validators/videos/video-live.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body } from 'express-validator'
import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
diff --git a/server/middlewares/validators/videos/video-ownership-changes.ts b/server/middlewares/validators/videos/video-ownership-changes.ts
index a7f0b72c38..95e4cebced 100644
--- a/server/middlewares/validators/videos/video-ownership-changes.ts
+++ b/server/middlewares/validators/videos/video-ownership-changes.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { param } from 'express-validator'
import { isIdValid } from '@server/helpers/custom-validators/misc'
import { checkUserCanTerminateOwnershipChange } from '@server/helpers/custom-validators/video-ownership'
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index ab84b4814a..8f5c75fd5b 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query, ValidationChain } from 'express-validator'
import { ExpressPromiseHandler } from '@server/types/express'
import { MUserAccountId } from '@server/types/models'
diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts
index 5fe78b39e8..6e0bb0ad1e 100644
--- a/server/middlewares/validators/videos/video-rates.ts
+++ b/server/middlewares/validators/videos/video-rates.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, param, query } from 'express-validator'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { VideoRateType } from '../../../../shared/models/videos'
diff --git a/server/middlewares/validators/videos/video-shares.ts b/server/middlewares/validators/videos/video-shares.ts
index 3b8d617680..0f04032bb3 100644
--- a/server/middlewares/validators/videos/video-shares.ts
+++ b/server/middlewares/validators/videos/video-shares.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { param } from 'express-validator'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { isIdValid } from '../../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/videos/video-watch.ts b/server/middlewares/validators/videos/video-watch.ts
index 431515eb15..d83710a647 100644
--- a/server/middlewares/validators/videos/video-watch.ts
+++ b/server/middlewares/validators/videos/video-watch.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body } from 'express-validator'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { toIntOrNull } from '../../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 13187f3985..23ee9778af 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { body, header, param, query, ValidationChain } from 'express-validator'
import { getResumableUploadPath } from '@server/helpers/upload'
import { isAbleToUploadVideo } from '@server/lib/user'
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index 1313608203..8893a0c7e8 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { query } from 'express-validator'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
diff --git a/server/models/application/application.ts b/server/models/application/application.ts
index 5531d134a1..e3939383be 100644
--- a/server/models/application/application.ts
+++ b/server/models/application/application.ts
@@ -1,4 +1,4 @@
-import * as memoizee from 'memoizee'
+import memoizee from 'memoizee'
import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
import { AttributesOnly } from '@shared/core-utils'
import { AccountModel } from '../account/account'
diff --git a/server/models/model-cache.ts b/server/models/model-cache.ts
index eafb5c13ce..3651267e7c 100644
--- a/server/models/model-cache.ts
+++ b/server/models/model-cache.ts
@@ -1,5 +1,4 @@
import { Model } from 'sequelize-typescript'
-import * as Bluebird from 'bluebird'
import { logger } from '@server/helpers/logger'
type ModelCacheType =
@@ -52,7 +51,7 @@ class ModelCache {
if (cache.has(key)) {
logger.debug('Model cache hit for %s -> %s.', cacheType, key)
- return Bluebird.resolve<T>(cache.get(key))
+ return Promise.resolve<T>(cache.get(key))
}
return fun().then(m => {
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index e933989aec..c89279c65e 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -585,7 +585,7 @@ export class VideoCommentModel extends Model<Partial<AttributesOnly<VideoComment
if (accountId) {
whereAnd.push({
- [Op.eq]: accountId
+ accountId
})
}
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 627c957635..5e8d29d0a9 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -1,5 +1,5 @@
import { remove } from 'fs-extra'
-import * as memoizee from 'memoizee'
+import memoizee from 'memoizee'
import { join } from 'path'
import { FindOptions, Op, Transaction } from 'sequelize'
import {
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts
index 3e9fd97c72..18d96c7507 100644
--- a/server/models/video/video-streaming-playlist.ts
+++ b/server/models/video/video-streaming-playlist.ts
@@ -1,4 +1,4 @@
-import * as memoizee from 'memoizee'
+import memoizee from 'memoizee'
import { join } from 'path'
import { Op } from 'sequelize'
import {
diff --git a/server/models/video/video-view.ts b/server/models/video/video-view.ts
index dfc6296ce2..b51f0f84d1 100644
--- a/server/models/video/video-view.ts
+++ b/server/models/video/video-view.ts
@@ -1,5 +1,5 @@
-import * as Sequelize from 'sequelize'
-import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript'
+import { literal, Op } from 'sequelize'
+import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Model, Table } from 'sequelize-typescript'
import { AttributesOnly } from '@shared/core-utils'
import { VideoModel } from './video'
@@ -20,11 +20,11 @@ export class VideoViewModel extends Model<Partial<AttributesOnly<VideoViewModel>
createdAt: Date
@AllowNull(false)
- @Column(Sequelize.DATE)
+ @Column(DataType.DATE)
startDate: Date
@AllowNull(false)
- @Column(Sequelize.DATE)
+ @Column(DataType.DATE)
endDate: Date
@AllowNull(false)
@@ -47,10 +47,10 @@ export class VideoViewModel extends Model<Partial<AttributesOnly<VideoViewModel>
const query = {
where: {
startDate: {
- [Sequelize.Op.lt]: beforeDate
+ [Op.lt]: beforeDate
},
videoId: {
- [Sequelize.Op.in]: Sequelize.literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)')
+ [Op.in]: literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)')
}
}
}
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 874ad168a1..e0c4dd2dbe 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1,4 +1,4 @@
-import * as Bluebird from 'bluebird'
+import Bluebird from 'bluebird'
import { remove } from 'fs-extra'
import { maxBy, minBy } from 'lodash'
import { join } from 'path'
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index fe42e5fa87..86b40cfe60 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -3,7 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import { readdir } from 'fs-extra'
-import * as magnetUtil from 'magnet-uri'
+import magnetUtil from 'magnet-uri'
import { basename, join } from 'path'
import {
checkSegmentHash,
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts
index 719813ae90..1e0c95a3b1 100644
--- a/server/tests/api/server/no-client.ts
+++ b/server/tests/api/server/no-client.ts
@@ -1,5 +1,5 @@
import 'mocha'
-import * as request from 'supertest'
+import request from 'supertest'
import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils'
import { HttpStatusCode } from '@shared/models'
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts
index f597ac60ce..30a9618b30 100644
--- a/server/tests/api/server/tracker.ts
+++ b/server/tests/api/server/tracker.ts
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await,@typescript-eslint/no-floating-promises */
import 'mocha'
-import * as magnetUtil from 'magnet-uri'
-import * as WebTorrent from 'webtorrent'
+import magnetUtil from 'magnet-uri'
+import WebTorrent from 'webtorrent'
import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
describe('Test tracker', function () {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index f9220e4b34..df9deb1e10 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import * as request from 'supertest'
+import request from 'supertest'
import {
buildAbsoluteFixturePath,
checkTmpIsEmpty,
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index 55b4348465..a1c976fd30 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import * as xmlParser from 'fast-xml-parser'
+import { parse, validate } from 'fast-xml-parser'
import {
cleanupTests,
createMultipleServers,
@@ -149,9 +149,9 @@ describe('Test syndication feeds', () => {
it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () {
for (const server of servers) {
const rss = await server.feed.getXML({ feed: 'videos' })
- expect(xmlParser.validate(rss)).to.be.true
+ expect(validate(rss)).to.be.true
- const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false })
+ const xmlDoc = parse(rss, { parseAttributeValue: true, ignoreAttributes: false })
const enclosure = xmlDoc.rss.channel.item[0].enclosure
expect(enclosure).to.exist
diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts
index b9f4ef4f8e..afa19ee085 100644
--- a/server/tools/peertube-auth.ts
+++ b/server/tools/peertube-auth.ts
@@ -4,10 +4,11 @@ import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths()
import { OptionValues, program } from 'commander'
-import * as prompt from 'prompt'
import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli'
import { isUserUsernameValid } from '../helpers/custom-validators/users'
-import * as CliTable3 from 'cli-table3'
+import CliTable3 from 'cli-table3'
+
+import prompt = require('prompt')
async function delInstance (url: string) {
const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ])
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index 488109b7a7..758b561e1b 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -6,7 +6,6 @@ import { accessSync, constants } from 'fs'
import { remove } from 'fs-extra'
import { truncate } from 'lodash'
import { join } from 'path'
-import * as prompt from 'prompt'
import { promisify } from 'util'
import { YoutubeDL } from '@server/helpers/youtube-dl'
import { sha256 } from '../helpers/core-utils'
@@ -22,6 +21,8 @@ import {
} from './cli'
import { PeerTubeServer } from '@shared/extra-utils'
+import prompt = require('prompt')
+
const processOptions = {
maxBuffer: Infinity
}
diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts
index d9c285115c..ae625114d2 100644
--- a/server/tools/peertube-plugins.ts
+++ b/server/tools/peertube-plugins.ts
@@ -7,7 +7,7 @@ import { program, Command, OptionValues } from 'commander'
import { assignToken, buildServer, getServerCredentials } from './cli'
import { PluginType } from '../../shared/models'
import { isAbsolute } from 'path'
-import * as CliTable3 from 'cli-table3'
+import CliTable3 from 'cli-table3'
program
.name('plugins')
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts
index 73b026ac8f..7e27ca49e6 100644
--- a/server/tools/peertube-redundancy.ts
+++ b/server/tools/peertube-redundancy.ts
@@ -1,7 +1,7 @@
import { registerTSPaths } from '../helpers/register-ts-paths'
registerTSPaths()
-import * as CliTable3 from 'cli-table3'
+import CliTable3 from 'cli-table3'
import { Command, program } from 'commander'
import { uniq } from 'lodash'
import { URL } from 'url'
diff --git a/server/types/plugins/register-server-auth.model.ts b/server/types/plugins/register-server-auth.model.ts
index 3e1a5aeba1..79c18c406c 100644
--- a/server/types/plugins/register-server-auth.model.ts
+++ b/server/types/plugins/register-server-auth.model.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { UserRole } from '@shared/models'
import { MOAuthToken, MUser } from '../models'
diff --git a/shared/extra-utils/miscs/generate.ts b/shared/extra-utils/miscs/generate.ts
index a03a200495..3b29c0ad49 100644
--- a/shared/extra-utils/miscs/generate.ts
+++ b/shared/extra-utils/miscs/generate.ts
@@ -1,5 +1,5 @@
import { expect } from 'chai'
-import * as ffmpeg from 'fluent-ffmpeg'
+import ffmpeg from 'fluent-ffmpeg'
import { ensureDir, pathExists } from 'fs-extra'
import { dirname } from 'path'
import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@server/helpers/ffprobe-utils'
diff --git a/shared/extra-utils/miscs/webtorrent.ts b/shared/extra-utils/miscs/webtorrent.ts
index a1097effe7..8fe2ad8216 100644
--- a/shared/extra-utils/miscs/webtorrent.ts
+++ b/shared/extra-utils/miscs/webtorrent.ts
@@ -1,5 +1,5 @@
import { readFile } from 'fs-extra'
-import * as parseTorrent from 'parse-torrent'
+import parseTorrent from 'parse-torrent'
import { basename, join } from 'path'
import * as WebTorrent from 'webtorrent'
import { VideoFile } from '@shared/models'
diff --git a/shared/extra-utils/mock-servers/mock-email.ts b/shared/extra-utils/mock-servers/mock-email.ts
index ffd62e3253..c13d3dc0f4 100644
--- a/shared/extra-utils/mock-servers/mock-email.ts
+++ b/shared/extra-utils/mock-servers/mock-email.ts
@@ -1,9 +1,8 @@
import { ChildProcess } from 'child_process'
+import MailDev from 'maildev'
import { randomInt } from '@shared/core-utils'
import { parallelTests } from '../miscs'
-const MailDev = require('maildev')
-
class MockSmtpServer {
private static instance: MockSmtpServer
diff --git a/shared/extra-utils/mock-servers/mock-instances-index.ts b/shared/extra-utils/mock-servers/mock-instances-index.ts
index c9e33087de..2aabef9d26 100644
--- a/shared/extra-utils/mock-servers/mock-instances-index.ts
+++ b/shared/extra-utils/mock-servers/mock-instances-index.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { randomInt } from '@shared/core-utils'
export class MockInstancesIndex {
diff --git a/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts b/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts
index 5ea432ecfc..5106fc66a2 100644
--- a/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts
+++ b/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import { randomInt } from '@shared/core-utils'
export class MockJoinPeerTubeVersions {
diff --git a/shared/extra-utils/mock-servers/mock-object-storage.ts b/shared/extra-utils/mock-servers/mock-object-storage.ts
index 19ea7c87c0..f1c5a61238 100644
--- a/shared/extra-utils/mock-servers/mock-object-storage.ts
+++ b/shared/extra-utils/mock-servers/mock-object-storage.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
import got, { RequestError } from 'got'
import { Server } from 'http'
import { pipeline } from 'stream'
diff --git a/shared/extra-utils/mock-servers/mock-plugin-blocklist.ts b/shared/extra-utils/mock-servers/mock-plugin-blocklist.ts
index d18f8224ff..6f66bf4f0e 100644
--- a/shared/extra-utils/mock-servers/mock-plugin-blocklist.ts
+++ b/shared/extra-utils/mock-servers/mock-plugin-blocklist.ts
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express, { Request, Response } from 'express'
import { Server } from 'http'
import { randomInt } from '@shared/core-utils'
@@ -18,7 +18,7 @@ export class MockBlocklist {
return new Promise<number>(res => {
const app = express()
- app.get('/blocklist', (req: express.Request, res: express.Response) => {
+ app.get('/blocklist', (req: Request, res: Response) => {
return res.json(this.body)
})
diff --git a/shared/extra-utils/mock-servers/mock-proxy.ts b/shared/extra-utils/mock-servers/mock-proxy.ts
index 5365f87d12..eb5f177c71 100644
--- a/shared/extra-utils/mock-servers/mock-proxy.ts
+++ b/shared/extra-utils/mock-servers/mock-proxy.ts
@@ -1,6 +1,6 @@
import { createServer, Server } from 'http'
-import * as proxy from 'proxy'
+import proxy from 'proxy'
import { randomInt } from '@shared/core-utils'
class MockProxy {
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 5a2b09dccf..60a08b13c7 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import { decode } from 'querystring'
-import * as request from 'supertest'
+import request from 'supertest'
import { URL } from 'url'
import { HttpStatusCode } from '@shared/models'
import { buildAbsoluteFixturePath } from '../miscs/tests'
diff --git a/shared/extra-utils/videos/captions.ts b/shared/extra-utils/videos/captions.ts
index ff8a43366f..fc44cd2507 100644
--- a/shared/extra-utils/videos/captions.ts
+++ b/shared/extra-utils/videos/captions.ts
@@ -1,5 +1,5 @@
import { expect } from 'chai'
-import * as request from 'supertest'
+import request from 'supertest'
import { HttpStatusCode } from '@shared/models'
async function testCaptionFile (url: string, captionPath: string, containsString: string) {
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts
index 29f99ed6d0..d3665bc908 100644
--- a/shared/extra-utils/videos/live.ts
+++ b/shared/extra-utils/videos/live.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
-import * as ffmpeg from 'fluent-ffmpeg'
+import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
import { pathExists, readdir } from 'fs-extra'
import { join } from 'path'
import { buildAbsoluteFixturePath, wait } from '../miscs'
@@ -50,7 +50,7 @@ function sendRTMPStream (options: {
return command
}
-function waitFfmpegUntilError (command: ffmpeg.FfmpegCommand, successAfterMS = 10000) {
+function waitFfmpegUntilError (command: FfmpegCommand, successAfterMS = 10000) {
return new Promise<void>((res, rej) => {
command.on('error', err => {
return rej(err)
@@ -62,7 +62,7 @@ function waitFfmpegUntilError (command: ffmpeg.FfmpegCommand, successAfterMS = 1
})
}
-async function testFfmpegStreamError (command: ffmpeg.FfmpegCommand, shouldHaveError: boolean) {
+async function testFfmpegStreamError (command: FfmpegCommand, shouldHaveError: boolean) {
let error: Error
try {
@@ -77,7 +77,7 @@ async function testFfmpegStreamError (command: ffmpeg.FfmpegCommand, shouldHaveE
if (!shouldHaveError && error) throw error
}
-async function stopFfmpeg (command: ffmpeg.FfmpegCommand) {
+async function stopFfmpeg (command: FfmpegCommand) {
command.kill('SIGINT')
await wait(500)
diff --git a/tsconfig.json b/tsconfig.json
index 32e4a42e46..ada13dc987 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,6 +9,7 @@
"importHelpers": true,
"removeComments": true,
"strictBindCallApply": true,
+ "esModuleInterop": true,
"outDir": "./dist",
"lib": [
"dom",
diff --git a/yarn.lock b/yarn.lock
index 9d2a8f2bae..fc06540624 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1360,6 +1360,13 @@
dependencies:
"@types/node" "*"
+"@types/bencode@^2.0.0":
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/@types/bencode/-/bencode-2.0.0.tgz#75161d132f15a912aa49ea0c861c53ddb8539a76"
+ integrity sha512-ntDggX576d+MULpy9ApOy3OI9GqO86H+T9zEwYk3fdVaLi85M/1l+GVR/UWfITg9czcOO2SxZJyzyTOrI8UsFA==
+ dependencies:
+ "@types/node" "*"
+
"@types/bittorrent-protocol@*":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@types/bittorrent-protocol/-/bittorrent-protocol-3.1.1.tgz#76bfd5903d0f7c7b23289763f39aca9337b3b723"
@@ -1458,6 +1465,13 @@
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080"
integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==
+"@types/create-torrent@^5.0.0":
+ version "5.0.0"
+ resolved "https://registry.yarnpkg.com/@types/create-torrent/-/create-torrent-5.0.0.tgz#bd3def0e133390049113c09b0c263a6d6cca2852"
+ integrity sha512-mZbaThIOP3NQru6/oi7I3hcWSu8/d0/4os13JVWGAU5hoAZIUc6MbeloHAX5nnnIZgn7YIp5PpNRf9Im/QvAvA==
+ dependencies:
+ "@types/node" "*"
+
"@types/express-rate-limit@^5.0.0":
version "5.1.3"
resolved "https://registry.yarnpkg.com/@types/express-rate-limit/-/express-rate-limit-5.1.3.tgz#79f2ca40d90455a5798da6f8e06d8a3d35f4a1d6"