@jcbuisson/express-x 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.mjs +5 -2
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -79,7 +79,7 @@ function expressX(app) {
|
|
|
79
79
|
|
|
80
80
|
// `context` is the context of execution (transport type, connection, app)
|
|
81
81
|
// `args` is the list of arguments of the method
|
|
82
|
-
|
|
82
|
+
const hookedMethod = async (context, ...args) => {
|
|
83
83
|
context.args = args
|
|
84
84
|
|
|
85
85
|
// if a hook or the method throws an error, it will be caught by `socket.on('client-request'`
|
|
@@ -105,8 +105,11 @@ function expressX(app) {
|
|
|
105
105
|
return result
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
// hooked version of method, used by client calls
|
|
109
|
+
service['__' + methodName] = hookedMethod
|
|
110
|
+
|
|
108
111
|
// hooked version of method: `create`, etc., to be called from backend with no context
|
|
109
|
-
service[methodName] =
|
|
112
|
+
service[methodName] = async (...args) => await hookedMethod({}, ...args)
|
|
110
113
|
|
|
111
114
|
// un-hooked version of method: `_create`, etc., to be called from backend with no context
|
|
112
115
|
service['_' + methodName] = method
|