corebasic 1.0.36 → 1.0.38
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 +6 -7
- package/package.json +1 -1
package/libs/features.js
CHANGED
|
@@ -19,20 +19,19 @@ export function start(app, url) {
|
|
|
19
19
|
|
|
20
20
|
name = name.split('.')
|
|
21
21
|
let handler = name.pop()
|
|
22
|
-
name = name.join('/')
|
|
23
|
-
let module = name
|
|
22
|
+
name = `src/${name.join('/')}`
|
|
24
23
|
|
|
25
|
-
if (name === 'transactions/query')
|
|
24
|
+
if (name === 'src/transactions/query')
|
|
26
25
|
return
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
feature.handler = (await import(`${new URL(`${name}.js`, url).toString().replace('file://', '')}`))[handler]
|
|
29
28
|
|
|
30
29
|
if (feature.api.split(' ')[0].toLowerCase() !== "get") {
|
|
31
30
|
let topic = feature.topic
|
|
32
|
-
Kafka.receive(topic
|
|
31
|
+
Kafka.receive(`features.${topic}`, `${featureName}.${topic}`, async (topic, message) => {
|
|
33
32
|
|
|
34
33
|
const timer = ms => new Promise(res => setTimeout(res, ms)) // A promise that resolves after "ms" Milliseconds
|
|
35
|
-
|
|
34
|
+
topic = topic.replace('features.','')
|
|
36
35
|
while (true) {
|
|
37
36
|
try {
|
|
38
37
|
await features[message.feature].handler(topic, message)
|
|
@@ -88,7 +87,7 @@ const commandAction = async (req, res, feature, featureName) => {
|
|
|
88
87
|
let txn = req.body.txn ?? Util.uid()
|
|
89
88
|
req.body.data._id = req.body.data._id ?? txn
|
|
90
89
|
try {
|
|
91
|
-
await Kafka.send(feature.topic
|
|
90
|
+
await Kafka.send(`features.${feature.topic}`, { data: req.body.data, feature: featureName, txn, id: _id }, _id)
|
|
92
91
|
|
|
93
92
|
} catch {
|
|
94
93
|
throw {status: 500, message: "Failed to queue the transaction"}
|