corebasic 1.0.84 → 1.0.86
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/libs/features.js +5 -3
- package/libs/messaging.js +4 -3
- package/package.json +1 -1
package/libs/features.js
CHANGED
|
@@ -12,7 +12,7 @@ const getFeatureMethod = api => api.split(' ')[0].toLowerCase()
|
|
|
12
12
|
const getFeatureUrl = api => api.split(' ')[1]
|
|
13
13
|
const getFeature = name => features[name]
|
|
14
14
|
|
|
15
|
-
export const send = async (feature, params, payload) => {
|
|
15
|
+
export const send = async (feature, params, payload, headers) => {
|
|
16
16
|
let {api} = getFeature(feature)
|
|
17
17
|
let method = getFeatureMethod(api)
|
|
18
18
|
let url = getFeatureUrl(api)
|
|
@@ -24,7 +24,9 @@ export const send = async (feature, params, payload) => {
|
|
|
24
24
|
throw {feature, when: 'api/params/substitution', message: "Internal Feature Call" }
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
payload = { ...payload, feature, txn: Utils.uid() }
|
|
28
|
+
|
|
29
|
+
return (await axios[method](`http://127.0.0.1:3000${url}`, { data: payload, headers: {jwt: headers.jwt}, timeout: 1000 })).data
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
|
|
@@ -61,7 +63,7 @@ export const start = async (app, url, file) => {
|
|
|
61
63
|
try {
|
|
62
64
|
if (method === "get") {
|
|
63
65
|
try {
|
|
64
|
-
await feature.handler({...req, body: {...req.body, topic} }, res)
|
|
66
|
+
await feature.handler({...req, headers: req.headers, body: {...req.body, topic} }, res)
|
|
65
67
|
} catch (err) {
|
|
66
68
|
throw {status: 500, message: "Failed to GET feature", ...err}
|
|
67
69
|
}
|
package/libs/messaging.js
CHANGED
|
@@ -16,6 +16,9 @@ async function disconnect(user, uid) {
|
|
|
16
16
|
if (!users_pool[user])
|
|
17
17
|
return
|
|
18
18
|
|
|
19
|
+
let [{res}] = users_pool[user].reqres.filter(item => item.uid === uid).concat([{}])
|
|
20
|
+
res.end()
|
|
21
|
+
|
|
19
22
|
if (users_pool[user].listeners[uid]) {
|
|
20
23
|
if (users_pool[user].listeners.count == 1)
|
|
21
24
|
await consumer.unsubscribe(user, users_pool[user].listeners[uid]);
|
|
@@ -62,10 +65,8 @@ export async function start(app) {
|
|
|
62
65
|
})
|
|
63
66
|
app.get('/messages/disconnects/:user', async (req, res) => {
|
|
64
67
|
let uid = req.body.client
|
|
65
|
-
if (users_pool[req.params.user])
|
|
68
|
+
if (users_pool[req.params.user])
|
|
66
69
|
await disconnect(req.params.user, uid)
|
|
67
|
-
userRes.end()
|
|
68
|
-
}
|
|
69
70
|
res.json({})
|
|
70
71
|
})
|
|
71
72
|
}
|