corebasic 1.0.267 → 1.0.269

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.
@@ -54,13 +54,18 @@ function getLeaf(feature, req) {
54
54
  if (req) {
55
55
  for (let key in features) {
56
56
  const feature = features[key];
57
- if (feature.featureless && feature.api === req.method.toUpperCase() + ' ' + req.path)
57
+ let api = feature.api;
58
+ if (feature.api.includes(':')) {
59
+ for (let key in req.params)
60
+ api = api.replace(`:${key}`, decodeURIComponent(req.params[key] ?? ''));
61
+ }
62
+ if (feature.featureless && api === req.method.toUpperCase() + ' ' + req.path)
58
63
  return key.split(/\.(query|command)\./)[0];
59
64
  }
60
- 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
65
+ throw new Error(`Invalid feature for extracting leaf in getLeaf()`);
61
66
  }
62
67
  else {
63
- 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
68
+ throw new Error(`Invalid feature for extracting leaf in getLeaf()`);
64
69
  }
65
70
  }
66
71
  const DEPLOY_TOKEN_SECRET = process.env.DEPLOY_TOKEN_SECRET || "MY_SECRET_DEPLOY_TOKEN";
@@ -165,7 +170,12 @@ function getFeaturelessFeature(req) {
165
170
  if (Session.ALLOWED_URLS.includes(req.path)) {
166
171
  for (let key in features) {
167
172
  const feature = features[key];
168
- if (feature.featureless && feature.api === req.method.toUpperCase() + ' ' + req.path) {
173
+ let api = feature.api;
174
+ if (feature.api.includes(':')) {
175
+ for (let key in req.params)
176
+ api = api.replace(`:${key}`, decodeURIComponent(req.params[key] ?? ''));
177
+ }
178
+ if (feature.featureless && api === req.method.toUpperCase() + ' ' + req.path) {
169
179
  return getFeature(key);
170
180
  }
171
181
  }
package/libs/features.ts CHANGED
@@ -163,12 +163,17 @@ function getLeaf(feature: string, req?: ExpressRequest): string {
163
163
  if (req) {
164
164
  for(let key in features) {
165
165
  const feature = features[key]!
166
- if (feature.featureless && feature.api === req.method.toUpperCase() + ' ' + req.path)
166
+ let api = feature.api
167
+ if (feature.api.includes(':')) {
168
+ for (let key in req.params)
169
+ api = api.replace(`:${key}`, decodeURIComponent(req.params[key] ?? ''))
170
+ }
171
+ if (feature.featureless && api === req.method.toUpperCase() + ' ' + req.path)
167
172
  return key.split(/\.(query|command)\./)[0]!
168
173
  }
169
- 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
174
+ throw new Error(`Invalid feature for extracting leaf in getLeaf()`)
170
175
  } else {
171
- 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
176
+ throw new Error(`Invalid feature for extracting leaf in getLeaf()`)
172
177
  }
173
178
  }
174
179
 
@@ -286,7 +291,12 @@ function getFeaturelessFeature(req: ExpressRequest): FeatureEntry | undefined {
286
291
  if (Session.ALLOWED_URLS.includes(req.path)) {
287
292
  for(let key in features) {
288
293
  const feature = features[key]!
289
- if (feature.featureless && feature.api === req.method.toUpperCase() + ' ' + req.path) {
294
+ let api = feature.api
295
+ if (feature.api.includes(':')) {
296
+ for (let key in req.params)
297
+ api = api.replace(`:${key}`, decodeURIComponent(req.params[key] ?? ''))
298
+ }
299
+ if (feature.featureless && api === req.method.toUpperCase() + ' ' + req.path) {
290
300
  return getFeature(key)
291
301
  }
292
302
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.267",
4
+ "version": "1.0.269",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "./index.ts",