corebasic 1.0.48 → 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.
- package/libs/features.js +5 -4
- 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
|
|
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,
|
|
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,
|
|
87
|
+
const commandAction = async (req, res, topic) => {
|
|
87
88
|
let txn = req.body.txn ?? Util.uid()
|
|
88
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.${
|
|
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"}
|