@jcbuisson/express-x 3.1.2 → 3.1.3

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 +3 -3
  2. package/src/server.mjs +8 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/server.mjs",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@electric-sql/pglite": "^0.4.5",
32
- "@jcbuisson/express-x-client": "^3.0.5",
33
- "@jcbuisson/express-x-drizzle": "^1.0.8",
32
+ "@jcbuisson/express-x-client": "^3.1.1",
33
+ "@jcbuisson/express-x-drizzle": "^1.0.9",
34
34
  "@vueuse/core": "^14.3.0",
35
35
  "dexie": "^4.4.2",
36
36
  "drizzle-orm": "^0.45.2",
package/src/server.mjs CHANGED
@@ -134,7 +134,7 @@ export function expressX(config) {
134
134
  path: config?.WS_PATH || '/socket.io/',
135
135
  connectionStateRecovery: {
136
136
  // the backup duration of the sessions and the packets
137
- maxDisconnectionDuration: 2 * 60 * 1000,
137
+ maxDisconnectionDuration: config?.maxDisconnectionDuration ?? 2 * 60 * 1000,
138
138
  // whether to skip middlewares upon successful recovery
139
139
  skipMiddlewares: true,
140
140
  }
@@ -346,7 +346,7 @@ export function expressX(config) {
346
346
  function service(name) {
347
347
  // get service from `services` cache
348
348
  if (name in services) return services[name]
349
- app.log('error', `there is no service named '${name}'`, 'missing-service')
349
+ throw new EXError('missing-service', `there is no service named '${name}'`)
350
350
  }
351
351
 
352
352
  function joinChannel(channelName, socket) {
@@ -402,8 +402,12 @@ export const addTimestamp = (field) => async (context) => {
402
402
  * Hash password of the property `field`
403
403
  */
404
404
  export const hashPassword = (passwordField) => async (context) => {
405
- const user = context.result
406
- user[passwordField] = await bcrypt.hash(user[passwordField], 5)
405
+ for (const arg of (context.args || [])) {
406
+ if (arg && typeof arg === 'object' && !Array.isArray(arg) && passwordField in arg) {
407
+ arg[passwordField] = await bcrypt.hash(arg[passwordField], 5)
408
+ return
409
+ }
410
+ }
407
411
  }
408
412
 
409
413
  /*