corebasic 1.0.87 → 1.0.89

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 +15 -1
  2. package/package.json +1 -1
package/libs/features.js CHANGED
@@ -12,8 +12,11 @@ const getFeatureMethod = api => api.split(' ')[0].toLowerCase()
12
12
  const getFeatureUrl = api => api.split(' ')[1]
13
13
  const getFeature = name => features[name]
14
14
 
15
+ let SLYP_FEATURES_LIST = {}
16
+
15
17
  export const send = async (feature, params, payload, headers) => {
16
- let {api} = getFeature(feature)
18
+ const throwError = () => {throw {message: `Feature ${feature} not found in internal or external list during inter feature call`}}
19
+ let {api} = getFeature(feature) ?? SLYP_FEATURES_LIST[feature] ?? throwError()
17
20
  let method = getFeatureMethod(api)
18
21
  let url = getFeatureUrl(api)
19
22
 
@@ -29,9 +32,20 @@ export const send = async (feature, params, payload, headers) => {
29
32
  return (await axios[method](`http://127.0.0.1:3000${url}`, { data: payload, headers: {jwt: headers.jwt}, timeout: 1000 })).data
30
33
  }
31
34
 
35
+ async function exportAllFeatures() {
36
+ let exp_features = {}
37
+ for (let [key, {api}] of Object.entries(features))
38
+ exp_features[key] = {api}
39
+
40
+ await Messaging.subscribe("SLYP_FEATURES_LIST", (message, channel) => {
41
+ SLYP_FEATURES_LIST = {...SLYP_FEATURES_LIST, ...JSON.parse(message)}
42
+ })
43
+ await Messaging.produce("SLYP_FEATURES_LIST", JSON.stringify(exp_features))
44
+ }
32
45
 
33
46
  export const start = async (app, url, file) => {
34
47
  features = await Utils.fileToJson(url, file)
48
+ await exportAllFeatures()
35
49
 
36
50
 
37
51
  // Registering handlers
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.87",
4
+ "version": "1.0.89",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {