corebasic 1.0.47 → 1.0.49

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 +6 -5
  2. package/package.json +1 -1
package/libs/features.js CHANGED
@@ -54,15 +54,16 @@ export function start(app, url) {
54
54
  return
55
55
  app[method](url, async (req, res) => {
56
56
  let feature = features[req.body.feature]
57
+ let topic = feature.topic
57
58
  try {
58
59
  if (method === "get") {
59
60
  try {
60
- await feature.handler({...req, body: {...req.body, topic: feature.topic } }, res)
61
+ await feature.handler({...req, body: {...req.body, topic} }, res)
61
62
  } catch (err) {
62
63
  throw {status: 500, message: "Failed to retreive data", ...err}
63
64
  }
64
65
  } else
65
- await commandAction(req, res, feature)
66
+ await commandAction(req, res, topic)
66
67
  } catch (err) {
67
68
  res.status(err.status ?? 500).json(err)
68
69
  }
@@ -83,12 +84,12 @@ export function start(app, url) {
83
84
  })
84
85
  }
85
86
 
86
- const commandAction = async (req, res, feature) => {
87
+ const commandAction = async (req, res, topic) => {
87
88
  let txn = req.body.txn ?? Util.uid()
88
- req.body.data._id = req.body.data._id ?? txn
89
+ let _id = req.body.data._id ?? txn
89
90
  try {
90
91
  let {data, feature, app, user, client, version} = req.body
91
- await Kafka.send(`Features.${feature.topic}`, { data, feature, app, user, client, version, txn, id: _id, date: new Date().getTime() }, _id)
92
+ await Kafka.send(`Features.${topic}`, { data, feature, app, user, client, version, txn, id: _id, date: new Date().getTime() }, _id)
92
93
 
93
94
  } catch {
94
95
  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.47",
4
+ "version": "1.0.49",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {