@rpcbase/server 0.102.0 → 0.104.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/database.js +8 -2
- package/package.json +1 -1
- package/queue/index.js +3 -0
- package/queue/register_queue_listener.js +0 -1
- package/src/auth/check_session.js +6 -1
package/database.js
CHANGED
|
@@ -3,6 +3,8 @@ const isPort = require("validator/lib/isPort")
|
|
|
3
3
|
|
|
4
4
|
const mongoose = require("./mongoose")
|
|
5
5
|
|
|
6
|
+
const pack = require("./package.json")
|
|
7
|
+
|
|
6
8
|
// load internal models
|
|
7
9
|
require("./src/models/User")
|
|
8
10
|
require("./src/models/Invite")
|
|
@@ -51,8 +53,13 @@ module.exports = async(...database_names) => {
|
|
|
51
53
|
keepAlive: true,
|
|
52
54
|
keepAliveInitialDelay: 5000,
|
|
53
55
|
minPoolSize: 5,
|
|
54
|
-
maxPoolSize: 1024 * 1024,
|
|
56
|
+
// maxPoolSize: 1024 * 1024,
|
|
57
|
+
maxPoolSize: 32,
|
|
55
58
|
family: 4, // force ipv4
|
|
59
|
+
driverInfo: {
|
|
60
|
+
name: `${pack.name}/database`,
|
|
61
|
+
version: pack.version,
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
// INFO: on reconnects
|
|
@@ -67,5 +74,4 @@ module.exports = async(...database_names) => {
|
|
|
67
74
|
console.log("JSON:", JSON.stringify(err, null, 2))
|
|
68
75
|
console.log("resaon", err.reason)
|
|
69
76
|
}
|
|
70
|
-
|
|
71
77
|
}
|
package/package.json
CHANGED
package/queue/index.js
CHANGED
|
@@ -10,6 +10,9 @@ const tasks_list = Object.create(null)
|
|
|
10
10
|
let worker_queue
|
|
11
11
|
|
|
12
12
|
const worker_add = async(task_name, payload, options) => {
|
|
13
|
+
if (!worker_queue) {
|
|
14
|
+
worker_queue = new Queue("worker-queue", worker_queue_url)
|
|
15
|
+
}
|
|
13
16
|
const res = await worker_queue.add({task_name, payload}, options)
|
|
14
17
|
console.log("created task:", task_name, res.id)
|
|
15
18
|
console.log(payload)
|
|
@@ -11,7 +11,6 @@ const log = debug("rb:queue:listener")
|
|
|
11
11
|
// Listens for mongodb change events,
|
|
12
12
|
// when a document is created, updated or deleted, dispatch job message
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
// mongoose middleware used for delete events
|
|
16
15
|
const mongoose_delete_plugin = (schema) => {
|
|
17
16
|
schema.pre("deleteOne", function(next) {
|
|
@@ -17,7 +17,12 @@ const check_session = async(payload, ctx) => {
|
|
|
17
17
|
log("is_signed_in:", is_signed_in)
|
|
18
18
|
|
|
19
19
|
// check if user exists
|
|
20
|
-
|
|
20
|
+
let user
|
|
21
|
+
try {
|
|
22
|
+
user = await User.findOne({_id: req.session.user_id}, {_id: 1})
|
|
23
|
+
} catch (err) {
|
|
24
|
+
log("find_user_err:", err)
|
|
25
|
+
}
|
|
21
26
|
if (!user) {
|
|
22
27
|
is_signed_in = false
|
|
23
28
|
req.session.destroy(/* TODO: this should take callback */)
|