corebasic 1.0.257 → 1.0.259

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.
@@ -92,18 +92,18 @@ export const send = async (meta, feature, data, params) => {
92
92
  let url = getFeatureUrl(api);
93
93
  if (params || url.includes(':')) {
94
94
  for (let key in params)
95
- url = url.replace(`:${key}`, params[key]);
95
+ url = url.replace(`:${key}`, encodeURIComponent(params[key]));
96
96
  if (url.includes(':'))
97
97
  throw new Error(`Error: Internal feature call send on feature: ${feature} when api/params/substitution`);
98
98
  }
99
- const payload = { ...meta, data, feature, txn: Utils.uid() };
99
+ const payload = { ...meta, data, feature, txn: Utils.uid(), params: params ?? {} };
100
100
  service = service.replace('http://slyp.app', 'https://slyp.app');
101
101
  // return (await axios[method](`${service}${url}`, { data: payload, headers: {jwt: headers.jwt}, timeout: 1000 })).data
102
102
  // Used to work. But request to 127.0.0.1 fails to send the specified headers along with the request.
103
103
  // return (await axios[method](`${service}${url}`, payload, {headers: {jwt: SERVICE_ACCESS_TOKEN, service: true}, timeout: 1000 })).data // Worked Earlier, but issue spotted
104
104
  if (baseFeature) { // Local call
105
105
  let response;
106
- let req = { body: payload, params: params ?? {}, method, path: url, url: '', headers: {}, query: {}, on: (_event, _callback) => { } };
106
+ let req = { body: payload, params: params ?? {}, method, path: decodeURIComponent(url), url: '', headers: {}, query: {}, on: (_event, _callback) => { } };
107
107
  req = JSON.parse(JSON.stringify(req));
108
108
  const callback = (payload) => { response = payload; };
109
109
  const res = {
@@ -185,7 +185,7 @@ const apiHandler = async (req, res) => {
185
185
  const message = {
186
186
  meta,
187
187
  data: req.body.data,
188
- params: req.params,
188
+ params: featureless ? req.params : req.body.params,
189
189
  };
190
190
  const appReq = {
191
191
  meta: message.meta,
package/libs/features.ts CHANGED
@@ -203,12 +203,12 @@ export const send = async <K extends keyof FeatureTypes> (meta: Partial<FeatureM
203
203
 
204
204
  if (params || url.includes(':')) {
205
205
  for (let key in params)
206
- url = url.replace(`:${key}`, params[key]!)
206
+ url = url.replace(`:${key}`, encodeURIComponent(params[key]!))
207
207
  if (url.includes(':'))
208
208
  throw new Error(`Error: Internal feature call send on feature: ${feature} when api/params/substitution`)
209
209
  }
210
210
 
211
- const payload: PayloadMessage = { ...meta, data, feature, txn: Utils.uid() } as PayloadMessage
211
+ const payload: PayloadMessage = { ...meta, data, feature, txn: Utils.uid(), params: params ?? {} } as PayloadMessage
212
212
  service = service.replace('http://slyp.app', 'https://slyp.app')
213
213
 
214
214
  // return (await axios[method](`${service}${url}`, { data: payload, headers: {jwt: headers.jwt}, timeout: 1000 })).data
@@ -217,7 +217,7 @@ export const send = async <K extends keyof FeatureTypes> (meta: Partial<FeatureM
217
217
  // return (await axios[method](`${service}${url}`, payload, {headers: {jwt: SERVICE_ACCESS_TOKEN, service: true}, timeout: 1000 })).data // Worked Earlier, but issue spotted
218
218
  if (baseFeature) { // Local call
219
219
  let response;
220
- let req: ExpressRequest = { body: payload, params: params ?? {}, method, path: url, url: '', headers: {}, query: {}, on: (_event: string, _callback:()=>void) => {} }
220
+ let req: ExpressRequest = { body: payload, params: params ?? {}, method, path: decodeURIComponent(url), url: '', headers: {}, query: {}, on: (_event: string, _callback:()=>void) => {} }
221
221
  req = JSON.parse(JSON.stringify(req))
222
222
  const callback = (payload: unknown): void => { response = payload }
223
223
  const res: ExpressResponse = {
@@ -312,7 +312,7 @@ const apiHandler = async (req: ExpressRequest, res: ExpressResponse) => {
312
312
  const message: FeatureMessage = {
313
313
  meta,
314
314
  data: req.body.data,
315
- params: req.params,
315
+ params: featureless ? req.params : req.body.params!,
316
316
  }
317
317
 
318
318
  const appReq: Req = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.257",
4
+ "version": "1.0.259",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "./index.ts",