corebasic 1.0.43 → 1.0.44

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.
Files changed (2) hide show
  1. package/libs/features.js +7 -7
  2. package/package.json +1 -1
package/libs/features.js CHANGED
@@ -28,14 +28,14 @@ export function start(app, url) {
28
28
 
29
29
  if (feature.api.split(' ')[0].toLowerCase() !== "get") {
30
30
  let topic = feature.topic
31
- Kafka.receive(`features.${topic}`, `${featureName}.${topic}`, async (topic, message) => {
31
+ Kafka.receive(`Features.${topic}`, `${featureName}.${topic}`, async (topic, message) => {
32
32
 
33
33
  const timer = ms => new Promise(res => setTimeout(res, ms)) // A promise that resolves after "ms" Milliseconds
34
- topic = topic.replace('features.','')
34
+ topic = topic.replace('Features.','')
35
35
  while (true) {
36
36
  try {
37
37
  await features[message.feature].handler(topic, message)
38
- await Elabase.insert("txns", {_id: message.txn, status: "Processed"})
38
+ await Elabase.insert("Features.txns", {_id: message.txn, status: "Processed"})
39
39
  break
40
40
  } catch {
41
41
  console.warn(`Feature: ${featureName}, error in executing handler during Kafka.receive(topic: ${topic})`)
@@ -62,7 +62,7 @@ export function start(app, url) {
62
62
  throw {status: 500, message: "Failed to retreive data", ...err}
63
63
  }
64
64
  } else
65
- await commandAction(req, res, feature, req.body.feature)
65
+ await commandAction(req, res, feature)
66
66
  } catch (err) {
67
67
  res.status(err.status ?? 500).json(err)
68
68
  }
@@ -72,7 +72,7 @@ export function start(app, url) {
72
72
 
73
73
  app.get('/transactions/:id', async (req, res) => {
74
74
  try {
75
- let items = await Elabase.query("txns", {_id: req.params.id})
75
+ let items = await Elabase.query("Features.txns", {_id: req.params.id})
76
76
  if (items.length)
77
77
  res.json({ data: { ...items[0], txn: items._id } })
78
78
  else
@@ -83,11 +83,11 @@ export function start(app, url) {
83
83
  })
84
84
  }
85
85
 
86
- const commandAction = async (req, res, feature, featureName) => {
86
+ const commandAction = async (req, res, feature) => {
87
87
  let txn = req.body.txn ?? Util.uid()
88
88
  req.body.data._id = req.body.data._id ?? txn
89
89
  try {
90
- await Kafka.send(`features.${feature.topic}`, { data: req.body.data, feature: featureName, txn, id: _id, date: new Date().getTime() }, _id)
90
+ await Kafka.send(`Features.${feature.topic}`, { data: req.body.data, feature: req.body.feature, txn, id: _id, date: new Date().getTime() }, _id)
91
91
 
92
92
  } catch {
93
93
  throw {status: 500, message: "Failed to queue the transaction"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.43",
4
+ "version": "1.0.44",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {