From 0ca0ea804cc0388004cceb2ff0c50b89c797de50 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Jan 2024 10:51:24 +0100 Subject: [PATCH] refs #5878 feat mapMethods approach --- loopback/server/middleware/error-handler.js | 7 ++++--- loopback/util/map-methods.js | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 loopback/util/map-methods.js diff --git a/loopback/server/middleware/error-handler.js b/loopback/server/middleware/error-handler.js index e274396a6..10c0bc635 100644 --- a/loopback/server/middleware/error-handler.js +++ b/loopback/server/middleware/error-handler.js @@ -1,12 +1,13 @@ -const UserError = require('../../util/user-error'); +const UserError = require('vn-loopback/util/user-error'); const logToConsole = require('strong-error-handler/lib/logger'); const valueIsNot = require('./value-is-not'); const valueInvalid = require('./value-invalid'); - +const mapMethods = require('vn-loopback/util/map-methods') const validations = [ valueIsNot, - valueInvalid + valueInvalid, + mapMethods ]; module.exports = function() { return function(err, req, res, next) { diff --git a/loopback/util/map-methods.js b/loopback/util/map-methods.js new file mode 100644 index 000000000..2858cd61d --- /dev/null +++ b/loopback/util/map-methods.js @@ -0,0 +1,12 @@ +const SLASH = '/'; +const MODULES = 'modules'; +const BACK = 'back'; + +const app = require('vn-loopback/server/server'); + +const modelsMethods = app; +function keyMap(model, local, connector = '_') { + return `${model}${connector}${local}`; +} +module.exports = modelsMethods; +