@rpcbase/server 0.43.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/bin.js +1 -2
- package/cli/run_docker.js +1 -1
- package/cli/start_server.js +0 -1
- package/database.js +10 -11
- package/express/index.js +1 -1
- package/mailer/index.js +14 -2
- package/package.json +1 -1
- package/rpc/rpc_router.js +0 -3
package/bin.js
CHANGED
|
@@ -13,12 +13,11 @@ let is_command = false
|
|
|
13
13
|
const args = yargs(hideBin(process.argv))
|
|
14
14
|
.command("start", "run server/infrastructure", () => {}, (argv) => {
|
|
15
15
|
is_command = true
|
|
16
|
-
console.log("run start server/infrastructure")
|
|
17
16
|
start_server()
|
|
18
17
|
})
|
|
19
18
|
.command("ping", "ping", () => {}, (argv) => {
|
|
20
19
|
is_command = true
|
|
21
|
-
console.log("
|
|
20
|
+
console.log("PING")
|
|
22
21
|
})
|
|
23
22
|
.option("verbose", {
|
|
24
23
|
alias: "v",
|
package/cli/run_docker.js
CHANGED
|
@@ -4,7 +4,6 @@ const path = require("path")
|
|
|
4
4
|
|
|
5
5
|
const is_production = "yes" === process.env.INFRASTRUCTURE_IS_PRODUCTION
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
const run_docker = async(infrastructure_dir, proj_prefix) => {
|
|
9
8
|
// env
|
|
10
9
|
const env_path = path.relative(infrastructure_dir, path.join(process.cwd(), "./.env"))
|
|
@@ -20,6 +19,7 @@ const run_docker = async(infrastructure_dir, proj_prefix) => {
|
|
|
20
19
|
const cmd = `docker-compose --env-file ${env_path} -p ${proj_prefix} ${compose_files.join(" ")} up ${opts.join(" ")}`
|
|
21
20
|
|
|
22
21
|
console.log(cmd)
|
|
22
|
+
|
|
23
23
|
try {
|
|
24
24
|
execSync(cmd, {stdio: "inherit", cwd: infrastructure_dir})
|
|
25
25
|
} catch (err) {
|
package/cli/start_server.js
CHANGED
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,
|
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
|
|
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
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, "/")
|