UNPKG

json-object-editor

Version:

JOE the Json Object Editor | Platform Edition

46 lines (37 loc) 1.19 kB
function PluginUtils(){ var self = this; function getPluginList(){ const plugins = {} for(var plug in JOE.Apps.plugins){ let plugin = JOE.Apps.plugins[plug]; plugins[plug]={ name:plug, protected:plugin.protected, async:Object.keys(plugin.async||{}), _pathname:plugin._pathname, _override:plugin._override, } }; return plugins; } this.default = function(data,req,res){ // list the plugins that are available const plugins = getPluginList(); try{ var payload = { params:req.params, data:data, plugins:plugins } }catch(e){ return {errors:'plugin error: '+e,failedat:'plugin'}; } return payload; }; this.html = function(data,req,res){ return JSON.stringify(self.default(data,req),'','\t\r\n <br/>'); } this.protected = []; return self; } module.exports = new PluginUtils();