@jcbuisson/express-x 1.5.12 → 1.5.14

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.12",
3
+ "version": "1.5.14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
@@ -33,7 +33,7 @@ export async function isAuthenticated(context) {
33
33
  if (context.transport !== 'ws') return
34
34
  // extract userId from connection data
35
35
  const userId = await getConnectionDataItem(context, 'userId')
36
- if (!userId) throw Error(`Not authenticated, userId ${userId}`)
36
+ if (!userId) throw Error(`Not authenticated`)
37
37
  }
38
38
 
39
39
  export const isExpired = (delay) => async (context) => {
package/src/context.mjs CHANGED
@@ -11,8 +11,8 @@ export async function resetConnection(context) {
11
11
  where: { id },
12
12
  data: {
13
13
  clientIP: '',
14
- data: "{}",
15
- data: { channelNames: '[]' },
14
+ data: '{}',
15
+ channelNames: '[]',
16
16
  }
17
17
  })
18
18
  }
package/src/server.mjs CHANGED
@@ -20,7 +20,14 @@ export function expressX(prisma, options = {}) {
20
20
  const cnx2Socket = {}
21
21
 
22
22
  function createConnection(clientIP) {
23
- return app.service('Connection').create({ data: { clientIP }})
23
+ const now = new Date();
24
+ const expirationTime = new Date(now.getTime() + 15 * 60000)
25
+ return app.service('Connection').create({
26
+ data: {
27
+ clientIP,
28
+ expirationTime,
29
+ }
30
+ })
24
31
  }
25
32
 
26
33
  function getConnection(id) {