aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/plugins.ts27
1 files changed, 20 insertions, 7 deletions
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index 89cc67f54..f17e8cab9 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -12,7 +12,7 @@ import { pluginsSortValidator } from '../../middlewares/validators'
12import { PluginModel } from '../../models/server/plugin' 12import { PluginModel } from '../../models/server/plugin'
13import { UserRight } from '../../../shared/models/users' 13import { UserRight } from '../../../shared/models/users'
14import { 14import {
15 enabledPluginValidator, 15 existingPluginValidator,
16 installPluginValidator, 16 installPluginValidator,
17 listPluginsValidator, 17 listPluginsValidator,
18 uninstallPluginValidator, 18 uninstallPluginValidator,
@@ -35,18 +35,25 @@ pluginRouter.get('/',
35 asyncMiddleware(listPlugins) 35 asyncMiddleware(listPlugins)
36) 36)
37 37
38pluginRouter.get('/:pluginName/settings', 38pluginRouter.get('/:npmName',
39 authenticate, 39 authenticate,
40 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 40 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
41 asyncMiddleware(enabledPluginValidator), 41 asyncMiddleware(existingPluginValidator),
42 asyncMiddleware(listPluginSettings) 42 getPlugin
43) 43)
44 44
45pluginRouter.put('/:pluginName/settings', 45pluginRouter.get('/:npmName/registered-settings',
46 authenticate,
47 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
48 asyncMiddleware(existingPluginValidator),
49 asyncMiddleware(getPluginRegisteredSettings)
50)
51
52pluginRouter.put('/:npmName/settings',
46 authenticate, 53 authenticate,
47 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 54 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
48 updatePluginSettingsValidator, 55 updatePluginSettingsValidator,
49 asyncMiddleware(enabledPluginValidator), 56 asyncMiddleware(existingPluginValidator),
50 asyncMiddleware(updatePluginSettings) 57 asyncMiddleware(updatePluginSettings)
51) 58)
52 59
@@ -85,6 +92,12 @@ async function listPlugins (req: express.Request, res: express.Response) {
85 return res.json(getFormattedObjects(resultList.data, resultList.total)) 92 return res.json(getFormattedObjects(resultList.data, resultList.total))
86} 93}
87 94
95function getPlugin (req: express.Request, res: express.Response) {
96 const plugin = res.locals.plugin
97
98 return res.json(plugin.toFormattedJSON())
99}
100
88async function installPlugin (req: express.Request, res: express.Response) { 101async function installPlugin (req: express.Request, res: express.Response) {
89 const body: InstallPlugin = req.body 102 const body: InstallPlugin = req.body
90 103
@@ -101,7 +114,7 @@ async function uninstallPlugin (req: express.Request, res: express.Response) {
101 return res.sendStatus(204) 114 return res.sendStatus(204)
102} 115}
103 116
104async function listPluginSettings (req: express.Request, res: express.Response) { 117async function getPluginRegisteredSettings (req: express.Request, res: express.Response) {
105 const plugin = res.locals.plugin 118 const plugin = res.locals.plugin
106 119
107 const settings = await PluginManager.Instance.getSettings(plugin.name) 120 const settings = await PluginManager.Instance.getSettings(plugin.name)