@rpcbase/server 0.51.0 → 0.54.0

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": "@rpcbase/server",
3
- "version": "0.51.0",
3
+ "version": "0.54.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -14,14 +14,14 @@
14
14
  "connect-redis": "6.1.3",
15
15
  "cors": "2.8.5",
16
16
  "debug": "4.3.4",
17
- "dotenv": "16.0.0",
17
+ "dotenv": "16.0.1",
18
18
  "express": "4.18.1",
19
- "express-session": "1.17.2",
20
- "glob": "8.0.1",
21
- "mongoose": "6.3.2",
19
+ "express-session": "1.17.3",
20
+ "glob": "8.0.3",
21
+ "mongoose": "6.3.4",
22
22
  "postmark": "3.0.1",
23
23
  "redis": "4.1.0",
24
24
  "validator": "13.7.0",
25
- "yargs": "17.4.1"
25
+ "yargs": "17.5.1"
26
26
  }
27
27
  }
@@ -1,75 +0,0 @@
1
- /* @flow */
2
- const session = require("express-session")
3
- const validator = require("validator")
4
- const {createClient} = require("redis")
5
- const redis_store = require("connect-redis")(session)
6
-
7
- // WARNING:
8
- // https://stackoverflow.com/questions/70867229/error-connection-timeout-when-connecting-to-redis-docker-instance
9
- // https://github.com/redis/node-redis/issues/1656/
10
-
11
- const {SESSION_STORE_PORT, SESSION_STORE_HOST} = process.env
12
-
13
-
14
- // extreme warning: when there is blocking io redis client won't connect
15
- // process.nextTick(() => {
16
- // redis_client.connect()
17
- // .catch((err) => {
18
- // console.log("session store error ohh", err)
19
- // })
20
- // .then(() => {
21
- // console.log("redis session-store connected port:", SESSION_STORE_PORT)
22
- // })
23
- // })
24
-
25
-
26
- module.exports = () => new Promise((resolve, reject) => {
27
-
28
- if (!SESSION_STORE_PORT) {
29
- return resolve((req, res, next) => next())
30
- }
31
-
32
- if (typeof SESSION_STORE_PORT === "string" && !validator.isPort(SESSION_STORE_PORT)) {
33
- throw new Error("expected SESSION_STORE_PORT to be a valid port number")
34
- }
35
-
36
- setTimeout(async() => {
37
- const reconnectStrategy = (retries) => {
38
- console.log("redis_client::reconnectStrategy::retrying with arg", retries)
39
- if (retries < 5) {
40
- console.log("retry count:", retries, "retrying in 1s")
41
- return 4000
42
- } else {
43
- return new Error("max retries expiered")
44
- }
45
- }
46
-
47
- const redis_client = createClient({
48
- socket: {
49
- host: SESSION_STORE_HOST,
50
- port: SESSION_STORE_PORT,
51
- reconnectStrategy,
52
- connectTimeout: 10000,
53
- keepAlive: 0,
54
- },
55
- legacyMode: true,
56
- })
57
-
58
- console.log("redis session willconnect")
59
- await redis_client.connect()
60
- console.log("redis session connected")
61
-
62
- const session_middleware = session({
63
- store: new redis_store({client: redis_client}),
64
- proxy: true,
65
- saveUninitialized: false,
66
- // TODO: use session secret from env
67
- secret: "session secret wowow",
68
- resave: false,
69
- })
70
-
71
- resolve(session_middleware)
72
-
73
- }, 100)
74
-
75
- })