aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/api/index.ts11
-rw-r--r--server/controllers/api/videos/upload.ts4
-rw-r--r--server/helpers/express-utils.ts8
3 files changed, 11 insertions, 12 deletions
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index 31f1a56f9..38bd135d0 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -1,8 +1,7 @@
1import cors from 'cors' 1import cors from 'cors'
2import express from 'express' 2import express from 'express'
3 3import { logger } from '@server/helpers/logger'
4import { HttpStatusCode } from '../../../shared/models' 4import { HttpStatusCode } from '../../../shared/models'
5import { badRequest } from '../../helpers/express-utils'
6import { abuseRouter } from './abuse' 5import { abuseRouter } from './abuse'
7import { accountsRouter } from './accounts' 6import { accountsRouter } from './accounts'
8import { blocklistRouter } from './blocklist' 7import { blocklistRouter } from './blocklist'
@@ -64,3 +63,11 @@ export { apiRouter }
64function pong (req: express.Request, res: express.Response) { 63function pong (req: express.Request, res: express.Response) {
65 return res.send('pong').status(HttpStatusCode.OK_200).end() 64 return res.send('pong').status(HttpStatusCode.OK_200).end()
66} 65}
66
67function badRequest (req: express.Request, res: express.Response) {
68 logger.debug(`API express handler not found: bad PeerTube request for ${req.method} - ${req.originalUrl}`)
69
70 return res.type('json')
71 .status(HttpStatusCode.BAD_REQUEST_400)
72 .end()
73}
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index 0e07302d2..27fef0b1a 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -63,13 +63,13 @@ uploadRouter.post('/upload-resumable',
63 authenticate, 63 authenticate,
64 reqVideoFileAddResumable, 64 reqVideoFileAddResumable,
65 asyncMiddleware(videosAddResumableInitValidator), 65 asyncMiddleware(videosAddResumableInitValidator),
66 uploadx.upload 66 (req, res) => uploadx.upload(req, res) // Prevent next() call, explicitely tell to uploadx it's the end
67) 67)
68 68
69uploadRouter.delete('/upload-resumable', 69uploadRouter.delete('/upload-resumable',
70 authenticate, 70 authenticate,
71 asyncMiddleware(deleteUploadResumableCache), 71 asyncMiddleware(deleteUploadResumableCache),
72 uploadx.upload 72 (req, res) => uploadx.upload(req, res) // Prevent next() call, explicitely tell to uploadx it's the end
73) 73)
74 74
75uploadRouter.put('/upload-resumable', 75uploadRouter.put('/upload-resumable',
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts
index 82dd4c178..783097e55 100644
--- a/server/helpers/express-utils.ts
+++ b/server/helpers/express-utils.ts
@@ -1,7 +1,6 @@
1import express, { RequestHandler } from 'express' 1import express, { RequestHandler } from 'express'
2import multer, { diskStorage } from 'multer' 2import multer, { diskStorage } from 'multer'
3import { getLowercaseExtension } from '@shared/core-utils' 3import { getLowercaseExtension } from '@shared/core-utils'
4import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
5import { CONFIG } from '../initializers/config' 4import { CONFIG } from '../initializers/config'
6import { REMOTE_SCHEME } from '../initializers/constants' 5import { REMOTE_SCHEME } from '../initializers/constants'
7import { isArray } from './custom-validators/misc' 6import { isArray } from './custom-validators/misc'
@@ -59,12 +58,6 @@ function getHostWithPort (host: string) {
59 return host 58 return host
60} 59}
61 60
62function badRequest (_req: express.Request, res: express.Response) {
63 return res.type('json')
64 .status(HttpStatusCode.BAD_REQUEST_400)
65 .end()
66}
67
68function createReqFiles ( 61function createReqFiles (
69 fieldNames: string[], 62 fieldNames: string[],
70 mimeTypes: { [id: string]: string | string[] }, 63 mimeTypes: { [id: string]: string | string[] },
@@ -126,7 +119,6 @@ export {
126 getHostWithPort, 119 getHostWithPort,
127 createAnyReqFiles, 120 createAnyReqFiles,
128 isUserAbleToSearchRemoteURI, 121 isUserAbleToSearchRemoteURI,
129 badRequest,
130 createReqFiles, 122 createReqFiles,
131 cleanUpReqFiles, 123 cleanUpReqFiles,
132 getCountVideos 124 getCountVideos