]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
esModuleInterop to true
authorChocobozzz <me@florianbigard.com>
Fri, 27 Aug 2021 12:32:44 +0000 (14:32 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 27 Aug 2021 13:12:22 +0000 (15:12 +0200)
208 files changed:
package.json
scripts/migrations/peertube-2.1.ts
scripts/print-transcode-command.ts
scripts/prune-storage.ts
scripts/regenerate-thumbnails.ts
server.ts
server/controllers/activitypub/client.ts
server/controllers/activitypub/inbox.ts
server/controllers/activitypub/index.ts
server/controllers/activitypub/outbox.ts
server/controllers/activitypub/utils.ts
server/controllers/api/abuse.ts
server/controllers/api/accounts.ts
server/controllers/api/bulk.ts
server/controllers/api/config.ts
server/controllers/api/custom-page.ts
server/controllers/api/index.ts
server/controllers/api/jobs.ts
server/controllers/api/oauth-clients.ts
server/controllers/api/overviews.ts
server/controllers/api/plugins.ts
server/controllers/api/search/index.ts
server/controllers/api/search/search-video-channels.ts
server/controllers/api/search/search-video-playlists.ts
server/controllers/api/search/search-videos.ts
server/controllers/api/server/contact.ts
server/controllers/api/server/debug.ts
server/controllers/api/server/follows.ts
server/controllers/api/server/index.ts
server/controllers/api/server/logs.ts
server/controllers/api/server/redundancy.ts
server/controllers/api/server/server-blocklist.ts
server/controllers/api/server/stats.ts
server/controllers/api/users/index.ts
server/controllers/api/users/me.ts
server/controllers/api/users/my-abuses.ts
server/controllers/api/users/my-blocklist.ts
server/controllers/api/users/my-history.ts
server/controllers/api/users/my-notifications.ts
server/controllers/api/users/my-subscriptions.ts
server/controllers/api/users/my-video-playlists.ts
server/controllers/api/users/token.ts
server/controllers/api/video-channel.ts
server/controllers/api/video-playlist.ts
server/controllers/api/videos/blacklist.ts
server/controllers/api/videos/captions.ts
server/controllers/api/videos/comment.ts
server/controllers/api/videos/import.ts
server/controllers/api/videos/index.ts
server/controllers/api/videos/live.ts
server/controllers/api/videos/ownership.ts
server/controllers/api/videos/rate.ts
server/controllers/api/videos/update.ts
server/controllers/api/videos/upload.ts
server/controllers/api/videos/watching.ts
server/controllers/bots.ts
server/controllers/client.ts
server/controllers/download.ts
server/controllers/feeds.ts
server/controllers/lazy-static.ts
server/controllers/live.ts
server/controllers/plugins.ts
server/controllers/services.ts
server/controllers/static.ts
server/controllers/tracker.ts
server/controllers/webfinger.ts
server/helpers/activitypub.ts
server/helpers/audit-logger.ts
server/helpers/captions-utils.ts
server/helpers/core-utils.ts
server/helpers/custom-jsonld-signature.ts
server/helpers/custom-validators/videos.ts
server/helpers/database-utils.ts
server/helpers/express-utils.ts
server/helpers/ffmpeg-utils.ts
server/helpers/ffprobe-utils.ts
server/helpers/image-utils.ts
server/helpers/logger.ts
server/helpers/peertube-crypto.ts
server/helpers/uuid.ts
server/helpers/webtorrent.ts
server/initializers/checker-after-init.ts
server/initializers/checker-before-init.ts
server/initializers/config.ts
server/initializers/installer.ts
server/initializers/migrator.ts
server/lib/activitypub/actors/webfinger.ts
server/lib/activitypub/crawl.ts
server/lib/activitypub/playlists/create-update.ts
server/lib/activitypub/share.ts
server/lib/activitypub/video-comments.ts
server/lib/activitypub/video-rates.ts
server/lib/activitypub/videos/shared/object-to-model-attributes.ts
server/lib/auth/oauth-model.ts
server/lib/auth/oauth.ts
server/lib/auth/tokens-cache.ts
server/lib/client-html.ts
server/lib/files-cache/abstract-video-static-file-cache.ts
server/lib/job-queue/handlers/activitypub-cleaner.ts
server/lib/job-queue/handlers/activitypub-follow.ts
server/lib/job-queue/handlers/activitypub-http-broadcast.ts
server/lib/job-queue/handlers/activitypub-http-fetcher.ts
server/lib/job-queue/handlers/activitypub-http-unicast.ts
server/lib/job-queue/handlers/activitypub-refresher.ts
server/lib/job-queue/handlers/actor-keys.ts
server/lib/job-queue/handlers/email.ts
server/lib/job-queue/handlers/move-to-object-storage.ts
server/lib/job-queue/handlers/video-file-import.ts
server/lib/job-queue/handlers/video-import.ts
server/lib/job-queue/handlers/video-live-ending.ts
server/lib/job-queue/handlers/video-redundancy.ts
server/lib/job-queue/handlers/video-transcoding.ts
server/lib/job-queue/job-queue.ts
server/lib/live/shared/muxing-session.ts
server/lib/local-actor.ts
server/lib/peertube-socket.ts
server/lib/plugins/hooks.ts
server/lib/plugins/plugin-helpers-builder.ts
server/lib/plugins/plugin-manager.ts
server/lib/plugins/register-helpers.ts
server/lib/redis.ts
server/lib/schedulers/abstract-scheduler.ts
server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
server/lib/search.ts
server/lib/signup.ts
server/lib/stat-manager.ts
server/middlewares/auth.ts
server/middlewares/cache/shared/api-cache.ts
server/middlewares/csp.ts
server/middlewares/doc.ts
server/middlewares/error.ts
server/middlewares/pagination.ts
server/middlewares/servers.ts
server/middlewares/sort.ts
server/middlewares/user-right.ts
server/middlewares/validators/abuse.ts
server/middlewares/validators/account.ts
server/middlewares/validators/activitypub/activity.ts
server/middlewares/validators/activitypub/pagination.ts
server/middlewares/validators/activitypub/signature.ts
server/middlewares/validators/actor-image.ts
server/middlewares/validators/blocklist.ts
server/middlewares/validators/bulk.ts
server/middlewares/validators/config.ts
server/middlewares/validators/feeds.ts
server/middlewares/validators/follows.ts
server/middlewares/validators/jobs.ts
server/middlewares/validators/logs.ts
server/middlewares/validators/oembed.ts
server/middlewares/validators/pagination.ts
server/middlewares/validators/plugins.ts
server/middlewares/validators/redundancy.ts
server/middlewares/validators/search.ts
server/middlewares/validators/server.ts
server/middlewares/validators/shared/utils.ts
server/middlewares/validators/shared/video-channels.ts
server/middlewares/validators/shared/video-comments.ts
server/middlewares/validators/shared/video-imports.ts
server/middlewares/validators/shared/video-ownerships.ts
server/middlewares/validators/shared/video-playlists.ts
server/middlewares/validators/themes.ts
server/middlewares/validators/user-history.ts
server/middlewares/validators/user-notifications.ts
server/middlewares/validators/user-subscriptions.ts
server/middlewares/validators/users.ts
server/middlewares/validators/videos/video-blacklist.ts
server/middlewares/validators/videos/video-captions.ts
server/middlewares/validators/videos/video-channels.ts
server/middlewares/validators/videos/video-comments.ts
server/middlewares/validators/videos/video-imports.ts
server/middlewares/validators/videos/video-live.ts
server/middlewares/validators/videos/video-ownership-changes.ts
server/middlewares/validators/videos/video-playlists.ts
server/middlewares/validators/videos/video-rates.ts
server/middlewares/validators/videos/video-shares.ts
server/middlewares/validators/videos/video-watch.ts
server/middlewares/validators/videos/videos.ts
server/middlewares/validators/webfinger.ts
server/models/application/application.ts
server/models/model-cache.ts
server/models/video/video-comment.ts
server/models/video/video-file.ts
server/models/video/video-streaming-playlist.ts
server/models/video/video-view.ts
server/models/video/video.ts
server/tests/api/redundancy/redundancy.ts
server/tests/api/server/no-client.ts
server/tests/api/server/tracker.ts
server/tests/api/videos/multiple-servers.ts
server/tests/feeds/feeds.ts
server/tools/peertube-auth.ts
server/tools/peertube-import-videos.ts
server/tools/peertube-plugins.ts
server/tools/peertube-redundancy.ts
server/types/plugins/register-server-auth.model.ts
shared/extra-utils/miscs/generate.ts
shared/extra-utils/miscs/webtorrent.ts
shared/extra-utils/mock-servers/mock-email.ts
shared/extra-utils/mock-servers/mock-instances-index.ts
shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts
shared/extra-utils/mock-servers/mock-object-storage.ts
shared/extra-utils/mock-servers/mock-plugin-blocklist.ts
shared/extra-utils/mock-servers/mock-proxy.ts
shared/extra-utils/requests/requests.ts
shared/extra-utils/videos/captions.ts
shared/extra-utils/videos/live.ts
tsconfig.json
yarn.lock

index f627a9a349d1415b210b1ecee75aac3463484890..b217e67cabefa1feee815ebd4bbe1be7a912c313 100644 (file)
     "@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",
     "@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",
index e17e5816630cdf6b356c2791b1b20b9b2a9c6c9c..4bbc203c18afd1e93eb58853e68711d65286ed70 100644 (file)
@@ -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()
index d833632150da06969537e41c1fec15fbd7a66a0a..352145252ce4fc7369f30c8a31f101fd914a7e3f 100644 (file)
@@ -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'
index 5b029d215a703de61bfad4fe6cee4d9894394692..00141fec1a47add675581e8ebb6abe56a7d3bf28 100755 (executable)
@@ -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)
index 078f3830bf442517c3d5565afceccd012d6f85ba..8075f90bab9f4bd01681e560dc28eaf1dbf2864f 100644 (file)
@@ -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 })
index bfc7ee1450867bfdddf45d54f18ade4ff5f92fd8..9af83cde9ffa9973a447efcd5885d48c3fbbd009 100644 (file)
--- 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')
index bef4bc068cfe85e2b2f20a6c853549ec08b4ca76..c4e3cec6b4833da1a0effda48acee07f89cb008b 100644 (file)
@@ -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'
index 30662990a0e628e9025de95ff4e59eb95fffd374..ece4edff0c00e5961b5d05b7c8d4f7ee491f5550 100644 (file)
@@ -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'
index 7e81902af7249147eeb2c8a3a4166bbca497b33a..8c681820adc7fbf0bdea7bf3a7d872d1fe0bc77f 100644 (file)
@@ -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'
index 22328da7f3207e415fabe4c0504b27cc91dcc156..bdf9d138bfd6f035e88bd50eea5ef2a5e485cbb2 100644 (file)
@@ -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'
index 19bdd58eb22d692fb774c5adad2a5dbfa5570530..f851ef652d0c2d2a251e58f6cbf9bd4a44a3f396 100644 (file)
@@ -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')
index e851365e928924e7ed739fc5824ce3529f739db0..72c418e749e871d112dc7c2b324b796e2271d8ad 100644 (file)
@@ -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'
index 55e2aaf62d6615edeb179fc02e4d3689a6e16016..75679b0f44a0bbc1b0f0f067cdb148570578584a 100644 (file)
@@ -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'
index 62121ece5a2021e5fa273f99656ac0efedb4a040..d27c3c73e64a435723d1abd96294bab6f70bbf36 100644 (file)
@@ -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'
index ee733a38c87fc139b1a4dea92aaae64427177756..d542f62aa34a992520ae7dc627040b7c1f6e5ae7 100644 (file)
@@ -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'
index 68d8c2ea49b127035c439801080849e5a123c02f..d1c672f3fc0a62f6a637caeaafe5dfbc0717dd82 100644 (file)
@@ -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'
index 93b14dadbacf3c3a244e3531f63818e0d2a65678..9949b378a041454b5887d89afe089b921b7120ef 100644 (file)
@@ -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'
index 9e333322b2a479a9c4ffd632c23d35fa0462b09f..7001674bb06ce10ea22ab7f9c94e95769418dd53 100644 (file)
@@ -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'
index f95f06864dbef3cb857e71a8ebc6b7818dd1bf4c..4990fb0df2f6767e0568e4669e951841b3a162ef 100644 (file)
@@ -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'
index 2dfac15ef3019497ebf6f5c706db478efbe309fc..5b16232e2a0399c35545c3a47f029dc5b300158b 100644 (file)
@@ -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'
index 3a9ef34e8a464cce0ccb85b6b172ab14435d2df6..2de7fe41f48e826cea5e9a8d729021a45faee500 100644 (file)
@@ -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'
index 67adbb30794efd7cb7c3e3c49d4cf11118012b1c..39efc0b10c0686f58f6bb55b684f30b3bfb5f331 100644 (file)
@@ -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'
index eef22250636aaabf7ecc48c4a1d29d15f62c5851..25173ac20b79683e656db3ca03d00fb347cfe6ce 100644 (file)
@@ -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'
index 0a56f19b7c394f567ecbd9b59d5118c7bfb07fac..b28f11c792a694288ac307b03f6b991284068c6e 100644 (file)
@@ -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'
index 4a6ce0de4e6886f87929686bf44888aa98f16b86..eb7ce08414c578b6364bdec184ad565d573c8a6e 100644 (file)
@@ -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'
index b315e99cf244aa6d69cac891b6b9cc440a6550bc..09ff50f694e41260d83b08145ddfb22c615be03f 100644 (file)
@@ -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'
index 0601b89ceb042c2e163223e34959adcc204216ad..093e6a03c9f7327aa48661e4b9b249451586039f 100644 (file)
@@ -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'
index cbe6b7e4f5c5a75237d66ca8b1eeeb51454b9c6f..2e0fd25ebb2d4dbf0fae0ced9a5c765fbccbeae8 100644 (file)
@@ -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'
index 32fefefc04c90893dc42516872edcba87d22d918..b20718d0966443250fc619bb8ab0e7d8b1fea9b9 100644 (file)
@@ -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'
index 39eceb6547d7c4902de199c3f568ddc380672690..dfd5491aa599470eb454ac54a4913a259298b254 100644 (file)
@@ -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'
index e36c8d2db44fbfa748f36833e863709a715ab946..9f43d3e4e9901ed01648a1f8e9dccc6130a0ea3f 100644 (file)
@@ -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'
index b3ee50d855947e805d928d950c972f692a37baf2..740f95da3dc1f113de7d3be3455d537a1f454e72 100644 (file)
@@ -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'
index 397702548b0e54ff992acf08a75cc972643fd185..d661144ca6bed9f2ea2ff04bf110efec7d61c987 100644 (file)
@@ -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'
index be800e8b5d5e0a9589883ad70de9a323df1fa3cd..bc47e5fec6bef5b1df55a5868c7cfc277be9a327 100644 (file)
@@ -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'
index a98d792188d1b79b35dfac316f7517a66dc175aa..83b774d3c879717438dcb25cf55559c0265767a4 100644 (file)
@@ -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'
index fcd0ce3fce166d8365081975e26e47ade3fbefd1..103c3d33266f60fd99627e4d63736e783d6b9745 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import { AbuseModel } from '@server/models/abuse/abuse'
 import {
   abuseListForUserValidator,
index 24fff83e332a38eb989e2b5788d605a70d8efea7..0b56645cf3f741f14448323c00f665a5524dd259 100644 (file)
@@ -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'
index a6e7231030e2d3d480235c4a3c00ed5d1ce5643f..2fcb25acf5d3540bf9696f61ed9ee842da500ba5 100644 (file)
@@ -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'
index 3beee07c021634d3c773098b52a7450e9ca71ef6..d107a306e11db1963ae9d4e924dc925d68b7951c 100644 (file)
@@ -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'
index 26a715704b66a882315d27ad6c3aa8d5a7259c87..e3c0cf089a26b6eb1c23ba5c662734e4ed52fcb0 100644 (file)
@@ -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'
index 76e741ba548e53a64197f163311e870fdb6f5e83..f55ea2ec445cb449fe41a956cdef78ac539c57d2 100644 (file)
@@ -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'
index b405ddbf41f586e4a1a47d6b861a2768ffb243cd..d5dbe921c727fe5b116889cc04902c9a8b7c80fd 100644 (file)
@@ -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'
index a0c6601d94f920c5d5f9360fa34eb0819f9edcd1..b79dc5933ea3dad6578685d06beaf7afeeb10169 100644 (file)
@@ -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'
index 4971d0a772eb9701a94054f447fe04bc3e401a12..2f81cf43c1d59bd013ad59f1ca94bc5c3ddf1cde 100644 (file)
@@ -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'
index 6bc768471cb7e7bda84540136d4cb0267f299cbb..de65c74f1073d7db1d47ff6a9918c692789a4581 100644 (file)
@@ -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'
index 4008de60fc59c2a12ddf175383e63cdd218a26ab..2d2213327ce1e47e13d259cc098dcace67dfe093 100644 (file)
@@ -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'
index cb696f652cc669b84d9a49798935ac6ceae00b6b..23bba90891265ef4b41bf87f3330de0d4e98b52c 100644 (file)
@@ -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'
index de9a5308a1e50a426002fe224f3e5bae8e77c3ca..39fc577885459313ca6e2ba4d01e258d2a9b4d65 100644 (file)
@@ -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),
index 10833d48bfdbe7fc524fbb07ef17447dfc35c519..c0c77f3f74d0d068863038f2cc77ac5281707a77 100644 (file)
@@ -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'
index 151ff354b7b3f6e5cc6292131e6bc565934ec797..efafe64e9af7d6c15611d8ad3b8c56fca2497a4b 100644 (file)
@@ -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'
index f48acbc681843190eb2b39051b4736218fbc2d28..043861ac3cea13ddf0add36a360bb288db064561 100644 (file)
@@ -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'
index 96f6cd886bf7726f6f3346344df2624329573976..c9cc16644e131658a8f8dcfe1fccc7d93806ae4f 100644 (file)
@@ -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'
index 49639060bdd3f1d4559550f43fe468e439d0fa37..a98a3e67c15e2e74fc3ec1396f86805cd17c7fdc 100644 (file)
@@ -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'
index 5c740c0410eedaf39839acf20312e3af5bb40213..7ffda749d571602042b16181cb869d9254e987e4 100644 (file)
@@ -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'
index 05c75e543c9d87dff05a2e0c5bd254755748a671..e8c28b6138fcfd84f443922d44918fc5ec5e0560 100644 (file)
@@ -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 {
index de04116086ee2fb6257713f3360ffacf5cec0e9e..63db345bfe0ce0c866fa0d07a7bf366e6a6aa7c4 100644 (file)
@@ -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'
index ba3c54440a43d20d93aedee0c52afd94e477fdd0..d81e35ec3d43c5d77718aa13624a6bef48a5d1db 100644 (file)
@@ -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'
index ffe40d57e3ce699f40978f67874c2d813ed1d8ba..8da710669c6400ee791b2bf1fb5b86d5343ae3ea 100644 (file)
@@ -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'
index 9fa70a7c8ca89e7f9cc9983f422252a909801517..5ac2e43a1c65794e84767baabbdcb52544491540 100644 (file)
@@ -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'
index 632e4dcd8d6f5b7f5d72368541e6cb6e6f3b014c..a4076ee56b3e54d2a806880b3be455ca87a131bd 100644 (file)
@@ -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'
index 95d5c01357984eafdb51603ed0cc9d583e118d01..81008f120d213cdb5b9975b9c3958d0e4e2a2ea4 100644 (file)
@@ -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'
index 11ab3f10ab47ee7b39c85aef2c034d08078414f9..28fffc9e1dfcee68e0d886e3b655fdf69583b236 100644 (file)
@@ -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'
index 8c0af9ff7546c6c58f60a22e06b93ffdff36830d..8a8a95486071b0b12ef5397e6ac8225da8b70d82 100644 (file)
@@ -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'
index 912d7e36c8265b804e1d928ea83187ee33fb1891..1c04e4b11ebfaf1ce08a744d80e5afb791fbea1c 100644 (file)
@@ -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'
index 37f8f12c98150ea4c63250ae7d39daf7660e9043..da9c68c6cf1438fee044b6c6a438edf9b05ff2d1 100644 (file)
@@ -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) {
index 885e4498f069c02df78f0114235b0339487d3fd3..29ce011660eba651f07efb9158c51c8705cc388a 100644 (file)
@@ -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'
index e0754b501b2ce39729997c298942c20a81f9fb89..8b56d2d5099bd78070821ab150210c1b3a49b57f 100644 (file)
@@ -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'
index 884bd187d3ae6135b3811ab91c5a7726a625eb94..5f2e870e38ff001c09d9b3e0c47e82ba5b44caec 100644 (file)
@@ -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()
   }
 }
index ca03f7a4903cd0b6efb6053110d680d6c4bbc1f0..f6e5b9784b0876bc2f4e93953722ad8dd6e09cb3 100644 (file)
@@ -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
index 9abc532d28741f94c9dec872de8734a32b0f1f41..7f28cfc8b1306151b7f551459428d64b34637a0d 100644 (file)
@@ -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)
index 56f10086c605439432988db8780c796f903f17a5..3c706e372ee26a9b17f4ed3457fb1cf74c44e106 100644 (file)
@@ -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': {
index b33e088ebe25cdf4208f543e88c835de57d3bd16..c3604fbad0dd2138622aba15e988aa01c0cca52d 100644 (file)
@@ -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 {
index ec35295df2fd0f470ffd50ce720ad310e6fc085b..aedcc5e6409d89861462352f8dfc92f151d3ef95 100644 (file)
@@ -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'
index c299b70f139ef590432574fe57e524c1c55715e9..38fe6926baed2708b4cd2192a794893a28028131 100644 (file)
@@ -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])
     },
index a99c9ee7c70809a35c5e87b26356f4fc9ba191ba..54fd031b75ae48bdb71038c869f66509738ed5d6 100644 (file)
@@ -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
 }) {
index e58444b07296dd16453abfbc7ad27cd12bec488a..8381dee84facea27f4b9bbd18173e97fd745f452 100644 (file)
@@ -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
index c76ed545bb2b2bdba91fe33183cd6d2567cfda4b..033be2c50970df39a70463720682cd3604da063b 100644 (file)
@@ -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)
index 20c3c3edbaa111bb5ef304a98ae7781fb5648ebd..4bd00e50345abb597bb94d778d14711071e0ea29 100644 (file)
@@ -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
         )
       })
index bc6f1d0748cb0a78615ef396cbd9f95460593426..66060bde294d39137a69da2116171a5bca386bba 100644 (file)
@@ -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)
 }
index 3eb06c773bae1afa77bc3dfaebeaf6e68fa2b475..f3c80e046fae15ee46b3a86cda0717f49c8a2232 100644 (file)
@@ -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) {
index 813ebc2361f77965c129df369acfc8b318e868d1..83b46e08544f6250cabf255f098075f925fc866b 100644 (file)
@@ -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
index 09f58727498d0df6bb46a9c3052f0d349fcc00f8..c0a6c41ab3508e0fed97599221de1052bcd49297 100644 (file)
@@ -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(
index 93c01912146f9bab240a126c57d47466dee9891d..16dc137c0e68436d0d58d5e8fedd2d2da60d7571 100644 (file)
@@ -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
index 0e684eef862dc1b0dfd4521d566ed2ff14f8feaa..be9fc61f083a43be735410f93eab0a01c33ef992 100644 (file)
@@ -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'
index 676f88653359e700784bf15ae208b34799561819..75daeb5d89e55792c5a2e236caef15e64737db0d 100644 (file)
@@ -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 {
index 77203ae24139ac9f40cceb7a86f1927af545687f..7d7c9f8cba91dadee1ee977d574a8e0c48f82d0f 100644 (file)
@@ -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 = {
index 1c7ec47174e421d8184f2a15f1ef926ff96fc006..5532f05bd8ba3d6392669a46cfa41f408ba71b88 100644 (file)
@@ -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'
index 28ff5225a01bde45b7ddf7b0e5086487bc713386..336129b822013a0e3e01786069d6923005d1de27 100644 (file)
@@ -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
index ea3e61ac5de98ce04a750a248740b322186fcd12..b152d709c3f386543b578845fda1efc40c06eed0 100644 (file)
@@ -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)
 
index 1ff01a1751a88602dad85c0ecc650bfb75a7968a..b18761174ffdc02a2044c7747be8971c8cab0f07 100644 (file)
@@ -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) {
index 6b7f9504fde70c3a77d6abe614c23edb07953f03..2a14790fe6d1707691505b066705532b4101b793 100644 (file)
@@ -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) {
index 9fb97ef843ae6ffe3a8a736aa77fdc7ad3e5bef1..04aa5eae940add78127ffebc1c60af780d4f30ae 100644 (file)
@@ -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) {
index bd9ed45a9d78b09162e7be517d90e5d1c2f9e36d..62354ab5660cff99532791ffe353b8487440236f 100644 (file)
@@ -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'
index ae728d080bedaa56edb37e13b12ef76e4d2dfbe6..f2ef0a78af67265dc2e2ce187d2d57e9494eccd7 100644 (file)
@@ -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'
index a97681c86b76e30bea5af1b668ae838754015d31..497773536e126857f9e7b55406a711b1123f395e 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import {
   InvalidClientError,
   InvalidGrantError,
index b027ce69a473bfe0508655411dd9f5ad8ff57575..410708a352e325bff62db53beca2689548384867 100644 (file)
@@ -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'
 
index e093d35f733540a4cd2d1e13e53bf62415e7e4e8..3b0a68f4d6443bf4daa240a535d20cb02b6a4541 100644 (file)
@@ -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'
index af66689a0c34d627166fa4d99447be1d0cf79dbd..a7ac88525c80be00d6d7616e7607f8f195b914f6 100644 (file)
@@ -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
 
index 56e2b0cebce3270933f948092fb82cf4015453ae..d5e4508fea24a2a8e4c01c9dd54336f082e02b2e 100644 (file)
@@ -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) {
index f896d7af4c04e70e3c21aabe976e78f9feacbc6a..91e3d33c607f323f7acecd8ecf2ea3c1cd80ceb1 100644 (file)
@@ -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
 
index d4b328635a528a50d96bbba143d6da5db50360eb..9b0bb6574aba65366ffc3d46efb2f573e6376e66 100644 (file)
@@ -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))
index ab9675cae7c2bd70cbb828f1f4c7fbc8177ba4c3..46016a0a7ff05d5dc10b9b3480a29343e38fba42 100644 (file)
@@ -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
index 9e561c6b757b1b7c4f0564d30691f175df188fa5..9be50837f28246919f8e86696c696d8b49bddad7 100644 (file)
@@ -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
index d97e50ebc4b3acf3a7c9638dab2aa02d168d8181..5037992d2271f5091789942c06eaec8520fe2e4b 100644 (file)
@@ -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)
index 60ac61afd2d76e3e44790b8255b1e6d9e7375aba..9d5a65376a3982e72c1b7bd12b43db726d089381 100644 (file)
@@ -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)
 
index 3157731e2ea5e5afe4474f301b45c5e597c96059..6fc1caa84bf1a2e64f215458993f178e30e7f44d 100644 (file)
@@ -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)
 
index f3b8726eb19d6535d3f14a82438f4fe6955de75a..0bebc0fc2473e3dcdf16f1b5899670db747093c3 100644 (file)
@@ -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)
 
index e8ee1f7596a3821e9e8ab0eda193f710c9058fdc..e6c918e6cb6d01722e760799219983448c8c9507 100644 (file)
@@ -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)
 
index a5fa204f55adb4e81c7e0c0a24cc4d52f5f9a84a..bdbf07a067977023d32cb2174baea56cfed9126e 100644 (file)
@@ -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)
index 9ccf724c2dceba95a6c385a437c7e1175d8386b5..a04cfa2c906a10e0ddb934d0def181eb02e1f232 100644 (file)
@@ -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 () {
index 6296dab052beb04ce321c16cc967a45ced986a3b..9cb7a65891b07be7f583ba3a34e6ac56ae3f1dfb 100644 (file)
@@ -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)
 
index 5a93c4ed1aeaa0347c105953710d0bc8770e1f8f..20880cdc1a39209f395f163cd9cc91982c2adb15 100644 (file)
@@ -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)
index 7a3a1bf8226becb155d99ae2e2df26ab29a45cd5..4cda12b5754c5ca411384656eaaf2f4edafc192b 100644 (file)
@@ -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)
 
index 0c9fb0cb633a86b6c986b4e659cb11392926179a..a6907142d25ea74d71dbd102029bc62bcbfe7017 100644 (file)
@@ -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)
 
index 77667f6b0bfb51f2428b0e2dd20ad760f9f2d342..821a92b9123c13467846bd28b9a0dd31a8ee6245 100644 (file)
@@ -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'
index 0740e378e6f1d635b75d624d6e458420d75a2c83..901435dea792277d2aa02f9461e0d86ee87fc6b3 100644 (file)
@@ -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)
index 5e97b52a01f6f393984897bfae003fa8cbbae6da..327aaece2d6f762c4cba1431daa39aa8ae05c390 100644 (file)
@@ -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'
index 8487672bacd0ade440164b504585dc059d87acb3..e26776f450e37648dd0265fa20f5bb7f2004f0f3 100644 (file)
@@ -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'
index 6599bcccaf28f95f70eb936a88a66a7c4e8e2bb4..d4d2a7edc31cf9f4610912a5089295c7eb7e929c 100644 (file)
@@ -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'
index af533effd8100700098235afd48c5f11304d9dbd..acca9309a717fbccd1afac6712ccd36d2444ef3b 100644 (file)
@@ -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'
index 62641e313af34f63a72da710e815b4bedbc0c771..d1d88d853d22e4dcd4f5a6203effffc76aed6e5e 100644 (file)
@@ -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'
index 0e6088911752df4a91f8db5e0f531e3af3dd0e15..f3d51a22e09f9df869dee6990a18e4f65f4981cd 100644 (file)
@@ -1,5 +1,5 @@
+import Bluebird from 'bluebird'
 import { logger } from '../../helpers/logger'
-import * as Bluebird from 'bluebird'
 
 export abstract class AbstractScheduler {
 
index 1acea79985ede840f0227f110c2e87f7604caddb..099fa56513e308554bc32e7445dc53c5e2ea4099 100644 (file)
@@ -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) {
index b643a4055e7227d0a72cdb65d395d20ad6b62a9d..2f4c5eed9b004b8a548e8fbed3ca6333b990fa2e 100644 (file)
@@ -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'
index 8fa81e601d7a712e314dd036a2151648ee8f8353..3c1397a1287681c90458ee20041905eee0402f8e 100644 (file)
@@ -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)
index 3c5e0a93e0046d3940c26b7c5b83672541d00348..03063793d8121695bb5864755086545d80021341 100644 (file)
@@ -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 }))
     })
index 9e6327b2379ed2c018803fc7567e91380dca8694..c5424be979b1703b7ba479a63c9925fa424c7871 100644 (file)
@@ -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'
index f9f7b1b673406c2c0f0d83b90a46091bb4199fd5..f8846dcfcd3d766c964b857e2895ee752e1dfba7 100644 (file)
@@ -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'
index 0ee44bf4782a1c446d82584e37592420e00de2cf..e2a75a17ebae7427e70bf6da5ca2e9782bfdd48b 100644 (file)
@@ -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
 })
index 3db85c68d9f27fd07f9d94d7cda13579fb525936..eef76acaa03e4363bcfd125daef7a75d75264995 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 
 function openapiOperationDoc (options: {
   url?: string
index af5a9c29a00e58ff887d879837d4959374ebf4df..6c52ce7bd98f7fa98e7d551e07249991d6248002 100644 (file)
@@ -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'
 
index b59717d7bc46edf541f7418549df124201d842bd..9812af9e48101b72b9a9c678c5237bb665da9d4e 100644 (file)
@@ -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) {
index cf70d901e305dadb0cc5575031df78dcb10e1eed..ebfa03e6ca02ccc0747d93d4dfe0988140299be9 100644 (file)
@@ -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'
 
index 0600ccd15567fd74f37f8fb0049330fafcbdd2bf..4588958988af88a759c35ebfbc7a6afb58ed0643 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import { SortType } from '../models/utils'
 
 const setDefaultSort = setDefaultSortFactory('-createdAt')
index c8c694f055ebac9e9a15e7694333022855a46f7e..ea95b16c2d8550f9cb6fc30636bb3b9b2d94af4e 100644 (file)
@@ -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'
index f4d9c3af201cb91dd959d0bebd80d748de31dd30..22f66c8cff0d0ab69eaf822c98cf6aff3b867a00 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import { body, param, query } from 'express-validator'
 import {
   areAbusePredefinedReasonsValid,
index 599eb10bb287cb4db53c29c9c547b87dd3a8dadd..e529c831d541ea575e80209a8d6f3d623848dc00 100644 (file)
@@ -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'
index d24e4427b79cf5191ca4dd364fc72c004ed7e06a..e296b8be74995f8ba9a82b4d0f952a9bd7d03d99 100644 (file)
@@ -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'
index c8ec34eb6addcfa0c0b829c3a414692c06aef1cb..c542d41731f372adcad0552c40a054bf4939a4ab 100644 (file)
@@ -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'
index f2f7d58487882f84a287581c8ccf39342e1332c7..642bcefe0dc1c17f9bb9dbee542baf600a0f8967 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import { body } from 'express-validator'
 import {
   isSignatureCreatorValid,
index 49daadd61950a95dfca00a3b2c04765da91305a7..c7e9f391c84f8f013f10a23b267edcef8c1e0a05 100644 (file)
@@ -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'
index f15b293e95f1b4a0ee73291103acca40b0ee005b..b7749e204c8bac8bc6ba164a78876ddcc04bb36f 100644 (file)
@@ -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'
index 6fec5814930e6a3ab5ee3bde1b9b025de1ba4e44..1cfc7481eeeb938d754e964c415a806272e46f2d 100644 (file)
@@ -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'
index 1aeadbe65f9da8ed945f14708ede957dc3653249..16a840667dc6cfd6987bc85aaf735d9d61f30625 100644 (file)
@@ -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'
index d29bebf6474737d2410b4a650a3c536beab40d98..f8ebaf6ed87d65cb360fe6465c56b625d3acd0ca 100644 (file)
@@ -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'
index 16abdd096c948a44777de807988134c41543726a..df4cefe2815fb96d59952b562bf1694fd66c607c 100644 (file)
@@ -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'
index 5d89d167f66a38351d20beadf3e533dbe8643ab3..4de90548b067e9ab3378fb4dd26260e88e326599 100644 (file)
@@ -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'
index c55baaee385f69bd62c6652f4286c7ab4ca3dbe3..03c1c4df15bb2ca255864f00cc241ed58f169d88 100644 (file)
@@ -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'
index e5fc0c277dc498c3f60944b382532de18711d3c9..5e47211b57864a19fea865dc898df2468a7e3dfd 100644 (file)
@@ -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'
index 74eae251e04790dbbd53a60b02e7446106995f12..8e4922b9d4fadac10b7747e241793d580219b3e9 100644 (file)
@@ -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'
index 3fb2176b9d6832f212d8bcf63e2eade58ac593eb..21171af236e36cc2152a83b51f76cd7ec8c9f0d0 100644 (file)
@@ -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'
index f1b2ff5cd92831409332ee671927dd27da6fe2ad..d31b216f59a2d209b1408ee9b7eaee7b7ebb8df9 100644 (file)
@@ -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'
index 27d0e541d61dd7bbc9a4848915e3c5dcbce614ae..e6ec8642ada15f3e262c4e49fc12dfba4dc6ce78 100644 (file)
@@ -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'
index 29fdc13d28cc5a49a541308426e6f72e2b92f166..10bbefe38866ee95d16be212f8f12197b23a83fe 100644 (file)
@@ -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'
index 4f08560af5f79ef37c3626f8de09a5f9fad2c014..5c66ad500f39854acafb64df2e151c736daab5bb 100644 (file)
@@ -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'
index 3fc3d012a6e490e692d1dcea42205d2d7f84ba5c..7c0c89267b074396a7a892f7818a148e07d57d57 100644 (file)
@@ -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'
index 60132fb6e0bc45869452a6376f5efc1ec11d60b1..386ae911f25e31ac4f5ebd7906e91b4e7b56dcd6 100644 (file)
@@ -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'
index 50b49ffcb61b2449fa15759d8c636594fc2d8978..69fda4b324a468d320cb0270f916d203a487a893 100644 (file)
@@ -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'
 
index 93a23ef40ee6f0985502eff43c2dd35c6e3c657d..680613cda4aff766227a0249d51195f74510c50d 100644 (file)
@@ -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'
 
index 3f67681797be98f47dac099e8e5081453761a2e9..4342fe55279b923206d2ed73ce672911baa4c971 100644 (file)
@@ -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'
index 2953b9505bbc3930b902ca461ca555bcbfe4a362..7b9fee85884c69615c38e3594867b74bef83b579 100644 (file)
@@ -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'
index 1db0d9b264d12b8663b098b5afa2e96aaea8a4d5..f9be26627848806e8046bb30c1679cee76a4832f 100644 (file)
@@ -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'
index 2f8e7686efa85154a106d7eaaa902bf764385bf6..4a7577d32ec6ad5bd25a103b22b3112be26fa779 100644 (file)
@@ -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'
index df57777714b4c75e1703091606fef1dd366ac2f0..48ce90d7b0f7f30a82f76034e214b958ebf644a3 100644 (file)
@@ -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'
index c6977fcd9d0ef99792e5c80683696fc399433d55..c06b85862d0160eca603e893bcbdd6d6ce5a62f2 100644 (file)
@@ -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'
index 3a4937b7b610a37cb0f2b6566dc2c44659f41d5c..de11e69f2a867414f9a552fe1e0f8d65b649fe2c 100644 (file)
@@ -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'
index 6bc127e01af8c72822599c4be4f21cc129863138..38321ccf9a5323b2813ce2a1aebed3ad9370dbf1 100644 (file)
@@ -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'
index 3b5693d231093ab3231701f13887e69aeaa8402d..fc717abf64dfcd9d0745812513c9bc6724ed31a3 100644 (file)
@@ -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'
index 61c2ed92f857946e7c1f147596c37867e98357ae..3ea8bdcbbebb75566b9a472ee188413c29a7be51 100644 (file)
@@ -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'
index 52b839e5692c4a265e688c8494438c53c38db28f..640139c73981894af25c6aa86ad9b4c7b9b90739 100644 (file)
@@ -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'
index 97e8b4510a8993eec8026efa57d8c6d6231fb3a0..6c7601e052882ab325ed8a51c8bba0d6af7ddd0e 100644 (file)
@@ -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'
index a7f0b72c38932e2652e6914a2979e62f1b7d45bd..95e4cebced7506266f52b72205a7e70cf2bbff13 100644 (file)
@@ -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'
index ab84b4814aa010b450df9a6d6d6fcda446a8203f..8f5c75fd5b698c138aa0a2cecca0789ca300dbfd 100644 (file)
@@ -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'
index 5fe78b39e86caf2bf6d1c6d8fdca0bc825bc3c24..6e0bb0ad1e4e0ba98f0a8c48dd0aa09edcb6621d 100644 (file)
@@ -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'
index 3b8d6176801dbb4497fb3f38c19b5699297f9793..0f04032bb38ac79778619cc79d060370e09da04c 100644 (file)
@@ -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'
index 431515eb15a90303969f93049baa9e902ab6b36d..d83710a647647e071c67c0c118fd501d77281ac6 100644 (file)
@@ -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'
index 13187f3985a854347f61f45374719f344efafa43..23ee9778af71084fa8baa3a5bb6a8166d9a4c777 100644 (file)
@@ -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'
index 1313608203b811f892aed39cb71f82f10d3136cb..8893a0c7e89d7ec1b68a464c1ba3cacfe8d0001d 100644 (file)
@@ -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'
index 5531d134a1b6f67c14b6b9bc2b8483cccb2eb90d..e3939383be804d9d346d6f709390e5d1b6fb11e2 100644 (file)
@@ -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'
index eafb5c13ce5e82521bade4749aaea9d1c8560db5..3651267e7c5c10028c0dcb62eec8505ed9f27aa5 100644 (file)
@@ -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 => {
index e933989aec73df76dadcbe5852cd8d3a73a4ff99..c89279c65e443b5e9e11c7a62d566ecb9dbb7496 100644 (file)
@@ -585,7 +585,7 @@ export class VideoCommentModel extends Model<Partial<AttributesOnly<VideoComment
 
     if (accountId) {
       whereAnd.push({
-        [Op.eq]: accountId
+        accountId
       })
     }
 
index 627c957635bb5079ead16cbec64cc12bed6303f3..5e8d29d0a9b5a3e7039aba94d499f8bc087830b1 100644 (file)
@@ -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 {
index 3e9fd97c72ed401a96280634b6f7bde813baed37..18d96c7507728f7f881ff07398fe66a728df7370 100644 (file)
@@ -1,4 +1,4 @@
-import * as memoizee from 'memoizee'
+import memoizee from 'memoizee'
 import { join } from 'path'
 import { Op } from 'sequelize'
 import {
index dfc6296ce2618f1bbb64cbab15e0beb5b34a8645..b51f0f84d103b7c648ed2cd1fed9667f74650ae8 100644 (file)
@@ -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)')
         }
       }
     }
index 874ad168a1325418154a973b1035ebb527829f82..e0c4dd2dbea860c2a03f3fbc325ab0077b891142 100644 (file)
@@ -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'
index fe42e5fa874f4f91f1e5986659a562760042c23e..86b40cfe603726476424b7e96b429064cfbe7970 100644 (file)
@@ -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,
index 719813ae904a602115b221903a8fc0a32f00f812..1e0c95a3b12da4073dff662739527a7050d12ff5 100644 (file)
@@ -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'
 
index f597ac60ce84504a4857976d78759a033340e050..30a9618b3024a31c3586fe9232fb4c57ba5105a4 100644 (file)
@@ -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 () {
index f9220e4b34a780e2470ed09904fc20414075eda7..df9deb1e106bc6dcd3dd784dee1d4e8844a67897 100644 (file)
@@ -2,7 +2,7 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import * as request from 'supertest'
+import request from 'supertest'
 import {
   buildAbsoluteFixturePath,
   checkTmpIsEmpty,
index 55b4348465516294ce48e73bde82ff35c6d88233..a1c976fd30d013ed3d3f0c5ef66c354efd6121cb 100644 (file)
@@ -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
index b9f4ef4f8ef181a2b7486e24ec294df461a1b21a..afa19ee085753b8eae0db246aaef1d0d46e8b897 100644 (file)
@@ -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() ])
index 488109b7a7ffec1de0491c88b6a3e5dbcc788663..758b561e1b959c4b3745fae55026c971fde5b942 100644 (file)
@@ -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
 }
index d9c285115cdab926086e048dd0b1d308fa62fa0b..ae625114d2012d7597deed308f7610e0e63d9746 100644 (file)
@@ -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')
index 73b026ac8f40e6f941733330fd5ccfe3eeb69aa3..7e27ca49e62418896fab143f48e81b26b7215bf3 100644 (file)
@@ -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'
index 3e1a5aeba1ba0c736033eaad8357607f608f4dcf..79c18c406c93c4c69629689bba9d0010cbf37ca1 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import { UserRole } from '@shared/models'
 import { MOAuthToken, MUser } from '../models'
 
index a03a200495de3eec259c91539f0fe6634eda84f8..3b29c0ad49f1b75f62a293fb51d1b53f9489535a 100644 (file)
@@ -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'
index a1097effe7396dea1ad12dfa5b1aaeaec962b23f..8fe2ad82160785ca2571820de860a971b053f3cc 100644 (file)
@@ -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'
index ffd62e3253a35c2093fc742d50ce05887332d404..c13d3dc0f42c37a11f37d8ed17b85532157fb170 100644 (file)
@@ -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
index c9e33087de4ce693500617d5cde6604634b5a106..2aabef9d26c7813cf9947de566025bad548eb882 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import { randomInt } from '@shared/core-utils'
 
 export class MockInstancesIndex {
index 5ea432ecfc8a7bc59b0de6c7b26b954a7cada583..5106fc66a267b8837475a1fa91cf6aade5f8081d 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import { randomInt } from '@shared/core-utils'
 
 export class MockJoinPeerTubeVersions {
index 19ea7c87c03a80fb8a66d5219b939cd35d92951a..f1c5a612388136a4fdce3f06028a7b1bb2d703ef 100644 (file)
@@ -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'
index d18f8224ff6382a9ce113e350ebf59b141a53eff..6f66bf4f0e4b363325d95c7c24e933ed2e78f428 100644 (file)
@@ -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)
       })
 
index 5365f87d12b3d9b3cd8916b48d4ca62ab9bd0bf6..eb5f177c71d525dd32a1f60b168610b145f74ed6 100644 (file)
@@ -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 {
index 5a2b09dccf95d14981bd17feffce745235cd9526..60a08b13c74c30bebc36d0bf93ea2932b907c706 100644 (file)
@@ -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'
index ff8a43366f39819849990104e99f4742b35d3246..fc44cd250756717fb49ad61777f0a8edd3b19cec 100644 (file)
@@ -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) {
index 29f99ed6d0bfec68bc48263f8e542126aaa9253a..d3665bc9082e93a955e10cc52d69c886a42ced15 100644 (file)
@@ -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)
index 32e4a42e4655f0c944977a7dab0422abe8154034..ada13dc9871bdd9b08794770bb06b6ccd9c6c11c 100644 (file)
@@ -9,6 +9,7 @@
     "importHelpers": true,
     "removeComments": true,
     "strictBindCallApply": true,
+    "esModuleInterop": true,
     "outDir": "./dist",
     "lib": [
       "dom",
index 9d2a8f2baee5da6245ed1b11fd3bda5958bbb817..fc065406240d04d85dc3c81fd7db2c06d6ac1d09 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
   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"
   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"