corebasic 1.0.266 → 1.0.268

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.
@@ -49,16 +49,18 @@ const getFeatureUrl = (api) => { const url = api.split(' ')[1]; if (!url)
49
49
  throw new Error(`Invalid Feature url in api: ${api}`); return url; };
50
50
  const getFeature = (name) => features[name];
51
51
  function getLeaf(feature, req) {
52
+ if (feature)
53
+ return feature.split(/\.(query|command)\./)[0];
52
54
  if (req) {
53
55
  for (let key in features) {
54
56
  const feature = features[key];
55
57
  if (feature.featureless && feature.api === req.method.toUpperCase() + ' ' + req.path)
56
58
  return key.split(/\.(query|command)\./)[0];
57
59
  }
58
- return "NOLEAF"; // This code will never be reached as apiHandler()'s prior code ensures req is valid and there exists a feature. Included to silence ./tsc
60
+ throw new Error(`Invalid feature for extracting leaf in getLeaf()`);
59
61
  }
60
62
  else {
61
- return feature.split(/\.(query|command)\./)[0];
63
+ throw new Error(`Invalid feature for extracting leaf in getLeaf()`);
62
64
  }
63
65
  }
64
66
  const DEPLOY_TOKEN_SECRET = process.env.DEPLOY_TOKEN_SECRET || "MY_SECRET_DEPLOY_TOKEN";
package/libs/features.ts CHANGED
@@ -157,15 +157,18 @@ const getFeatureUrl = (api: string): string => { const url = api.split(' ')[1];
157
157
  const getFeature = (name: string): FeatureEntry | undefined => features[name]
158
158
 
159
159
  function getLeaf(feature: string, req?: ExpressRequest): string {
160
+ if (feature)
161
+ return feature.split(/\.(query|command)\./)[0]!
162
+
160
163
  if (req) {
161
164
  for(let key in features) {
162
165
  const feature = features[key]!
163
166
  if (feature.featureless && feature.api === req.method.toUpperCase() + ' ' + req.path)
164
167
  return key.split(/\.(query|command)\./)[0]!
165
168
  }
166
- return "NOLEAF" // This code will never be reached as apiHandler()'s prior code ensures req is valid and there exists a feature. Included to silence ./tsc
169
+ throw new Error(`Invalid feature for extracting leaf in getLeaf()`)
167
170
  } else {
168
- return feature.split(/\.(query|command)\./)[0]!
171
+ throw new Error(`Invalid feature for extracting leaf in getLeaf()`)
169
172
  }
170
173
  }
171
174
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.266",
4
+ "version": "1.0.268",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "./index.ts",