From 98e391b8675954c135aeaef8b520bf7676523878 Mon Sep 17 00:00:00 2001 From: Nick O'Leary <nick.oleary@gmail.com> Date: Mon, 7 Jan 2019 14:59:48 +0000 Subject: [PATCH] Add audit logging to admin api --- packages/node_modules/@node-red/editor-api/lib/util.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/node_modules/@node-red/editor-api/lib/util.js b/packages/node_modules/@node-red/editor-api/lib/util.js index 73c222e5c..8c6ad1d99 100644 --- a/packages/node_modules/@node-red/editor-api/lib/util.js +++ b/packages/node_modules/@node-red/editor-api/lib/util.js @@ -21,6 +21,8 @@ var i18n = require("@node-red/util").i18n; // TODO: separate module module.exports = { errorHandler: function(err,req,res,next) { + //TODO: why this when rejectHandler also?! + if (err.message === "request entity too large") { log.error(err); } else { @@ -39,6 +41,8 @@ module.exports = { return lang; }, rejectHandler: function(req,res,err) { + //TODO: why this when errorHandler also?! + log.audit({event: "api.error",error:err.code||"unexpected_error",message:err.message||err.toString()},req); res.status(err.status||500).json({ code: err.code||"unexpected_error", message: err.message||err.toString()