1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00
node-red/packages/node_modules/@node-red/editor-api/lib/admin/diagnostics.js

24 lines
826 B
JavaScript
Raw Normal View History

2022-03-28 19:49:56 +02:00
let runtimeAPI;
let settings;
const apiUtil = require("../util");
2022-03-24 17:00:45 +01:00
module.exports = {
2022-03-28 19:49:56 +02:00
init: function(_settings, _runtimeAPI) {
settings = _settings;
2022-03-24 17:00:45 +01:00
runtimeAPI = _runtimeAPI;
},
2022-03-28 19:49:56 +02:00
getReport: function(req, res) {
const diagnosticsOpts = settings.diagnostics || {};
2022-03-28 19:49:56 +02:00
const opts = {
2022-03-24 17:00:45 +01:00
user: req.user,
scope: diagnosticsOpts.level || "basic"
2022-03-24 17:00:45 +01:00
}
if(diagnosticsOpts.enabled === false || diagnosticsOpts.enabled === "false") {
2022-04-06 16:11:03 +02:00
apiUtil.rejectHandler(req, res, {message: "diagnostics are disabled", status: 403, code: "diagnostics.disabled" })
2022-03-28 19:49:56 +02:00
} else {
runtimeAPI.diagnostics.get(opts)
.then(function(result) { res.json(result); })
.catch(err => apiUtil.rejectHandler(req, res, err))
2022-03-24 17:00:45 +01:00
}
}
}