diff options
-rw-r--r-- | server/controllers/api/index.ts | 11 | ||||
-rw-r--r-- | server/controllers/api/videos/upload.ts | 4 | ||||
-rw-r--r-- | server/helpers/express-utils.ts | 8 |
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 @@ | |||
1 | import cors from 'cors' | 1 | import cors from 'cors' |
2 | import express from 'express' | 2 | import express from 'express' |
3 | 3 | import { logger } from '@server/helpers/logger' | |
4 | import { HttpStatusCode } from '../../../shared/models' | 4 | import { HttpStatusCode } from '../../../shared/models' |
5 | import { badRequest } from '../../helpers/express-utils' | ||
6 | import { abuseRouter } from './abuse' | 5 | import { abuseRouter } from './abuse' |
7 | import { accountsRouter } from './accounts' | 6 | import { accountsRouter } from './accounts' |
8 | import { blocklistRouter } from './blocklist' | 7 | import { blocklistRouter } from './blocklist' |
@@ -64,3 +63,11 @@ export { apiRouter } | |||
64 | function pong (req: express.Request, res: express.Response) { | 63 | function 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 | |||
67 | function 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 | ||
69 | uploadRouter.delete('/upload-resumable', | 69 | uploadRouter.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 | ||
75 | uploadRouter.put('/upload-resumable', | 75 | uploadRouter.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 @@ | |||
1 | import express, { RequestHandler } from 'express' | 1 | import express, { RequestHandler } from 'express' |
2 | import multer, { diskStorage } from 'multer' | 2 | import multer, { diskStorage } from 'multer' |
3 | import { getLowercaseExtension } from '@shared/core-utils' | 3 | import { getLowercaseExtension } from '@shared/core-utils' |
4 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | ||
5 | import { CONFIG } from '../initializers/config' | 4 | import { CONFIG } from '../initializers/config' |
6 | import { REMOTE_SCHEME } from '../initializers/constants' | 5 | import { REMOTE_SCHEME } from '../initializers/constants' |
7 | import { isArray } from './custom-validators/misc' | 6 | import { isArray } from './custom-validators/misc' |
@@ -59,12 +58,6 @@ function getHostWithPort (host: string) { | |||
59 | return host | 58 | return host |
60 | } | 59 | } |
61 | 60 | ||
62 | function badRequest (_req: express.Request, res: express.Response) { | ||
63 | return res.type('json') | ||
64 | .status(HttpStatusCode.BAD_REQUEST_400) | ||
65 | .end() | ||
66 | } | ||
67 | |||
68 | function createReqFiles ( | 61 | function 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 |