+const listAvailablePluginsValidator = [
+ query('search')
+ .optional()
+ .exists().withMessage('Should have a valid search'),
+ query('pluginType')
+ .optional()
+ .customSanitizer(toIntOrNull)
+ .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
+ query('currentPeerTubeEngine')
+ .optional()
+ .custom(isPluginVersionValid).withMessage('Should have a valid current peertube engine'),
+
+ (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking enabledPluginValidator parameters', { parameters: req.query })
+
+ if (areValidationErrors(req, res)) return
+
+ if (CONFIG.PLUGINS.INDEX.ENABLED === false) {
+ return res.status(HttpStatusCode.BAD_REQUEST_400)
+ .json({ error: 'Plugin index is not enabled' })
+ .end()
+ }
+
+ return next()
+ }
+]
+