@rpcbase/server 0.264.0 → 0.266.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 CHANGED
@@ -31,7 +31,14 @@ const args = yargs(hideBin(process.argv))
31
31
  .option("session", {
32
32
  hidden: true,
33
33
  })
34
- .command("start", "runs server/infrastructure", () => {}, (args) => {
34
+ .command("start", "runs server/infrastructure", (yargs) => {
35
+ yargs
36
+ .option("docker", {
37
+ type: "boolean",
38
+ default: false,
39
+ description: "Run in docker"
40
+ })
41
+ }, (args) => {
35
42
  is_command = true
36
43
  check_args(args)
37
44
  start_server_infrastructure(args)
@@ -4,15 +4,14 @@ const fs = require("fs")
4
4
 
5
5
  const run_docker = require("./run_docker")
6
6
  const run_native = require("./run_native")
7
- const get_runtime = require("./get_runtime")
8
7
 
9
8
  // TODO: auto create network if necessary
10
- // docker network create local-network
9
+ // docker network create ${RB_INSTANCE_NAME}-network
11
10
 
12
11
  const start_server = async(args) => {
13
12
  const infrastructure_dir = path.join(process.cwd(), "../infrastructure")
14
13
 
15
- const runtime = get_runtime()
14
+ const runtime = args.docker ? "docker" : "native"
16
15
 
17
16
  // prefix
18
17
  const proj_parent_dir = path.join(infrastructure_dir, "../../")
@@ -22,8 +21,6 @@ const start_server = async(args) => {
22
21
  run_docker(infrastructure_dir, proj_prefix, args)
23
22
  } else if (runtime === "native") {
24
23
  run_native(infrastructure_dir, proj_prefix, args)
25
- } else {
26
- throw new Error("unknown runtime")
27
24
  }
28
25
  }
29
26
 
package/database.js CHANGED
@@ -26,6 +26,8 @@ if (typeof DATABASE_NAME !== "string") {
26
26
  throw new Error("expected DATABASE_NAME to be a string")
27
27
  }
28
28
 
29
+ console.log("IS DOCKERRRRR", is_docker())
30
+
29
31
  const hostname = is_docker() ? "database" : "127.0.0.1"
30
32
 
31
33
  const mongo_url = `mongodb://${hostname}:${DATABASE_PORT}/${DATABASE_NAME}?directConnection=true&replicaSet=rs0`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.264.0",
3
+ "version": "0.266.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -6,6 +6,8 @@ const validator = require("validator")
6
6
  const {createClient} = require("redis")
7
7
  const RedisStore = require("connect-redis").default
8
8
 
9
+ const is_docker = require("@rpcbase/std/is_docker")
10
+
9
11
 
10
12
  const {SESSION_STORE_PORT, APP_DOMAIN} = process.env
11
13
  assert(SESSION_STORE_PORT, "SESSION_STORE_PORT is undefined")
@@ -1,9 +0,0 @@
1
- /* @flow */
2
- const is_docker = require("@rpcbase/std/is_docker")
3
-
4
-
5
- const get_runtime = () => {
6
- return is_docker() ? "docker" : "native"
7
- }
8
-
9
- module.exports = get_runtime