@rpcbase/server 0.45.0 → 0.48.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 +10 -11
- package/express/index.js +1 -2
- package/mailer/index.js +15 -2
- package/package.json +1 -1
- package/rpc/rpc_router.js +0 -3
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
|
-
|
|
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("
|
|
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:
|
|
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
|
-
|
|
43
|
-
|
|
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,
|
|
@@ -50,7 +50,6 @@ module.exports = () => {
|
|
|
50
50
|
credentials: true // enable set-cookie
|
|
51
51
|
}))
|
|
52
52
|
|
|
53
|
-
console.log("use session middleware")
|
|
54
53
|
app.use(session_middleware)
|
|
55
54
|
|
|
56
55
|
app.get("/api/ping", (req, res) => res.json({message: "pong"}))
|
package/mailer/index.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
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
|
|
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")
|
|
16
|
+
console.log("From:", payload.From, "To:", payload.To, "Subject:", payload.Subject)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
7
20
|
|
|
8
21
|
module.exports = client
|
package/package.json
CHANGED
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, "/")
|