@rpcbase/server 0.322.0 → 0.324.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.
@@ -0,0 +1,21 @@
1
+ /* @flow */
2
+ const path = require("path")
3
+ const queue = require("@rpcbase/server/queue")
4
+
5
+
6
+ const no_impl_server_task = () => {
7
+ throw new Error("cannot run worker task on the server!")
8
+ }
9
+
10
+ const register_server_tasks = () => {
11
+ const wd = process.cwd()
12
+
13
+ const tasks_map = require(path.join(wd, "./src/tasks/index.js"))
14
+
15
+ for (const [task_name, task_path] of Object.entries(tasks_map)) {
16
+ queue.register_task(task_name, no_impl_server_task)
17
+ }
18
+
19
+ }
20
+
21
+ register_server_tasks()
@@ -0,0 +1,19 @@
1
+ /* @flow */
2
+ const path = require("path")
3
+ const queue = require("@rpcbase/server/queue")
4
+
5
+
6
+ const register_worker_tasks = () => {
7
+ const wd = process.cwd()
8
+ const tasks_dir = path.join(wd, "./src/tasks/")
9
+
10
+ const tasks_map = require(tasks_dir, "./index.js")
11
+
12
+ for (const [task_name, task_path] of Object.entries(tasks_map)) {
13
+ const task_fn = require(path.join(tasks_dir, task_path))
14
+ queue.register_task(task_name, task_fn)
15
+ }
16
+
17
+ }
18
+
19
+ register_worker_tasks()
package/boot/server.js CHANGED
@@ -7,6 +7,8 @@ const {rpc_router, client_router, express} = require("../")
7
7
 
8
8
  const realtime_state = require("../rts")
9
9
 
10
+ require("./register_server_tasks")
11
+
10
12
  const {SERVER_PORT} = process.env
11
13
 
12
14
  const app = express()
package/boot/worker.js CHANGED
@@ -1,6 +1,8 @@
1
1
  /* @flow */
2
2
  require("./shared")
3
3
 
4
+ require("./register_worker_tasks")
5
+
4
6
  const queue = require("../queue")
5
7
 
6
8
  queue.start()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.322.0",
3
+ "version": "0.324.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -50,7 +50,10 @@ const check_apply_permissions = (ac_config, model_name, operation, user_id, item
50
50
  const conditions = query.getQuery()
51
51
 
52
52
  if (conditions._owners) {
53
- console.log(colors.yellow("Warning!"), model_name, "ACL for read is owner, but client is sending _owners in query, the field will be overwritten")
53
+ if (conditions._owners.length !== 1 || conditions._owners[0] !== user_id) {
54
+ console.log(colors.yellow("Warning!"), model_name, "ACL for read is owner, but client is sending _owners in query, the field will be overwritten")
55
+ console.log("received conditions._owners:", JSON.stringify(conditions._owners))
56
+ }
54
57
  }
55
58
  // TODO: implement dynamic ACL based on what the application allows the user to read
56
59
  query.setQuery({