@webtypen/webframez-core 0.0.46 → 0.0.48

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.
@@ -4,7 +4,7 @@ export declare class LambdaApplication {
4
4
  */
5
5
  boot(event: any, context: any, options?: any): Promise<void | {
6
6
  statusCode: number;
7
- body: string;
7
+ body: any;
8
8
  headers: {
9
9
  [key: string]: string;
10
10
  };
@@ -108,7 +108,7 @@ declare class RouterFacade {
108
108
  */
109
109
  handleRequest(req: null | IncomingMessage, res: null | ServerResponse, options?: any): Promise<void | {
110
110
  statusCode: number;
111
- body: string;
111
+ body: any;
112
112
  headers: {
113
113
  [key: string]: string;
114
114
  };
@@ -190,8 +190,12 @@ class RouterFacade {
190
190
  if (!req && this.mode === "aws-lambda" && options && options.event) {
191
191
  customRequest = {
192
192
  method: options.event.requestContext.http.method,
193
- url: options.event.requestContext.http.path,
193
+ url: options.event.rawPath +
194
+ (options.event.rawQueryString && options.event.rawQueryString.trim() !== '' ?
195
+ "?" + options.event.rawQueryString
196
+ : ""),
194
197
  headers: options.event.headers,
198
+ urlParams: options.event.queryStringParameters ? options.event.queryStringParameters : {},
195
199
  };
196
200
  }
197
201
  if (!this.kernel) {
@@ -223,16 +227,18 @@ class RouterFacade {
223
227
  })
224
228
  : null;
225
229
  const urlParams = {};
226
- if (req && req.url && req.url.indexOf("?") > 0) {
227
- const temp = req.url.substring(req.url.indexOf("?") + 1);
228
- if (temp && temp.trim() !== "") {
229
- const entries = temp.split("&");
230
- for (let entry of entries) {
231
- if (entry.indexOf("=") > 0) {
232
- urlParams[entry.substring(0, entry.indexOf("="))] = entry.substring(entry.indexOf("=") + 1);
233
- }
234
- else {
235
- urlParams[entry] = true;
230
+ if (!customRequest) {
231
+ if (req && req.url && req.url.indexOf("?") > 0) {
232
+ const temp = req.url.substring(req.url.indexOf("?") + 1);
233
+ if (temp && temp.trim() !== "") {
234
+ const entries = temp.split("&");
235
+ for (let entry of entries) {
236
+ if (entry.indexOf("=") > 0) {
237
+ urlParams[entry.substring(0, entry.indexOf("="))] = entry.substring(entry.indexOf("=") + 1);
238
+ }
239
+ else {
240
+ urlParams[entry] = true;
241
+ }
236
242
  }
237
243
  }
238
244
  }
@@ -251,7 +257,8 @@ class RouterFacade {
251
257
  : {},
252
258
  bodyPlain: bodyPlain,
253
259
  params: route && route.params ? route.params : {},
254
- urlParams: urlParams,
260
+ url: customRequest.url,
261
+ urlParams: customRequest.urlParams,
255
262
  headers: customRequest.headers,
256
263
  method: customRequest.method,
257
264
  }
@@ -398,7 +405,7 @@ class RouterFacade {
398
405
  if (this.mode === "aws-lambda") {
399
406
  return {
400
407
  statusCode: response.statusCode,
401
- body: JSON.stringify(response.content),
408
+ body: typeof response.content === "object" ? JSON.stringify(response.content) : response.content,
402
409
  headers: response.headers,
403
410
  };
404
411
  }
@@ -414,6 +421,7 @@ class RouterFacade {
414
421
  body: JSON.stringify({
415
422
  status: "error",
416
423
  message: "Error running the component ...",
424
+ error: e.toString(),
417
425
  }),
418
426
  headers: response.headers,
419
427
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "The core package of the typescript based webframez (web-framework) by webtypen.de",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "license": "MIT",
@@ -227,8 +227,14 @@ class RouterFacade {
227
227
  if (!req && this.mode === "aws-lambda" && options && options.event) {
228
228
  customRequest = {
229
229
  method: options.event.requestContext.http.method,
230
- url: options.event.requestContext.http.path,
230
+ url:
231
+ options.event.rawPath +
232
+ (options.event.rawQueryString && options.event.rawQueryString.trim() !== '' ?
233
+ "?" + options.event.rawQueryString
234
+ : ""
235
+ ),
231
236
  headers: options.event.headers,
237
+ urlParams: options.event.queryStringParameters ? options.event.queryStringParameters : {},
232
238
  };
233
239
  }
234
240
 
@@ -267,17 +273,19 @@ class RouterFacade {
267
273
  : null;
268
274
 
269
275
  const urlParams: any = {};
270
- if (req && req.url && req.url.indexOf("?") > 0) {
271
- const temp = req.url.substring(req.url.indexOf("?") + 1);
272
- if (temp && temp.trim() !== "") {
273
- const entries = temp.split("&");
274
- for (let entry of entries) {
275
- if (entry.indexOf("=") > 0) {
276
- urlParams[entry.substring(0, entry.indexOf("="))] = entry.substring(
277
- entry.indexOf("=") + 1
278
- );
279
- } else {
280
- urlParams[entry] = true;
276
+ if (!customRequest) {
277
+ if (req && req.url && req.url.indexOf("?") > 0) {
278
+ const temp = req.url.substring(req.url.indexOf("?") + 1);
279
+ if (temp && temp.trim() !== "") {
280
+ const entries = temp.split("&");
281
+ for (let entry of entries) {
282
+ if (entry.indexOf("=") > 0) {
283
+ urlParams[entry.substring(0, entry.indexOf("="))] = entry.substring(
284
+ entry.indexOf("=") + 1
285
+ );
286
+ } else {
287
+ urlParams[entry] = true;
288
+ }
281
289
  }
282
290
  }
283
291
  }
@@ -299,10 +307,10 @@ class RouterFacade {
299
307
  : bodyPlain
300
308
  )
301
309
  : {},
302
-
303
310
  bodyPlain: bodyPlain,
304
311
  params: route && route.params ? route.params : {},
305
- urlParams: urlParams,
312
+ url: customRequest.url,
313
+ urlParams: customRequest.urlParams,
306
314
  headers: customRequest.headers,
307
315
  method: customRequest.method,
308
316
  }
@@ -472,20 +480,21 @@ class RouterFacade {
472
480
  if (this.mode === "aws-lambda") {
473
481
  return {
474
482
  statusCode: response.statusCode,
475
- body: JSON.stringify(response.content),
483
+ body: typeof response.content === "object" ? JSON.stringify(response.content) : response.content,
476
484
  headers: response.headers,
477
485
  };
478
486
  } else if (res && req) {
479
487
  res.end();
480
488
  this.requestConsoleLog(req, response.statusCode);
481
489
  }
482
- } catch (e) {
490
+ } catch (e: any) {
483
491
  if (this.mode === "aws-lambda") {
484
492
  return {
485
493
  statusCode: 500,
486
494
  body: JSON.stringify({
487
495
  status: "error",
488
496
  message: "Error running the component ...",
497
+ error: e.toString(),
489
498
  }),
490
499
  headers: response.headers,
491
500
  };