@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
package/boot/worker.js
CHANGED
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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({
|