diff --git a/package.json b/package.json index 118a0aef6452d64307e9d8a60040b83fb8a73e8b..e7d0c39a45577099737a7ca252664352d6bdff3a 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "scripty": "^1.5.0", "sequelize": "4.0.0-2", "typescript": "~2.2.0", + "validator": "^7.0.0", "winston": "^2.1.1", "ws": "^2.0.0" }, @@ -86,6 +87,7 @@ "@types/node": "^7.0.18", "@types/request": "^0.0.43", "@types/sequelize": "^4.0.55", + "@types/validator": "^6.2.0", "@types/winston": "^2.3.2", "@types/ws": "^0.0.41", "chai": "^3.3.0", diff --git a/server.ts b/server.ts index f5413b8e33fd7c5ce1ddf9e2f4cf4e776fc3decd..b27a83860ff0256100b1d84405d7d9d2af0a1f3e 100644 --- a/server.ts +++ b/server.ts @@ -3,13 +3,14 @@ if ([ 'dev', 'test'].indexOf(process.env.NODE_ENV) !== -1) { } // ----------- Node modules ----------- -import bodyParser = require('body-parser') -import express = require('express') +import * as bodyParser from 'body-parser' +import * as express from 'express' +// FIXME: cannot import express-validator const expressValidator = require('express-validator') -import http = require('http') -import morgan = require('morgan') -import path = require('path') -import bittorrentTracker = require('bittorrent-tracker') +import * as http from 'http' +import * as morgan from 'morgan' +import * as path from 'path' +import * as bittorrentTracker from 'bittorrent-tracker' import { Server as WebSocketServer } from 'ws' const TrackerServer = bittorrentTracker.Server diff --git a/server/controllers/api/clients.ts b/server/controllers/api/clients.ts index 614163c8371c3ba99cf11ef3521b539b7a6b3798..f6499556a0d4e249b93fd310722187d4ef2cc231 100644 --- a/server/controllers/api/clients.ts +++ b/server/controllers/api/clients.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { CONFIG } from '../../initializers'; import { logger } from '../../helpers' diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 8bdde61b38f08ab9276f957c15d062f51fba6329..57c9398ecaafbd57a326b9ee02887fa5ca160dc2 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { CONFIG } from '../../initializers' diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts index 18bef2d3d3777604d819a7f91d50a2e7709e4b8a..98004544d05c1d8aa85ec244918461fd10a73bd5 100644 --- a/server/controllers/api/index.ts +++ b/server/controllers/api/index.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { badRequest } from '../../helpers' diff --git a/server/controllers/api/pods.ts b/server/controllers/api/pods.ts index 4ff1f5d9fa6dd8b237d493f3dfa8fa2b2c663425..a028c4ab9a1073b0debadf05a557902613199f1d 100644 --- a/server/controllers/api/pods.ts +++ b/server/controllers/api/pods.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { waterfall } from 'async' import { database as db } from '../../initializers/database' diff --git a/server/controllers/api/remote/index.ts b/server/controllers/api/remote/index.ts index b11439204e806e89c7df2b1ac93ddb7714933a77..d3522772bec9d38298152e7e06b172cb08541236 100644 --- a/server/controllers/api/remote/index.ts +++ b/server/controllers/api/remote/index.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { badRequest } from '../../../helpers' diff --git a/server/controllers/api/remote/pods.ts b/server/controllers/api/remote/pods.ts index 7a9a0c4f06552273e96699584609e1f81ca8edee..9c9d2164d9b8b342aacb5e7aff7d703267cbf54c 100644 --- a/server/controllers/api/remote/pods.ts +++ b/server/controllers/api/remote/pods.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import * as waterfall from 'async/waterfall' import { database as db } from '../../../initializers/database' diff --git a/server/controllers/api/remote/videos.ts b/server/controllers/api/remote/videos.ts index 178a21e7c56bbb0e1738f0bd3c59b5dccb4ba010..d97a3db31ef0683a34d5c4cd973c74d6be8d0449 100644 --- a/server/controllers/api/remote/videos.ts +++ b/server/controllers/api/remote/videos.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { eachSeries, waterfall } from 'async' import { database as db } from '../../../initializers/database' diff --git a/server/controllers/api/requests.ts b/server/controllers/api/requests.ts index 304499a4f67832a4c0b05099e8b22b251a5c066a..ff4b4ac1ab85e0ad0525645b466bc222a64c5f94 100644 --- a/server/controllers/api/requests.ts +++ b/server/controllers/api/requests.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { parallel } from 'async' import { diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 97a744f54391c56c9c7f77ee6b97c666d44f54bb..44c5ec13c8f21e2f238ded0e05b00fc5e41c063b 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { waterfall } from 'async' import { database as db } from '../../initializers/database' diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts index 3dd884354a7ff9940d6b999b4416ba182d8532ab..68db025b7f3bf67a0ec079b61039bdd5fdd01171 100644 --- a/server/controllers/api/videos/abuse.ts +++ b/server/controllers/api/videos/abuse.ts @@ -1,8 +1,8 @@ -import express = require('express') +import * as express from 'express' import { waterfall } from 'async' import { database as db } from '../../../initializers/database' -import friends = require('../../../lib/friends') +import * as friends from '../../../lib/friends' import { logger, getFormatedObjects, diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index fb4d57d7ba6077b200d32b52104298997b4d00e1..58960798bd503cfd2978f411a9352f3d9a795686 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { database as db } from '../../../initializers/database' import { logger } from '../../../helpers' diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 6eda7159bb26cfe44bb624f83d6e88cb022e4f6c..b82b0936f13674fcae423411ebb73ec6a18053b2 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -1,7 +1,7 @@ -import express = require('express') -import fs = require('fs') -import multer = require('multer') -import path = require('path') +import * as express from 'express' +import * as fs from 'fs' +import * as multer from 'multer' +import * as path from 'path' import { waterfall } from 'async' import { database as db } from '../../../initializers/database' diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 571ff68e3ffb0c254c1113cde697f15ff1fad9a9..1bc575675ae93bb2ff6e1056b97f5b069a062e58 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -1,4 +1,4 @@ -import express = require('express') +import * as express from 'express' import { waterfall } from 'async' import { database as db } from '../../../initializers/database' diff --git a/server/controllers/client.ts b/server/controllers/client.ts index ce5608c9b7145e5f78d58a82424c6f9842b13f83..c3d28245c329bfc5d180d0073a21389abc893b1a 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts @@ -1,10 +1,8 @@ import { parallel } from 'async' -import express = require('express') -import fs = require('fs') +import * as express from 'express' +import * as fs from 'fs' import { join } from 'path' -import expressValidator = require('express-validator') -// TODO: use .validator when express-validator typing will have validator field -const validator = expressValidator['validator'] +import * as validator from 'validator' import { database as db } from '../initializers/database' import { diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 51f75c57ed862d8afdebc350fd46ad4c0ea05f84..e65282339e9f2143484cbd6ad483be457166e00a 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -1,5 +1,5 @@ -import express = require('express') -import cors = require('cors') +import * as express from 'express' +import * as cors from 'cors' import { CONFIG, diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts index e4c827feb11b6405d964afce9499bb108e4e6a13..ee939ad04b0053722fd281d7ab12a98326ec5066 100644 --- a/server/helpers/custom-validators/pods.ts +++ b/server/helpers/custom-validators/pods.ts @@ -1,6 +1,4 @@ -import expressValidator = require('express-validator') -// TODO: use .validator when express-validator typing will have validator field -const validator = expressValidator['validator'] +import * as validator from 'validator' import { isArray } from './misc' diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 8fd2dac4fee484c50af2c06c3c46223af33c2fe4..f303ab8db2f5be4ea43bc69ee0663ce06d687371 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -1,7 +1,5 @@ import { values } from 'lodash' -import expressValidator = require('express-validator') -// TODO: use .validator when express-validator typing will have validator field -const validator = expressValidator['validator'] +import * as validator from 'validator' import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers' const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 2b2370be4471c906ecc20e82df8f66a77b8d3a1f..6389998e1320c831d0891d5cf78f76756c04a1f2 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -1,7 +1,5 @@ import { values } from 'lodash' -import expressValidator = require('express-validator') -// TODO: use .validator when express-validator typing will have validator field -const validator = expressValidator['validator'] +import * as validator from 'validator' import { CONSTRAINTS_FIELDS, diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index 7d6ce4ec894cd1040ae2346016476bbac1f756e3..4f49c58250abae92c230f737429008e7a287425e 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts @@ -1,5 +1,5 @@ // TODO: import from ES6 when retry typing file will include errorFilter function -import retry = require('async/retry') +import * as retry from 'async/retry' import { database as db } from '../initializers/database' import { logger } from './logger' diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index 7c99db55fac3509a8bf531e01f83e528677f2f88..d8f2f687cb372b5169774ede5b8e5b0bb7ed8b41 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts @@ -1,7 +1,7 @@ // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/ -import mkdirp = require('mkdirp') -import path = require('path') -import winston = require('winston') +import * as mkdirp from 'mkdirp' +import * as path from 'path' +import * as winston from 'winston' // Do not use barrel (dependencies issues) import { CONFIG } from '../initializers/constants' diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index a4e9672e61927c184a4cf1da07274aca7b1fad09..feb32a4cd7a2374425c4342a8bdce0a03b904cb1 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts @@ -1,7 +1,7 @@ -import crypto = require('crypto') -import bcrypt = require('bcrypt') -import fs = require('fs') -import openssl = require('openssl-wrapper') +import * as crypto from 'crypto' +import * as bcrypt from 'bcrypt' +import * as fs from 'fs' +import * as openssl from 'openssl-wrapper' import { join } from 'path' import { diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 8ded529728ea53927db1b9a89f7042afa8aee24f..48b1fd703122e1c4cb9013ccfa7f3409bca8c33a 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -1,5 +1,5 @@ -import replay = require('request-replay') -import request = require('request') +import * as replay from 'request-replay' +import * as request from 'request' import { RETRY_REQUESTS, diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts index 0ee01b0e3720e1e153c2910fa19efb6ecb520b4e..8c3d64b6004b2c187a59b4eb4db73946b39ef060 100644 --- a/server/initializers/checker.ts +++ b/server/initializers/checker.ts @@ -1,4 +1,4 @@ -import config = require('config') +import * as config from 'config' import { database as db } from './database' import { CONFIG } from './constants' diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 1072d0de0bf341cda6904b342935383e4f2bcbbb..7ab019f4446e682865b215a1b736b6be50f1cce2 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -1,4 +1,4 @@ -import config = require('config') +import * as config from 'config' import { join } from 'path' // Do not use barrels, remain constants as independent as possible diff --git a/server/initializers/database.ts b/server/initializers/database.ts index c89a8b23c70780eec2384d13648021d0db0de5bc..b0f47876e93d48d114c4d807b20d5b43d04cc86e 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts @@ -1,6 +1,6 @@ -import fs = require('fs') +import * as fs from 'fs' import { join } from 'path' -import Sequelize = require('sequelize') +import * as Sequelize from 'sequelize' import { CONFIG } from './constants' // Do not use barrel, we need to load database first diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 46716410718a69519ccbd1bad36f89156b920189..2f9b589916b9bc6e28c0f50b945639f70cd31656 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts @@ -1,8 +1,8 @@ import { join } from 'path' -import config = require('config') +import * as config from 'config' import { each, series } from 'async' -import mkdirp = require('mkdirp') -import passwordGenerator = require('password-generator') +import * as mkdirp from 'mkdirp' +import * as passwordGenerator from 'password-generator' import { database as db } from './database' import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION } from './constants' diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts index d42cb3ccc5120f1f5bd8f8204c5c3e6752957964..379d43af528f0e16456dd9e8c7a635870620dadf 100644 --- a/server/initializers/migrator.ts +++ b/server/initializers/migrator.ts @@ -1,6 +1,6 @@ import { waterfall, eachSeries } from 'async' -import fs = require('fs') -import path = require('path') +import * as fs from 'fs' +import * as path from 'path' import * as Sequelize from 'sequelize' import { database as db } from './database' diff --git a/server/lib/friends.ts b/server/lib/friends.ts index 08b776e83c8ed3c506b0d6b77572fa7639455fe9..6b0fbd2bfc29fb20a46a2e9ca6a403afd5d994cc 100644 --- a/server/lib/friends.ts +++ b/server/lib/friends.ts @@ -1,5 +1,5 @@ import { each, eachLimit, eachSeries, series, waterfall } from 'async' -import request = require('request') +import * as request from 'request' import { database as db } from '../initializers/database' import { diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index 07bbded57d636d3a5999c46cc7b94621981c4c72..468e418106c69c84ceb596b705665ebadfd7de40 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts @@ -1,4 +1,4 @@ -import OAuthServer = require('express-oauth-server') +import * as OAuthServer from 'express-oauth-server' import { OAUTH_LIFETIME } from '../initializers' import { logger } from '../helpers' diff --git a/server/models/video.ts b/server/models/video.ts index 9284dfeba10c83ffbf7159ab68943cc153fe5dcb..5558a7c3bf1391dd78c7b4acd27945d388681f3c 100644 --- a/server/models/video.ts +++ b/server/models/video.ts @@ -1,12 +1,12 @@ -import safeBuffer = require('safe-buffer') +import * as safeBuffer from 'safe-buffer' const Buffer = safeBuffer.Buffer -import createTorrent = require('create-torrent') -import ffmpeg = require('fluent-ffmpeg') -import fs = require('fs') -import magnetUtil = require('magnet-uri') +import * as createTorrent from 'create-torrent' +import * as ffmpeg from 'fluent-ffmpeg' +import * as fs from 'fs' +import * as magnetUtil from 'magnet-uri' import { map, values } from 'lodash' import { parallel, series } from 'async' -import parseTorrent = require('parse-torrent') +import * as parseTorrent from 'parse-torrent' import { join } from 'path' import * as Sequelize from 'sequelize' diff --git a/yarn.lock b/yarn.lock index 857aa92e6cb51316573a29492f3ffe8a515fb717..28d33fa975d2e86902b8d43ef870840027b0faf4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -92,7 +92,7 @@ "@types/express-serve-static-core" "*" "@types/mime" "*" -"@types/validator@*": +"@types/validator@*", "@types/validator@^6.2.0": version "6.2.0" resolved "https://registry.yarnpkg.com/@types/validator/-/validator-6.2.0.tgz#020322fe1929f69889eb675a1bdb5a98394b71f0" @@ -3382,6 +3382,10 @@ validator@^5.6.0: version "5.7.0" resolved "https://registry.yarnpkg.com/validator/-/validator-5.7.0.tgz#7a87a58146b695ac486071141c0c49d67da05e5c" +validator@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/validator/-/validator-7.0.0.tgz#c74deb8063512fac35547938e6f0b1504a282fd2" + validator@~6.2.0: version "6.2.1" resolved "https://registry.yarnpkg.com/validator/-/validator-6.2.1.tgz#bc575b78d15beb2e338a665ba9530c7f409ef667"