@jcbuisson/express-x 1.5.26 → 1.5.27

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x",
3
- "version": "1.5.26",
3
+ "version": "1.5.27",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
@@ -2,7 +2,7 @@
2
2
  import config from 'config'
3
3
  import bcrypt from 'bcryptjs'
4
4
 
5
- import { getConnectionDataItem } from './context.mjs'
5
+ import { getConnectionDataItem, resetConnection } from './context.mjs'
6
6
 
7
7
 
8
8
  // hash password of user record
@@ -40,5 +40,10 @@ export const isNotExpired = (delay) => async (context) => {
40
40
  if (context.transport !== 'ws') return
41
41
  const expireAt = await getConnectionDataItem(context, 'expireAt')
42
42
  const now = new Date()
43
- if (expireAt > now) throw new Error('session expired')
43
+ if (expireAt > now) {
44
+ // clear connection data
45
+ await resetConnection(context)
46
+ // throw exception
47
+ throw new Error('session expired')
48
+ }
44
49
  }
package/src/context.mjs CHANGED
@@ -10,7 +10,6 @@ export async function resetConnection(context) {
10
10
  await context.app.prisma.Connection.update({
11
11
  where: { id },
12
12
  data: {
13
- clientIP: '',
14
13
  data: '{}',
15
14
  channelNames: '[]',
16
15
  }
package/src/server.mjs CHANGED
@@ -384,10 +384,10 @@ export function expressX(prisma, options = {}) {
384
384
  app.log('verbose', `publish channels ${service.name} ${action} ${channelNames}`)
385
385
  for (const channelName of channelNames) {
386
386
  app.log('verbose', `service-event ${service.name} ${action} ${channelName}`)
387
- const connectionList = getChannelConnections(channelName)
387
+ const connectionList = await getChannelConnections(channelName)
388
388
  for (const connection of connectionList) {
389
389
  app.log('verbose', `emit to ${connection.id} ${service.name} ${action} ${result}`)
390
- const socket = cnx2Socket(connection.id)
390
+ const socket = cnx2Socket[connection.id]
391
391
  socket.emit('service-event', {
392
392
  name: service.name,
393
393
  action,