From c756bae079e02873f6433582ca14a092fec0db27 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sun, 6 Jun 2021 10:21:06 +0200 Subject: add video upload types, add doc middleware to more routes --- server/controllers/api/videos/index.ts | 23 +++++++++++++++++++---- server/controllers/api/videos/watching.ts | 9 ++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 703051ee2..8c6c44144 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -60,12 +60,25 @@ videosRouter.use('/', liveRouter) videosRouter.use('/', uploadRouter) videosRouter.use('/', updateRouter) -videosRouter.get('/categories', listVideoCategories) -videosRouter.get('/licences', listVideoLicences) -videosRouter.get('/languages', listVideoLanguages) -videosRouter.get('/privacies', listVideoPrivacies) +videosRouter.get('/categories', + openapiOperationDoc({ operationId: 'getCategories' }), + listVideoCategories +) +videosRouter.get('/licences', + openapiOperationDoc({ operationId: 'getLicences' }), + listVideoLicences +) +videosRouter.get('/languages', + openapiOperationDoc({ operationId: 'getLanguages' }), + listVideoLanguages +) +videosRouter.get('/privacies', + openapiOperationDoc({ operationId: 'getPrivacies' }), + listVideoPrivacies +) videosRouter.get('/', + openapiOperationDoc({ operationId: 'getVideos' }), paginationValidator, videosSortValidator, setDefaultVideosSort, @@ -76,6 +89,7 @@ videosRouter.get('/', ) videosRouter.get('/:id/description', + openapiOperationDoc({ operationId: 'getVideoDesc' }), asyncMiddleware(videosGetValidator), asyncMiddleware(getVideoDescription) ) @@ -91,6 +105,7 @@ videosRouter.get('/:id', asyncMiddleware(getVideo) ) videosRouter.post('/:id/views', + openapiOperationDoc({ operationId: 'addView' }), asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')), asyncMiddleware(viewVideo) ) diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts index 08190e583..8b15525aa 100644 --- a/server/controllers/api/videos/watching.ts +++ b/server/controllers/api/videos/watching.ts @@ -1,12 +1,19 @@ import * as express from 'express' import { UserWatchingVideo } from '../../../../shared' -import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoWatchingValidator } from '../../../middlewares' +import { + asyncMiddleware, + asyncRetryTransactionMiddleware, + authenticate, + openapiOperationDoc, + videoWatchingValidator +} from '../../../middlewares' import { UserVideoHistoryModel } from '../../../models/user/user-video-history' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const watchingRouter = express.Router() watchingRouter.put('/:videoId/watching', + openapiOperationDoc({ operationId: 'setProgress' }), authenticate, asyncMiddleware(videoWatchingValidator), asyncRetryTransactionMiddleware(userWatchVideo) -- cgit v1.2.3