2
0
Fork 0
tcrud/lib/plugin/server/debug.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-06-10 14:53:29 +00:00
var configRegistry = require('./../../config-registry');
module.exports = (function () {
var masterDebug = function(ctx,modelName,modelType,model) {
ctx.server.get(
ctx.createSlugApiServerBase('master')+
'/'+modelName+
'/'+modelType
,ctx.renderFunctionJSON(function() {
var result = {};
result[modelName] = model;
return result;
})
);
};
return function ServerDebugPlugin() {
this.configPlugin = function (ctx) {
ctx.key = 'serverDebug';
ctx.description = 'Exports some debug data.';
ctx.localDir = __dirname;
ctx.localConfigTemplate = 'debug.json';
};
this.configServer = function(ctx) {
var mt = configRegistry.getMasterTemplates();
masterDebug(ctx,'tfield', 'template', mt.masterTFieldTemplate);
masterDebug(ctx,'tfield', 'thelp', mt.masterTFieldTHelp);
masterDebug(ctx,'tentity', 'template', mt.masterTEntityTemplate);
masterDebug(ctx,'tentity', 'thelp', mt.masterTEntityTHelp);
masterDebug(ctx,'tview', 'template', mt.masterTViewTemplate);
masterDebug(ctx,'tview', 'thelp', mt.masterTViewTHelp);
// todo: TypeError: Converting circular structure to JSON
//ctx.server.get(ctx.createSlugApiServerBase('config/root-tentity'),this.renderFunction(function() {
// return configRegistry.rootTEntity;
//}));
};
};
})();