mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
24 lines
826 B
JavaScript
24 lines
826 B
JavaScript
let runtimeAPI;
|
|
let settings;
|
|
const apiUtil = require("../util");
|
|
module.exports = {
|
|
init: function(_settings, _runtimeAPI) {
|
|
settings = _settings;
|
|
runtimeAPI = _runtimeAPI;
|
|
},
|
|
getReport: function(req, res) {
|
|
const diagnosticsOpts = settings.diagnostics || {};
|
|
const opts = {
|
|
user: req.user,
|
|
scope: diagnosticsOpts.level || "basic"
|
|
}
|
|
if(diagnosticsOpts.enabled === false || diagnosticsOpts.enabled === "false") {
|
|
apiUtil.rejectHandler(req, res, {message: "diagnostics are disabled", status: 403, code: "diagnostics.disabled" })
|
|
} else {
|
|
runtimeAPI.diagnostics.get(opts)
|
|
.then(function(result) { res.json(result); })
|
|
.catch(err => apiUtil.rejectHandler(req, res, err))
|
|
}
|
|
}
|
|
}
|