X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fplugins.ts;h=de58a7350b37abffbdb67894b86af12a9af02b5b;hb=89cd12756035a146bbcc4db78cd3cd64f2f3d88d;hp=114cc49b6bd34ed6eb305a47884a32b73abd5418;hpb=6702a1b2ccd666285dee9c72b5bace641d2fce8b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index 114cc49b6..de58a7350 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts @@ -25,6 +25,7 @@ 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' +import { RegisteredSettings } from '../../../shared/models/plugins/register-setting.model' const pluginRouter = express.Router() @@ -103,9 +104,11 @@ export { async function listPlugins (req: express.Request, res: express.Response) { const pluginType = req.query.pluginType + const uninstalled = req.query.uninstalled const resultList = await PluginModel.listForApi({ pluginType, + uninstalled, start: req.query.start, count: req.query.count, sort: req.query.sort @@ -161,9 +164,9 @@ async function uninstallPlugin (req: express.Request, res: express.Response) { function getPluginRegisteredSettings (req: express.Request, res: express.Response) { const settings = PluginManager.Instance.getRegisteredSettings(req.params.npmName) - return res.json({ - settings - }) + const json: RegisteredSettings = { settings } + + return res.json(json) } async function updatePluginSettings (req: express.Request, res: express.Response) { @@ -180,5 +183,11 @@ async function listAvailablePlugins (req: express.Request, res: express.Response const resultList = await listAvailablePluginsFromIndex(query) + if (!resultList) { + return res.status(503) + .json({ error: 'Plugin index unavailable. Please retry later' }) + .end() + } + return res.json(resultList) }