mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
27
packages/node_modules/@node-red/editor-api/lib/admin/diagnostics.js
vendored
Normal file
27
packages/node_modules/@node-red/editor-api/lib/admin/diagnostics.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var apiUtils = require("@node-red/editor-api/lib/util");
|
||||
/** @type {runtime.RuntimeModule} */var runtimeAPI;
|
||||
|
||||
|
||||
module.exports = {
|
||||
init: function(/** @type {runtime.RuntimeModule} */_runtimeAPI) {
|
||||
runtimeAPI = _runtimeAPI;
|
||||
},
|
||||
getBasicReport: function(req, res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
scope: "basic"
|
||||
}
|
||||
runtimeAPI.diagnostics.get(opts).then(function(result) {
|
||||
res.json(result);
|
||||
});
|
||||
},
|
||||
getAdminReport: function(req, res) {
|
||||
var opts = {
|
||||
user: req.user,
|
||||
scope: "admin"
|
||||
}
|
||||
runtimeAPI.diagnostics.get(opts).then(function(result) {
|
||||
res.json(result);
|
||||
});
|
||||
}
|
||||
}
|
@@ -23,6 +23,7 @@ var context = require("./context");
|
||||
var auth = require("../auth");
|
||||
var info = require("./settings");
|
||||
var plugins = require("./plugins");
|
||||
var diagnostics = require("./diagnostics");
|
||||
|
||||
var apiUtil = require("../util");
|
||||
|
||||
@@ -34,6 +35,7 @@ module.exports = {
|
||||
context.init(runtimeAPI);
|
||||
info.init(settings,runtimeAPI);
|
||||
plugins.init(runtimeAPI);
|
||||
diagnostics.init(runtimeAPI);
|
||||
|
||||
var needsPermission = auth.needsPermission;
|
||||
|
||||
@@ -95,6 +97,9 @@ module.exports = {
|
||||
adminApp.get("/plugins", needsPermission("plugins.read"), plugins.getAll, apiUtil.errorHandler);
|
||||
adminApp.get("/plugins/messages", needsPermission("plugins.read"), plugins.getCatalogs, apiUtil.errorHandler);
|
||||
|
||||
adminApp.get("/diagnostics/basic", needsPermission("settings.read"), diagnostics.getBasicReport, apiUtil.errorHandler);
|
||||
adminApp.get("/diagnostics/admin", needsPermission("flows.write"), diagnostics.getAdminReport, apiUtil.errorHandler);
|
||||
|
||||
return adminApp;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user