@jcbuisson/express-x 1.5.16 → 1.5.18

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.16",
3
+ "version": "1.5.18",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
package/src/context.mjs CHANGED
@@ -49,3 +49,9 @@ export async function removeConnectionDataItem(context, key) {
49
49
  }
50
50
  })
51
51
  }
52
+
53
+ export function sendEventToClient(context, type, value) {
54
+ const id = context.params.connectionId
55
+ const socket = context.app.cnx2Socket
56
+ socket.emit(type, value)
57
+ }
package/src/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { expressX } from './server.mjs'
3
3
  import { hashPassword, protect, isAuthenticated } from './common-hooks.mjs'
4
- import { getContextConnection, resetConnection, getConnectionDataItem, setConnectionDataItem, removeConnectionDataItem } from './context.mjs'
4
+ import { getContextConnection, resetConnection, getConnectionDataItem, setConnectionDataItem, removeConnectionDataItem, sendEventToClient } from './context.mjs'
5
5
 
6
6
  export {
7
7
  expressX,
@@ -12,6 +12,8 @@ export {
12
12
  getConnectionDataItem,
13
13
  setConnectionDataItem,
14
14
  removeConnectionDataItem,
15
+
16
+ sendEventToClient,
15
17
 
16
18
  hashPassword,
17
19
  protect,
package/src/server.mjs CHANGED
@@ -18,12 +18,9 @@ export function expressX(prisma, options = {}) {
18
18
  const cnx2Socket = {}
19
19
 
20
20
  async function createConnection(clientIP) {
21
- const now = new Date();
22
- const expirationTime = new Date(now.getTime() + 15 * 60000)
23
21
  const connection = await app.service('Connection').create({
24
22
  data: {
25
23
  clientIP,
26
- expirationTime,
27
24
  }
28
25
  })
29
26
  return connection
@@ -40,7 +37,6 @@ export function expressX(prisma, options = {}) {
40
37
  clientIP: connection.clientIP,
41
38
  channelNames: connection.channelNames,
42
39
  data: connection.data,
43
- expirationTime: connection.expirationTime,
44
40
  }
45
41
  })
46
42
  }
@@ -439,6 +435,7 @@ export function expressX(prisma, options = {}) {
439
435
  // enhance `app` with objects and methods
440
436
  return Object.assign(app, {
441
437
  options,
438
+ cnx2Socket,
442
439
  createDatabaseService,
443
440
  createService,
444
441
  service,