@rpcbase/server 0.35.0 → 0.36.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/database.js CHANGED
@@ -23,6 +23,6 @@ const mongo_url = `mongodb://${replicaset_str}/${DATABASE_NAME}?`
23
23
  module.exports = async() => {
24
24
  console.log("mongo_url", mongo_url)
25
25
  const ret = await mongoose.connect(mongo_url)
26
- console.log("waiting after return", ret)
26
+ // console.log("waiting after return", ret)
27
27
  // TODO: handle connection retry and pools
28
28
  }
@@ -1,9 +1,11 @@
1
1
  /* @flow */
2
2
  const session = require("express-session")
3
- const redis = require("redis")
3
+ // const redis = require("redis")
4
4
  const validator = require("validator")
5
5
  const redis_store = require("connect-redis")(session)
6
6
 
7
+ const { createClient } = require("redis")
8
+
7
9
 
8
10
  const {SESSION_STORE_PORT} = process.env
9
11
 
@@ -13,12 +15,42 @@ if (typeof SESSION_STORE_PORT === "string" && !validator.isPort(SESSION_STORE_PO
13
15
 
14
16
  const session_store_url = `redis://session-store:${SESSION_STORE_PORT}`
15
17
 
16
- const redis_client = redis.createClient({
17
- url: session_store_url
18
+ console.log("will connect to session-store", session_store_url)
19
+
20
+
21
+ const reconnectStrategy = (retries) => {
22
+ console.log("retrying with arg", retries)
23
+ if (retries < 5) {
24
+ console.log("retry count:", retries, "retrying in 1s")
25
+ return 1000
26
+ } else {
27
+ return new Error("max retries expiered")
28
+ }
29
+ }
30
+
31
+
32
+
33
+ let redisClient = createClient({
34
+ socket: {reconnectStrategy},
35
+ url: session_store_url,
36
+ legacyMode: true,
18
37
  })
19
38
 
39
+ redisClient.connect()
40
+ .catch((err) => {
41
+ console.log("session store error ohh", err)
42
+ })
43
+ .then(() => {
44
+ console.log("REDIS CONNECTED OW")
45
+ })
46
+
47
+ // const redis_client = redis.createClient({
48
+ // url: session_store_url
49
+ // })
50
+
20
51
  const session_middleware = session({
21
- store: new redis_store({client: redis_client}),
52
+ // store: new redis_store({client: redis_client}),
53
+ store: new redis_store({client: redisClient}),
22
54
  proxy: true,
23
55
  saveUninitialized: false,
24
56
  // TODO: fix session secret
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -18,7 +18,7 @@
18
18
  "express-session": "1.17.2",
19
19
  "glob": "7.2.0",
20
20
  "mongoose": "6.2.4",
21
- "redis": "3.1.2",
21
+ "redis": "4.0.4",
22
22
  "validator": "13.7.0",
23
23
  "yargs": "17.3.1"
24
24
  }