aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-06-04 09:16:23 +0200
committerRigel Kent <sendmemail@rigelk.eu>2021-06-04 09:21:46 +0200
commit1333ab1f2d4ec495084c5368df25610683582ae3 (patch)
tree4d2b6f5b36d2acfacd5e5f6c3a9d35a9c7101658 /server
parent1c627fd8d2e60d4d790353886006485343d70084 (diff)
downloadPeerTube-1333ab1f2d4ec495084c5368df25610683582ae3.tar.gz
PeerTube-1333ab1f2d4ec495084c5368df25610683582ae3.tar.zst
PeerTube-1333ab1f2d4ec495084c5368df25610683582ae3.zip
add operationId doc middleware to so API endpoints
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/abuse.ts2
-rw-r--r--server/controllers/api/config.ts13
-rw-r--r--server/controllers/api/jobs.ts2
-rw-r--r--server/controllers/api/oauth-clients.ts3
-rw-r--r--server/controllers/api/plugins.ts6
-rw-r--r--server/controllers/api/search.ts3
-rw-r--r--server/controllers/api/users/token.ts4
-rw-r--r--server/controllers/api/videos/blacklist.ts4
8 files changed, 32 insertions, 5 deletions
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index 108627f81..ba5b94840 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -24,6 +24,7 @@ import {
24 deleteAbuseMessageValidator, 24 deleteAbuseMessageValidator,
25 ensureUserHasRight, 25 ensureUserHasRight,
26 getAbuseValidator, 26 getAbuseValidator,
27 openapiOperationDoc,
27 paginationValidator, 28 paginationValidator,
28 setDefaultPagination, 29 setDefaultPagination,
29 setDefaultSort 30 setDefaultSort
@@ -33,6 +34,7 @@ import { AccountModel } from '../../models/account/account'
33const abuseRouter = express.Router() 34const abuseRouter = express.Router()
34 35
35abuseRouter.get('/', 36abuseRouter.get('/',
37 openapiOperationDoc({ operationId: 'getAbuses' }),
36 authenticate, 38 authenticate,
37 ensureUserHasRight(UserRight.MANAGE_ABUSES), 39 ensureUserHasRight(UserRight.MANAGE_ABUSES),
38 paginationValidator, 40 paginationValidator,
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index 1f2a5f2da..9bd8c21c5 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -10,26 +10,32 @@ import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '..
10import { objectConverter } from '../../helpers/core-utils' 10import { objectConverter } from '../../helpers/core-utils'
11import { CONFIG, reloadConfig } from '../../initializers/config' 11import { CONFIG, reloadConfig } from '../../initializers/config'
12import { ClientHtml } from '../../lib/client-html' 12import { ClientHtml } from '../../lib/client-html'
13import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' 13import { asyncMiddleware, authenticate, ensureUserHasRight, openapiOperationDoc } from '../../middlewares'
14import { customConfigUpdateValidator } from '../../middlewares/validators/config' 14import { customConfigUpdateValidator } from '../../middlewares/validators/config'
15 15
16const configRouter = express.Router() 16const configRouter = express.Router()
17 17
18const auditLogger = auditLoggerFactory('config') 18const auditLogger = auditLoggerFactory('config')
19 19
20configRouter.get('/about', getAbout)
21
22configRouter.get('/', 20configRouter.get('/',
21 openapiOperationDoc({ operationId: 'getConfig' }),
23 asyncMiddleware(getConfig) 22 asyncMiddleware(getConfig)
24) 23)
25 24
25configRouter.get('/about',
26 openapiOperationDoc({ operationId: 'getAbout' }),
27 getAbout
28)
29
26configRouter.get('/custom', 30configRouter.get('/custom',
31 openapiOperationDoc({ operationId: 'getCustomConfig' }),
27 authenticate, 32 authenticate,
28 ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), 33 ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
29 getCustomConfig 34 getCustomConfig
30) 35)
31 36
32configRouter.put('/custom', 37configRouter.put('/custom',
38 openapiOperationDoc({ operationId: 'putCustomConfig' }),
33 authenticate, 39 authenticate,
34 ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), 40 ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
35 customConfigUpdateValidator, 41 customConfigUpdateValidator,
@@ -37,6 +43,7 @@ configRouter.put('/custom',
37) 43)
38 44
39configRouter.delete('/custom', 45configRouter.delete('/custom',
46 openapiOperationDoc({ operationId: 'delCustomConfig' }),
40 authenticate, 47 authenticate,
41 ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), 48 ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
42 asyncMiddleware(deleteCustomConfig) 49 asyncMiddleware(deleteCustomConfig)
diff --git a/server/controllers/api/jobs.ts b/server/controllers/api/jobs.ts
index d7cee1605..9e333322b 100644
--- a/server/controllers/api/jobs.ts
+++ b/server/controllers/api/jobs.ts
@@ -9,6 +9,7 @@ import {
9 authenticate, 9 authenticate,
10 ensureUserHasRight, 10 ensureUserHasRight,
11 jobsSortValidator, 11 jobsSortValidator,
12 openapiOperationDoc,
12 paginationValidatorBuilder, 13 paginationValidatorBuilder,
13 setDefaultPagination, 14 setDefaultPagination,
14 setDefaultSort 15 setDefaultSort
@@ -18,6 +19,7 @@ import { listJobsValidator } from '../../middlewares/validators/jobs'
18const jobsRouter = express.Router() 19const jobsRouter = express.Router()
19 20
20jobsRouter.get('/:state?', 21jobsRouter.get('/:state?',
22 openapiOperationDoc({ operationId: 'getJobs' }),
21 authenticate, 23 authenticate,
22 ensureUserHasRight(UserRight.MANAGE_JOBS), 24 ensureUserHasRight(UserRight.MANAGE_JOBS),
23 paginationValidatorBuilder([ 'jobs' ]), 25 paginationValidatorBuilder([ 'jobs' ]),
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts
index 48a10d31f..15bbf5c4d 100644
--- a/server/controllers/api/oauth-clients.ts
+++ b/server/controllers/api/oauth-clients.ts
@@ -3,12 +3,13 @@ import { OAuthClientLocal } from '../../../shared'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { CONFIG } from '../../initializers/config' 5import { CONFIG } from '../../initializers/config'
6import { asyncMiddleware } from '../../middlewares' 6import { asyncMiddleware, openapiOperationDoc } from '../../middlewares'
7import { OAuthClientModel } from '../../models/oauth/oauth-client' 7import { OAuthClientModel } from '../../models/oauth/oauth-client'
8 8
9const oauthClientsRouter = express.Router() 9const oauthClientsRouter = express.Router()
10 10
11oauthClientsRouter.get('/local', 11oauthClientsRouter.get('/local',
12 openapiOperationDoc({ operationId: 'getOAuthClient' }),
12 asyncMiddleware(getLocalClient) 13 asyncMiddleware(getLocalClient)
13) 14)
14 15
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index b64062287..1e6a02c49 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -8,6 +8,7 @@ import {
8 authenticate, 8 authenticate,
9 availablePluginsSortValidator, 9 availablePluginsSortValidator,
10 ensureUserHasRight, 10 ensureUserHasRight,
11 openapiOperationDoc,
11 paginationValidator, 12 paginationValidator,
12 pluginsSortValidator, 13 pluginsSortValidator,
13 setDefaultPagination, 14 setDefaultPagination,
@@ -35,6 +36,7 @@ import {
35const pluginRouter = express.Router() 36const pluginRouter = express.Router()
36 37
37pluginRouter.get('/available', 38pluginRouter.get('/available',
39 openapiOperationDoc({ operationId: 'getAvailablePlugins' }),
38 authenticate, 40 authenticate,
39 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 41 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
40 listAvailablePluginsValidator, 42 listAvailablePluginsValidator,
@@ -46,6 +48,7 @@ pluginRouter.get('/available',
46) 48)
47 49
48pluginRouter.get('/', 50pluginRouter.get('/',
51 openapiOperationDoc({ operationId: 'getPlugins' }),
49 authenticate, 52 authenticate,
50 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 53 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
51 listPluginsValidator, 54 listPluginsValidator,
@@ -84,6 +87,7 @@ pluginRouter.get('/:npmName',
84) 87)
85 88
86pluginRouter.post('/install', 89pluginRouter.post('/install',
90 openapiOperationDoc({ operationId: 'addPlugin' }),
87 authenticate, 91 authenticate,
88 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 92 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
89 installOrUpdatePluginValidator, 93 installOrUpdatePluginValidator,
@@ -91,6 +95,7 @@ pluginRouter.post('/install',
91) 95)
92 96
93pluginRouter.post('/update', 97pluginRouter.post('/update',
98 openapiOperationDoc({ operationId: 'updatePlugin' }),
94 authenticate, 99 authenticate,
95 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 100 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
96 installOrUpdatePluginValidator, 101 installOrUpdatePluginValidator,
@@ -98,6 +103,7 @@ pluginRouter.post('/update',
98) 103)
99 104
100pluginRouter.post('/uninstall', 105pluginRouter.post('/uninstall',
106 openapiOperationDoc({ operationId: 'uninstallPlugin' }),
101 authenticate, 107 authenticate,
102 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 108 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
103 uninstallPluginValidator, 109 uninstallPluginValidator,
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts
index a3b66b2a6..c975c5c3c 100644
--- a/server/controllers/api/search.ts
+++ b/server/controllers/api/search.ts
@@ -18,6 +18,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../lib/ac
18import { 18import {
19 asyncMiddleware, 19 asyncMiddleware,
20 commonVideosFiltersValidator, 20 commonVideosFiltersValidator,
21 openapiOperationDoc,
21 optionalAuthenticate, 22 optionalAuthenticate,
22 paginationValidator, 23 paginationValidator,
23 setDefaultPagination, 24 setDefaultPagination,
@@ -34,6 +35,7 @@ import { MChannelAccountDefault, MVideoAccountLightBlacklistAllFiles } from '../
34const searchRouter = express.Router() 35const searchRouter = express.Router()
35 36
36searchRouter.get('/videos', 37searchRouter.get('/videos',
38 openapiOperationDoc({ operationId: 'searchVideos' }),
37 paginationValidator, 39 paginationValidator,
38 setDefaultPagination, 40 setDefaultPagination,
39 videosSearchSortValidator, 41 videosSearchSortValidator,
@@ -45,6 +47,7 @@ searchRouter.get('/videos',
45) 47)
46 48
47searchRouter.get('/video-channels', 49searchRouter.get('/video-channels',
50 openapiOperationDoc({ operationId: 'searchChannels' }),
48 paginationValidator, 51 paginationValidator,
49 setDefaultPagination, 52 setDefaultPagination,
50 videoChannelsSearchSortValidator, 53 videoChannelsSearchSortValidator,
diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.ts
index 863a3d74c..e636f44f6 100644
--- a/server/controllers/api/users/token.ts
+++ b/server/controllers/api/users/token.ts
@@ -7,7 +7,7 @@ import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPa
7import { handleOAuthToken } from '@server/lib/auth/oauth' 7import { handleOAuthToken } from '@server/lib/auth/oauth'
8import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model' 8import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model'
9import { Hooks } from '@server/lib/plugins/hooks' 9import { Hooks } from '@server/lib/plugins/hooks'
10import { asyncMiddleware, authenticate } from '@server/middlewares' 10import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares'
11import { ScopedToken } from '@shared/models/users/user-scoped-token' 11import { ScopedToken } from '@shared/models/users/user-scoped-token'
12 12
13const tokensRouter = express.Router() 13const tokensRouter = express.Router()
@@ -19,10 +19,12 @@ const loginRateLimiter = RateLimit({
19 19
20tokensRouter.post('/token', 20tokensRouter.post('/token',
21 loginRateLimiter, 21 loginRateLimiter,
22 openapiOperationDoc({ operationId: 'getOAuthToken' }),
22 asyncMiddleware(handleToken) 23 asyncMiddleware(handleToken)
23) 24)
24 25
25tokensRouter.post('/revoke-token', 26tokensRouter.post('/revoke-token',
27 openapiOperationDoc({ operationId: 'revokeOAuthToken' }),
26 authenticate, 28 authenticate,
27 asyncMiddleware(handleTokenRevocation) 29 asyncMiddleware(handleTokenRevocation)
28) 30)
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts
index ca2b85ea5..530e17965 100644
--- a/server/controllers/api/videos/blacklist.ts
+++ b/server/controllers/api/videos/blacklist.ts
@@ -9,6 +9,7 @@ import {
9 authenticate, 9 authenticate,
10 blacklistSortValidator, 10 blacklistSortValidator,
11 ensureUserHasRight, 11 ensureUserHasRight,
12 openapiOperationDoc,
12 paginationValidator, 13 paginationValidator,
13 setBlacklistSort, 14 setBlacklistSort,
14 setDefaultPagination, 15 setDefaultPagination,
@@ -23,6 +24,7 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c
23const blacklistRouter = express.Router() 24const blacklistRouter = express.Router()
24 25
25blacklistRouter.post('/:videoId/blacklist', 26blacklistRouter.post('/:videoId/blacklist',
27 openapiOperationDoc({ operationId: 'addVideoBlock' }),
26 authenticate, 28 authenticate,
27 ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), 29 ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
28 asyncMiddleware(videosBlacklistAddValidator), 30 asyncMiddleware(videosBlacklistAddValidator),
@@ -30,6 +32,7 @@ blacklistRouter.post('/:videoId/blacklist',
30) 32)
31 33
32blacklistRouter.get('/blacklist', 34blacklistRouter.get('/blacklist',
35 openapiOperationDoc({ operationId: 'getVideoBlocks' }),
33 authenticate, 36 authenticate,
34 ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), 37 ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
35 paginationValidator, 38 paginationValidator,
@@ -48,6 +51,7 @@ blacklistRouter.put('/:videoId/blacklist',
48) 51)
49 52
50blacklistRouter.delete('/:videoId/blacklist', 53blacklistRouter.delete('/:videoId/blacklist',
54 openapiOperationDoc({ operationId: 'delVideoBlock' }),
51 authenticate, 55 authenticate,
52 ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), 56 ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST),
53 asyncMiddleware(videosBlacklistRemoveValidator), 57 asyncMiddleware(videosBlacklistRemoveValidator),