mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Add ability to search available plugins
This commit is contained in:
parent
503c6f440a
commit
6702a1b2cc
27 changed files with 513 additions and 81 deletions
|
@ -8,12 +8,13 @@ import {
|
|||
setDefaultPagination,
|
||||
setDefaultSort
|
||||
} from '../../middlewares'
|
||||
import { pluginsSortValidator } from '../../middlewares/validators'
|
||||
import { availablePluginsSortValidator, pluginsSortValidator } from '../../middlewares/validators'
|
||||
import { PluginModel } from '../../models/server/plugin'
|
||||
import { UserRight } from '../../../shared/models/users'
|
||||
import {
|
||||
existingPluginValidator,
|
||||
installOrUpdatePluginValidator,
|
||||
listAvailablePluginsValidator,
|
||||
listPluginsValidator,
|
||||
uninstallPluginValidator,
|
||||
updatePluginSettingsValidator
|
||||
|
@ -22,9 +23,22 @@ import { PluginManager } from '../../lib/plugins/plugin-manager'
|
|||
import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model'
|
||||
import { ManagePlugin } from '../../../shared/models/plugins/manage-plugin.model'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index'
|
||||
import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model'
|
||||
|
||||
const pluginRouter = express.Router()
|
||||
|
||||
pluginRouter.get('/available',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
listAvailablePluginsValidator,
|
||||
paginationValidator,
|
||||
availablePluginsSortValidator,
|
||||
setDefaultSort,
|
||||
setDefaultPagination,
|
||||
asyncMiddleware(listAvailablePlugins)
|
||||
)
|
||||
|
||||
pluginRouter.get('/',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
|
@ -88,10 +102,10 @@ export {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function listPlugins (req: express.Request, res: express.Response) {
|
||||
const type = req.query.type
|
||||
const pluginType = req.query.pluginType
|
||||
|
||||
const resultList = await PluginModel.listForApi({
|
||||
type,
|
||||
pluginType,
|
||||
start: req.query.start,
|
||||
count: req.query.count,
|
||||
sort: req.query.sort
|
||||
|
@ -160,3 +174,11 @@ async function updatePluginSettings (req: express.Request, res: express.Response
|
|||
|
||||
return res.sendStatus(204)
|
||||
}
|
||||
|
||||
async function listAvailablePlugins (req: express.Request, res: express.Response) {
|
||||
const query: PeertubePluginIndexList = req.query
|
||||
|
||||
const resultList = await listAvailablePluginsFromIndex(query)
|
||||
|
||||
return res.json(resultList)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue