@rpcbase/server 0.45.0 → 0.46.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
@@ -15,22 +15,22 @@ if (typeof DATABASE_NAME !== "string") {
15
15
  const replicaset_str = [0, 1, 2].map((i) => `database${i}:${process.env["DATABASE_PORT_" + i]}`)
16
16
  .join(",")
17
17
 
18
- console.log("db connection str:", replicaset_str)
18
+ const mongo_url = `mongodb://${replicaset_str}/${DATABASE_NAME}`
19
+ // &readPreference=secondary
19
20
 
20
- const mongo_url = `mongodb://${replicaset_str}/${DATABASE_NAME}?`
21
- + `replicaSet=rs0`
22
-
23
- // &readPreference=secondary
24
21
 
25
22
  module.exports = async() => {
26
- console.log("MONGO_URL", mongo_url)
23
+ console.log("mongo_url", mongo_url)
24
+
27
25
  const ret = await mongoose.connect(mongo_url, {
26
+ replicaSet: "rs0",
28
27
  keepAlive: true,
29
- keepAliveInitialDelay: 10000,
28
+ keepAliveInitialDelay: 5000,
30
29
  minPoolSize: 3,
30
+ serverSelectionTimeoutMS: 5000,
31
+ family: 4, // force ipv4
31
32
  })
32
33
 
33
- // mongoose.connection.on("")
34
34
  mongoose.connection.on("disconnected", (arg) => {
35
35
  console.log("Mongoose disconnected", arg)
36
36
  })
@@ -39,7 +39,6 @@ module.exports = async() => {
39
39
  console.log("Mongoose connection error", arg)
40
40
  })
41
41
 
42
- // console.log("Mongoose connect got ret", ret)
43
- // console.log("waiting after return", ret)
44
- // TODO: handle connection retry and pools
42
+
43
+
45
44
  }
package/express/index.js CHANGED
@@ -38,11 +38,11 @@ module.exports = () => {
38
38
  // local dev origins
39
39
  [
40
40
  `http://localhost:${CLIENT_PORT}`,
41
+ // WARNING: hardcoded port
41
42
  "http://localhost:8090", // TMP: used by client of admin
42
43
  "localhost",
43
44
  ]
44
45
 
45
- // console.log("SETUP CORS", cors_origins)
46
46
 
47
47
  app.use(cors({
48
48
  origin: cors_origins,
package/mailer/index.js CHANGED
@@ -1,8 +1,20 @@
1
1
  /* @flow */
2
2
  const postmark = require("postmark")
3
3
 
4
- const {POSTMARK_API_KEY} = process.env
4
+ const {POSTMARK_API_KEY, IS_PRODUCTION} = process.env
5
5
 
6
- const client = new postmark.ServerClient(POSTMARK_API_KEY)
6
+ const is_production = IS_PRODUCTION === "yes"
7
+
8
+ let client
9
+
10
+ if (is_production) {
11
+ client = new postmark.ServerClient(POSTMARK_API_KEY)
12
+ } else {
13
+ client = {
14
+ sendEmail: async(payload) => {
15
+ console.log("sendEmail disabled outside of production", payload)
16
+ }
17
+ }
18
+ }
7
19
 
8
20
  module.exports = client
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/rpc/rpc_router.js CHANGED
@@ -17,9 +17,6 @@ const async_wrapper = fn => (req, res, next) => {
17
17
  const rpc_router = (app) => {
18
18
  const rpc_routes = glob.sync(path.join(build_dir, "./rpc/*"))
19
19
 
20
-
21
- console.log("rpc router setup")
22
-
23
20
  rpc_routes.forEach((file_path) => {
24
21
  const basename = path.basename(file_path)
25
22
  const route_path = basename.replace(/__slash__/g, "/")