var configRegistry = require('./../../../config-registry'); module.exports = (function () { var createPluginInfo = function() { var result = {}; for (var pluginIdx in configRegistry.getMasterConfig().plugins) { var plugin = configRegistry.getMasterConfig().plugins[pluginIdx]; var pluginExtensions = Object.keys(plugin).slice(0,-1); //TODO: pluginExtensions.remove('tmeta'); var pluginData = { extensions: pluginExtensions, tmeta: plugin.tmeta, troutes: plugin.troutes }; result[plugin.tmeta.key] = pluginData; } return result; }; var createPluginKeyList = function() { var result = []; for (var pluginIdx in configRegistry.getMasterConfig().plugins) { var plugin = configRegistry.getMasterConfig().plugins[pluginIdx]; result.push(plugin.tmeta.key); } return result; }; return function ServerInfoPluginsPlugin() { this.configPlugin = function (ctx) { ctx.key='serverInfoPlugins'; ctx.description='Makes the server plugins info public as json'; ctx.localDir = __dirname; ctx.localConfigTemplate = 'info-plugins.json'; }; this.configServer = function(ctx) { ctx.server.get(ctx.createSlugApiServerBase(),ctx.renderFunctionJSON(function () { return { plugins: { keys: { registrated: createPluginKeyList(), backends: Object.keys(configRegistry.getMasterConfig().backends), validators: Object.keys(configRegistry.getMasterConfig().validators) }, info: createPluginInfo() } } })); }; }; })();