-import * as express from 'express'
+import express from 'express'
import { logger } from '@server/helpers/logger'
import { getFormattedObjects } from '@server/helpers/utils'
import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index'
authenticate,
availablePluginsSortValidator,
ensureUserHasRight,
+ openapiOperationDoc,
paginationValidator,
pluginsSortValidator,
setDefaultPagination,
updatePluginSettingsValidator
} from '@server/middlewares/validators/plugins'
import { PluginModel } from '@server/models/server/plugin'
-import { HttpStatusCode } from '@shared/core-utils'
import {
+ HttpStatusCode,
InstallOrUpdatePlugin,
ManagePlugin,
PeertubePluginIndexList,
const pluginRouter = express.Router()
pluginRouter.get('/available',
+ openapiOperationDoc({ operationId: 'getAvailablePlugins' }),
authenticate,
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
listAvailablePluginsValidator,
)
pluginRouter.get('/',
+ openapiOperationDoc({ operationId: 'getPlugins' }),
authenticate,
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
listPluginsValidator,
)
pluginRouter.post('/install',
+ openapiOperationDoc({ operationId: 'addPlugin' }),
authenticate,
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
installOrUpdatePluginValidator,
)
pluginRouter.post('/update',
+ openapiOperationDoc({ operationId: 'updatePlugin' }),
authenticate,
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
installOrUpdatePluginValidator,
)
pluginRouter.post('/uninstall',
+ openapiOperationDoc({ operationId: 'uninstallPlugin' }),
authenticate,
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
uninstallPluginValidator,
const fromDisk = !!body.path
const toInstall = body.npmName || body.path
+
+ const pluginVersion = body.pluginVersion && body.npmName
+ ? body.pluginVersion
+ : undefined
+
try {
- const plugin = await PluginManager.Instance.install(toInstall, undefined, fromDisk)
+ const plugin = await PluginManager.Instance.install(toInstall, pluginVersion, fromDisk)
return res.json(plugin.toFormattedJSON())
} catch (err) {