@rpcbase/server 0.32.0 → 0.35.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.
@@ -29,8 +29,13 @@ const start_server = async() => {
29
29
 
30
30
  const cmd = `docker-compose --env-file ${env_path} -p ${proj_prefix} ${compose_files.join(" ")} up --build --remove-orphans`
31
31
 
32
- console.log("RUN", cmd)
33
- execSync(cmd, {stdio: "inherit", cwd: infrastructure_dir})
32
+ console.log(cmd)
33
+ try {
34
+ execSync(cmd, {stdio: "inherit", cwd: infrastructure_dir})
35
+ } catch (err) {
36
+ console.log("start_server::error\n", err)
37
+ process.exit(1)
38
+ }
34
39
 
35
40
  }
36
41
 
package/database.js CHANGED
@@ -2,7 +2,7 @@
2
2
  const mongoose = require("mongoose")
3
3
  const validator = require("validator")
4
4
 
5
- const {DATABASE_PORT, DATABASE_NAME} = process.env
5
+ const {DATABASE_NAME} = process.env
6
6
 
7
7
  if (typeof DATABASE_PORT === "string" && !validator.isPort(DATABASE_PORT)) {
8
8
  throw new Error("expected DATABASE_PORT to be a valid port number")
@@ -12,11 +12,17 @@ if (typeof DATABASE_NAME !== "string") {
12
12
  throw new Error("expected DATABASE_NAME to be a string")
13
13
  }
14
14
 
15
- const mongo_url = `mongodb://database:${DATABASE_PORT}/${DATABASE_NAME}`
15
+ const replicaset_str = [0, 1, 2].map((i) => `database${i}:${process.env["DATABASE_PORT_" + i]}`)
16
+ .join(",")
17
+
18
+ console.log("db connection str:", replicaset_str)
19
+
20
+ const mongo_url = `mongodb://${replicaset_str}/${DATABASE_NAME}?`
21
+ + `replicaSet=rs0&readPreference=secondary`
16
22
 
17
23
  module.exports = async() => {
18
- console.log("setup DB", mongo_url)
24
+ console.log("mongo_url", mongo_url)
19
25
  const ret = await mongoose.connect(mongo_url)
20
- // TODO: handle connection ret
21
- // console.log(ret)
26
+ console.log("waiting after return", ret)
27
+ // TODO: handle connection retry and pools
22
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.32.0",
3
+ "version": "0.35.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -10,14 +10,14 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 0"
11
11
  },
12
12
  "dependencies": {
13
- "body-parser": "1.19.1",
14
- "connect-redis": "6.0.0",
13
+ "body-parser": "1.19.2",
14
+ "connect-redis": "6.1.1",
15
15
  "cors": "2.8.5",
16
- "dotenv": "10.0.0",
17
- "express": "4.17.2",
16
+ "dotenv": "16.0.0",
17
+ "express": "4.17.3",
18
18
  "express-session": "1.17.2",
19
19
  "glob": "7.2.0",
20
- "mongoose": "6.1.5",
20
+ "mongoose": "6.2.4",
21
21
  "redis": "3.1.2",
22
22
  "validator": "13.7.0",
23
23
  "yargs": "17.3.1"