@rpcbase/server 0.37.0 → 0.38.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.
@@ -2,11 +2,10 @@
2
2
  const os = require("os")
3
3
 
4
4
  const get_runtime = () => {
5
- console.warn("warning: native mode is tmp disabled")
6
- return "docker"
7
-
8
5
  if (os.platform() === "darwin") {
9
- return "native"
6
+ console.warn("warning: native mode is tmp disabled")
7
+ // return "native"
8
+ return "docker"
10
9
  } else {
11
10
  return "docker"
12
11
  }
package/express/index.js CHANGED
@@ -38,9 +38,10 @@ module.exports = () => {
38
38
  // local dev origins
39
39
  [
40
40
  `http://localhost:${CLIENT_PORT}`,
41
- "http://localhost:8090",
41
+ "http://localhost:8090", // TMP: used by client of admin
42
42
  "localhost",
43
43
  ]
44
+
44
45
  // console.log("SETUP CORS", cors_origins)
45
46
 
46
47
  app.use(cors({
@@ -52,7 +53,8 @@ module.exports = () => {
52
53
  console.log("use session middleware")
53
54
  app.use(session_middleware)
54
55
 
55
- app.get("/api/ping", (req, res) => res.json({status: "ok"}))
56
+ app.get("/api/ping", (req, res) => res.json({message: "pong"}))
57
+ app.post("/api/ping", (req, res) => res.json({message: "pong"}))
56
58
 
57
59
  return app
58
60
  }
@@ -8,7 +8,6 @@ const redis_store = require("connect-redis")(session)
8
8
  // https://stackoverflow.com/questions/70867229/error-connection-timeout-when-connecting-to-redis-docker-instance
9
9
  // https://github.com/redis/node-redis/issues/1656/
10
10
 
11
-
12
11
  const {SESSION_STORE_PORT} = process.env
13
12
 
14
13
  if (typeof SESSION_STORE_PORT === "string" && !validator.isPort(SESSION_STORE_PORT)) {
@@ -34,7 +33,7 @@ const redis_client = createClient({
34
33
  port: SESSION_STORE_PORT,
35
34
  reconnectStrategy
36
35
  },
37
- // legacyMode: true,
36
+ legacyMode: true,
38
37
  })
39
38
 
40
39
  // extreme warning: when there is blocking io redis client won't connect
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -13,6 +13,7 @@
13
13
  "body-parser": "1.19.2",
14
14
  "connect-redis": "6.1.1",
15
15
  "cors": "2.8.5",
16
+ "debug": "4.3.3",
16
17
  "dotenv": "16.0.0",
17
18
  "express": "4.17.3",
18
19
  "express-session": "1.17.2",
package/rpc/rpc_router.js CHANGED
@@ -2,6 +2,7 @@
2
2
  const fs = require("fs")
3
3
  const path = require("path")
4
4
  const glob = require("glob")
5
+ const debug = require("debug")
5
6
 
6
7
  const src_path = path.join(process.cwd(), "./src/")
7
8
  const build_dir = path.join(process.cwd(), "build/")
@@ -16,6 +17,9 @@ const async_wrapper = fn => (req, res, next) => {
16
17
  const rpc_router = (app) => {
17
18
  const rpc_routes = glob.sync(path.join(build_dir, "./rpc/*"))
18
19
 
20
+
21
+ console.log("rpc router setup")
22
+
19
23
  rpc_routes.forEach((file_path) => {
20
24
  const basename = path.basename(file_path)
21
25
  const route_path = basename.replace(/__slash__/g, "/")
@@ -30,6 +34,7 @@ const rpc_router = (app) => {
30
34
  const rpc_fn = require(module_path)
31
35
  app.post(`/rpc/${route_path}`, async_wrapper(async(req, res) => {
32
36
  // console.log("GOT REQ", req.body)
37
+ console.log(`POST /rpc/${route_path}`)
33
38
  // TODO: add jaegerclient / opentelemetry
34
39
  const result = await rpc_fn(req.body, {req})
35
40