@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +5 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
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
- service['__' + methodName] = async (context, ...args) => {
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] = method
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