Fix error logging
[oweals/peertube.git] / server / middlewares / pods.ts
index e405f265ec2dec60d5f5392dc5600368512a6e6c..eaf9aa144a7806b9532b8356d1375543e9c1ec50 100644 (file)
@@ -1,8 +1,9 @@
-'use strict'
+import 'express-validator'
+import * as express from 'express'
 
-const constants = require('../initializers/constants')
+import { REMOTE_SCHEME } from '../initializers'
 
-function setBodyHostsPort (req, res, next) {
+function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
   if (!req.body.hosts) return next()
 
   for (let i = 0; i < req.body.hosts.length; i++) {
@@ -19,7 +20,7 @@ function setBodyHostsPort (req, res, next) {
   return next()
 }
 
-function setBodyHostPort (req, res, next) {
+function setBodyHostPort (req: express.Request, res: express.Response, next: express.NextFunction) {
   if (!req.body.host) return next()
 
   const hostWithPort = getHostWithPort(req.body.host)
@@ -43,12 +44,12 @@ export {
 
 // ---------------------------------------------------------------------------
 
-function getHostWithPort (host) {
+function getHostWithPort (host: string) {
   const splitted = host.split(':')
 
   // The port was not specified
   if (splitted.length === 1) {
-    if (constants.REMOTE_SCHEME.HTTP === 'https') return host + ':443'
+    if (REMOTE_SCHEME.HTTP === 'https') return host + ':443'
 
     return host + ':80'
   }