aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/api/videos/index.ts6
-rw-r--r--server/controllers/api/videos/update.ts4
-rw-r--r--server/controllers/api/videos/upload.ts8
-rw-r--r--server/middlewares/doc.ts9
4 files changed, 15 insertions, 12 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 7671f099e..703051ee2 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import toInt from 'validator/lib/toInt' 2import toInt from 'validator/lib/toInt'
3import { doJSONRequest } from '@server/helpers/requests' 3import { doJSONRequest } from '@server/helpers/requests'
4import { LiveManager } from '@server/lib/live-manager' 4import { LiveManager } from '@server/lib/live-manager'
5import { docMiddleware } from '@server/middlewares/doc' 5import { openapiOperationDoc } from '@server/middlewares/doc'
6import { getServerActor } from '@server/models/application/application' 6import { getServerActor } from '@server/models/application/application'
7import { MVideoAccountLight } from '@server/types/models' 7import { MVideoAccountLight } from '@server/types/models'
8import { VideosCommonQuery } from '../../../../shared' 8import { VideosCommonQuery } from '../../../../shared'
@@ -84,7 +84,7 @@ videosRouter.get('/:id/metadata/:videoFileId',
84 asyncMiddleware(getVideoFileMetadata) 84 asyncMiddleware(getVideoFileMetadata)
85) 85)
86videosRouter.get('/:id', 86videosRouter.get('/:id',
87 docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo'), 87 openapiOperationDoc({ operationId: 'getVideo' }),
88 optionalAuthenticate, 88 optionalAuthenticate,
89 asyncMiddleware(videosCustomGetValidator('only-video-with-rights')), 89 asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
90 asyncMiddleware(checkVideoFollowConstraints), 90 asyncMiddleware(checkVideoFollowConstraints),
@@ -96,7 +96,7 @@ videosRouter.post('/:id/views',
96) 96)
97 97
98videosRouter.delete('/:id', 98videosRouter.delete('/:id',
99 docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo'), 99 openapiOperationDoc({ operationId: 'delVideo' }),
100 authenticate, 100 authenticate,
101 asyncMiddleware(videosRemoveValidator), 101 asyncMiddleware(videosRemoveValidator),
102 asyncRetryTransactionMiddleware(removeVideo) 102 asyncRetryTransactionMiddleware(removeVideo)
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts
index 09e584d30..8affe71c6 100644
--- a/server/controllers/api/videos/update.ts
+++ b/server/controllers/api/videos/update.ts
@@ -20,7 +20,7 @@ import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
20import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares' 20import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares'
21import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' 21import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
22import { VideoModel } from '../../../models/video/video' 22import { VideoModel } from '../../../models/video/video'
23import { docMiddleware } from '@server/middlewares/doc' 23import { openapiOperationDoc } from '@server/middlewares/doc'
24 24
25const lTags = loggerTagsFactory('api', 'video') 25const lTags = loggerTagsFactory('api', 'video')
26const auditLogger = auditLoggerFactory('videos') 26const auditLogger = auditLoggerFactory('videos')
@@ -36,7 +36,7 @@ const reqVideoFileUpdate = createReqFiles(
36) 36)
37 37
38updateRouter.put('/:id', 38updateRouter.put('/:id',
39 docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo'), 39 openapiOperationDoc({ operationId: 'putVideo' }),
40 authenticate, 40 authenticate,
41 reqVideoFileUpdate, 41 reqVideoFileUpdate,
42 asyncMiddleware(videosUpdateValidator), 42 asyncMiddleware(videosUpdateValidator),
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index 93a68f759..783cc329a 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -6,7 +6,7 @@ import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
6import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url' 6import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
7import { addOptimizeOrMergeAudioJob, buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' 7import { addOptimizeOrMergeAudioJob, buildLocalVideoFromReq, buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
8import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths' 8import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
9import { docMiddleware } from '@server/middlewares/doc' 9import { openapiOperationDoc } from '@server/middlewares/doc'
10import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' 10import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
11import { uploadx } from '@uploadx/core' 11import { uploadx } from '@uploadx/core'
12import { VideoCreate, VideoState } from '../../../../shared' 12import { VideoCreate, VideoState } from '../../../../shared'
@@ -61,7 +61,7 @@ const reqVideoFileAddResumable = createReqFiles(
61) 61)
62 62
63uploadRouter.post('/upload', 63uploadRouter.post('/upload',
64 docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy'), 64 openapiOperationDoc({ operationId: 'uploadLegacy' }),
65 authenticate, 65 authenticate,
66 reqVideoFileAdd, 66 reqVideoFileAdd,
67 asyncMiddleware(videosAddLegacyValidator), 67 asyncMiddleware(videosAddLegacyValidator),
@@ -69,7 +69,7 @@ uploadRouter.post('/upload',
69) 69)
70 70
71uploadRouter.post('/upload-resumable', 71uploadRouter.post('/upload-resumable',
72 docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumableInit'), 72 openapiOperationDoc({ operationId: 'uploadResumableInit' }),
73 authenticate, 73 authenticate,
74 reqVideoFileAddResumable, 74 reqVideoFileAddResumable,
75 asyncMiddleware(videosAddResumableInitValidator), 75 asyncMiddleware(videosAddResumableInitValidator),
@@ -82,7 +82,7 @@ uploadRouter.delete('/upload-resumable',
82) 82)
83 83
84uploadRouter.put('/upload-resumable', 84uploadRouter.put('/upload-resumable',
85 docMiddleware('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadResumable'), 85 openapiOperationDoc({ operationId: 'uploadResumable' }),
86 authenticate, 86 authenticate,
87 uploadxMiddleware, // uploadx doesn't use call next() before the file upload completes 87 uploadxMiddleware, // uploadx doesn't use call next() before the file upload completes
88 asyncMiddleware(videosAddResumableValidator), 88 asyncMiddleware(videosAddResumableValidator),
diff --git a/server/middlewares/doc.ts b/server/middlewares/doc.ts
index aa852cd77..3db85c68d 100644
--- a/server/middlewares/doc.ts
+++ b/server/middlewares/doc.ts
@@ -1,13 +1,16 @@
1import * as express from 'express' 1import * as express from 'express'
2 2
3function docMiddleware (docUrl: string) { 3function openapiOperationDoc (options: {
4 url?: string
5 operationId?: string
6}) {
4 return (req: express.Request, res: express.Response, next: express.NextFunction) => { 7 return (req: express.Request, res: express.Response, next: express.NextFunction) => {
5 res.locals.docUrl = docUrl 8 res.locals.docUrl = options.url || 'https://docs.joinpeertube.org/api-rest-reference.html#operation/' + options.operationId
6 9
7 if (next) return next() 10 if (next) return next()
8 } 11 }
9} 12}
10 13
11export { 14export {
12 docMiddleware 15 openapiOperationDoc
13} 16}