corebasic 1.0.70 → 1.0.72

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 CHANGED
@@ -94,9 +94,9 @@ export const start = async (app, url, file) => {
94
94
  res.status(500).json({ message: "Failed to retreive data" })
95
95
  }
96
96
  })
97
- app.get('/users/transactions', async (req, res) => {
97
+ app.get('/users/:id/transactions', async (req, res) => {
98
98
  try {
99
- res.json({ data: await Dip.query(`users.txns.${message.user}`, {}, { $orderby: { date: -1 } }) })
99
+ res.json({ data: await Dip.query(`users.txns.${req.params.id}`, {}, { $orderby: { date: -1 } }) })
100
100
  } catch {
101
101
  res.status(500).json({ message: "Failed to retreive data" })
102
102
  }
package/libs/messaging.js CHANGED
@@ -12,15 +12,20 @@ let users_pool = {
12
12
  }
13
13
 
14
14
  async function disconnect(user) {
15
+ await consumer.unsubscribe(user, users_pool[user].listener);
15
16
  delete users_pool[user]
16
- await consumer.unsubscribe(user);
17
+ // await consumer.unsubscribe(user);
17
18
  }
18
19
  async function connect({user,req,res}) {
19
- users_pool[user] = {req,res}
20
- await consumer.subscribe(user, (message, channel) => {
21
- if (users_pool[user])
20
+ const listener = (message, channel) => {
21
+ if (users_pool[user]) {
22
+ try {message = JSON.parse(message)} catch {}
22
23
  users_pool[user].res.write(JSON.stringify({message, channel}) + "\n")
23
- });
24
+ }
25
+ }
26
+ users_pool[user] = {req,res,listener}
27
+ await consumer.subscribe(user, listener);
28
+
24
29
  }
25
30
 
26
31
  export async function start(app) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.70",
4
+ "version": "1.0.72",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {