aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/feeds.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server/middlewares/validators/feeds.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/middlewares/validators/feeds.ts')
-rw-r--r--server/middlewares/validators/feeds.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index 18469bad3..617661813 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -12,6 +12,7 @@ import {
12} from '../../helpers/middlewares' 12} from '../../helpers/middlewares'
13import { doesVideoExist } from '../../helpers/middlewares/videos' 13import { doesVideoExist } from '../../helpers/middlewares/videos'
14import { areValidationErrors } from './utils' 14import { areValidationErrors } from './utils'
15import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
15 16
16const feedsFormatValidator = [ 17const feedsFormatValidator = [
17 param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), 18 param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
@@ -35,7 +36,7 @@ function setFeedFormatContentType (req: express.Request, res: express.Response,
35 if (req.accepts(acceptableContentTypes)) { 36 if (req.accepts(acceptableContentTypes)) {
36 res.set('Content-Type', req.accepts(acceptableContentTypes) as string) 37 res.set('Content-Type', req.accepts(acceptableContentTypes) as string)
37 } else { 38 } else {
38 return res.status(406) 39 return res.status(HttpStatusCode.NOT_ACCEPTABLE_406)
39 .json({ 40 .json({
40 message: `You should accept at least one of the following content-types: ${acceptableContentTypes.join(', ')}` 41 message: `You should accept at least one of the following content-types: ${acceptableContentTypes.join(', ')}`
41 }) 42 })
@@ -105,7 +106,7 @@ const videoCommentsFeedsValidator = [
105 if (areValidationErrors(req, res)) return 106 if (areValidationErrors(req, res)) return
106 107
107 if (req.query.videoId && (req.query.videoChannelId || req.query.videoChannelName)) { 108 if (req.query.videoId && (req.query.videoChannelId || req.query.videoChannelName)) {
108 return res.status(400) 109 return res.status(HttpStatusCode.BAD_REQUEST_400)
109 .json({ 110 .json({
110 message: 'videoId cannot be mixed with a channel filter' 111 message: 'videoId cannot be mixed with a channel filter'
111 }) 112 })