diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/admin.ts | 2 | ||||
-rw-r--r-- | server/middlewares/oauth.ts | 8 | ||||
-rw-r--r-- | server/middlewares/pagination.ts | 4 | ||||
-rw-r--r-- | server/middlewares/pods.ts | 6 | ||||
-rw-r--r-- | server/middlewares/secure.ts | 10 | ||||
-rw-r--r-- | server/middlewares/validators/pods.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/videos.ts | 2 |
8 files changed, 18 insertions, 18 deletions
diff --git a/server/middlewares/admin.ts b/server/middlewares/admin.ts index ebafa36a4..28b6a9a12 100644 --- a/server/middlewares/admin.ts +++ b/server/middlewares/admin.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const logger = require('../helpers/logger') | 1 | import { logger } from '../helpers' |
2 | 2 | ||
3 | function ensureIsAdmin (req, res, next) { | 3 | function ensureIsAdmin (req, res, next) { |
4 | const user = res.locals.oauth.token.user | 4 | const user = res.locals.oauth.token.user |
diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index 31ae1e000..07bbded57 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import OAuthServer = require('express-oauth-server') | 1 | import OAuthServer = require('express-oauth-server') |
2 | 2 | ||
3 | const constants = require('../initializers/constants') | 3 | import { OAUTH_LIFETIME } from '../initializers' |
4 | const logger = require('../helpers/logger') | 4 | import { logger } from '../helpers' |
5 | 5 | ||
6 | const oAuthServer = new OAuthServer({ | 6 | const oAuthServer = new OAuthServer({ |
7 | accessTokenLifetime: constants.OAUTH_LIFETIME.ACCESS_TOKEN, | 7 | accessTokenLifetime: OAUTH_LIFETIME.ACCESS_TOKEN, |
8 | refreshTokenLifetime: constants.OAUTH_LIFETIME.REFRESH_TOKEN, | 8 | refreshTokenLifetime: OAUTH_LIFETIME.REFRESH_TOKEN, |
9 | model: require('../lib/oauth-model') | 9 | model: require('../lib/oauth-model') |
10 | }) | 10 | }) |
11 | 11 | ||
diff --git a/server/middlewares/pagination.ts b/server/middlewares/pagination.ts index 8fe9f9082..cadd76980 100644 --- a/server/middlewares/pagination.ts +++ b/server/middlewares/pagination.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | const constants = require('../initializers/constants') | 1 | import { PAGINATION_COUNT_DEFAULT } from '../initializers' |
2 | 2 | ||
3 | function setPagination (req, res, next) { | 3 | function setPagination (req, res, next) { |
4 | if (!req.query.start) req.query.start = 0 | 4 | if (!req.query.start) req.query.start = 0 |
5 | else req.query.start = parseInt(req.query.start, 10) | 5 | else req.query.start = parseInt(req.query.start, 10) |
6 | 6 | ||
7 | if (!req.query.count) req.query.count = constants.PAGINATION_COUNT_DEFAULT | 7 | if (!req.query.count) req.query.count = PAGINATION_COUNT_DEFAULT |
8 | else req.query.count = parseInt(req.query.count, 10) | 8 | else req.query.count = parseInt(req.query.count, 10) |
9 | 9 | ||
10 | return next() | 10 | return next() |
diff --git a/server/middlewares/pods.ts b/server/middlewares/pods.ts index e405f265e..c255be899 100644 --- a/server/middlewares/pods.ts +++ b/server/middlewares/pods.ts | |||
@@ -1,6 +1,4 @@ | |||
1 | 'use strict' | 1 | import { REMOTE_SCHEME } from '../initializers' |
2 | |||
3 | const constants = require('../initializers/constants') | ||
4 | 2 | ||
5 | function setBodyHostsPort (req, res, next) { | 3 | function setBodyHostsPort (req, res, next) { |
6 | if (!req.body.hosts) return next() | 4 | if (!req.body.hosts) return next() |
@@ -48,7 +46,7 @@ function getHostWithPort (host) { | |||
48 | 46 | ||
49 | // The port was not specified | 47 | // The port was not specified |
50 | if (splitted.length === 1) { | 48 | if (splitted.length === 1) { |
51 | if (constants.REMOTE_SCHEME.HTTP === 'https') return host + ':443' | 49 | if (REMOTE_SCHEME.HTTP === 'https') return host + ':443' |
52 | 50 | ||
53 | return host + ':80' | 51 | return host + ':80' |
54 | } | 52 | } |
diff --git a/server/middlewares/secure.ts b/server/middlewares/secure.ts index ee8545028..bd7cfa918 100644 --- a/server/middlewares/secure.ts +++ b/server/middlewares/secure.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | const db = require('../initializers/database') | 1 | import { database as db } from '../initializers' |
2 | const logger = require('../helpers/logger') | 2 | import { |
3 | const peertubeCrypto = require('../helpers/peertube-crypto') | 3 | logger, |
4 | checkSignature as peertubeCryptoCheckSignature | ||
5 | } from '../helpers' | ||
4 | 6 | ||
5 | function checkSignature (req, res, next) { | 7 | function checkSignature (req, res, next) { |
6 | const host = req.body.signature.host | 8 | const host = req.body.signature.host |
@@ -26,7 +28,7 @@ function checkSignature (req, res, next) { | |||
26 | signatureShouldBe = host | 28 | signatureShouldBe = host |
27 | } | 29 | } |
28 | 30 | ||
29 | const signatureOk = peertubeCrypto.checkSignature(pod.publicKey, signatureShouldBe, req.body.signature.signature) | 31 | const signatureOk = peertubeCryptoCheckSignature(pod.publicKey, signatureShouldBe, req.body.signature.signature) |
30 | 32 | ||
31 | if (signatureOk === true) { | 33 | if (signatureOk === true) { |
32 | res.locals.secure = { | 34 | res.locals.secure = { |
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts index fbfd268d0..c55a88b85 100644 --- a/server/middlewares/validators/pods.ts +++ b/server/middlewares/validators/pods.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const db = require('../../initializers/database') | 1 | import { database as db } from '../../initializers/database' |
2 | import { checkErrors } from './utils' | 2 | import { checkErrors } from './utils' |
3 | import { logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
4 | import { CONFIG } from '../../initializers' | 4 | import { CONFIG } from '../../initializers' |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index a9149fe1b..e0d1d917a 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const db = require('../../initializers/database') | 1 | import { database as db } from '../../initializers/database' |
2 | import { checkErrors } from './utils' | 2 | import { checkErrors } from './utils' |
3 | import { logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
4 | 4 | ||
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index 5a49cf73c..47825975c 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const db = require('../../initializers/database') | 1 | import { database as db } from '../../initializers/database' |
2 | import { checkErrors } from './utils' | 2 | import { checkErrors } from './utils' |
3 | import { CONSTRAINTS_FIELDS, SEARCHABLE_COLUMNS } from '../../initializers' | 3 | import { CONSTRAINTS_FIELDS, SEARCHABLE_COLUMNS } from '../../initializers' |
4 | import { logger, isVideoDurationValid } from '../../helpers' | 4 | import { logger, isVideoDurationValid } from '../../helpers' |