@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 +1 -1
- package/src/common-hooks.mjs +1 -1
- package/src/context.mjs +2 -2
- package/src/server.mjs +8 -1
package/package.json
CHANGED
package/src/common-hooks.mjs
CHANGED
|
@@ -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
|
|
36
|
+
if (!userId) throw Error(`Not authenticated`)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export const isExpired = (delay) => async (context) => {
|
package/src/context.mjs
CHANGED
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
|
-
|
|
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) {
|