@webtypen/webframez-core 0.0.36 → 0.0.37

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.
@@ -3,10 +3,6 @@ export declare class LambdaApplication {
3
3
  * Init the routes and handle the request
4
4
  */
5
5
  boot(event: any, context: any, options?: any): Promise<void | {
6
- statusCode: number;
7
- body: string;
8
- headers?: undefined;
9
- } | {
10
6
  statusCode: number;
11
7
  body: string;
12
8
  headers: {
@@ -107,10 +107,6 @@ declare class RouterFacade {
107
107
  * @param res
108
108
  */
109
109
  handleRequest(req: null | IncomingMessage, res: null | ServerResponse, options?: any): Promise<void | {
110
- statusCode: number;
111
- body: string;
112
- headers?: undefined;
113
- } | {
114
110
  statusCode: number;
115
111
  body: string;
116
112
  headers: {
@@ -256,6 +256,7 @@ class RouterFacade {
256
256
  return {
257
257
  statusCode: 500,
258
258
  body: JSON.stringify({ status: "error", message: "Unknown middleware `" + middlewareKey + "` ..." }),
259
+ headers: response.headers,
259
260
  };
260
261
  }
261
262
  else if (req && res) {
@@ -276,6 +277,7 @@ class RouterFacade {
276
277
  return {
277
278
  statusCode: 500,
278
279
  body: JSON.stringify({ status: "error", message: "Middleware run error `" + middlewareKey + "` ..." }),
280
+ headers: response.headers,
279
281
  };
280
282
  }
281
283
  else if (req && res) {
@@ -288,7 +290,7 @@ class RouterFacade {
288
290
  catch (e) {
289
291
  // Send Middleware-Abort
290
292
  if (this.mode === "aws-lambda") {
291
- return { statusCode: 500, body: JSON.stringify({ status: "error", message: e.data }) };
293
+ return { statusCode: 500, body: JSON.stringify({ status: "error", message: e.data }), headers: response.headers };
292
294
  }
293
295
  else if (res) {
294
296
  res.writeHead(e.status, typeof e.data === "object" ? { "Content-Type": "application/json" } : { "Content-Type": "text/html" });
@@ -321,7 +323,11 @@ class RouterFacade {
321
323
  const controller = this.kernel.controller[split[0]];
322
324
  if (!controller) {
323
325
  if (this.mode === "aws-lambda") {
324
- return { statusCode: 500, body: JSON.stringify({ status: "error", message: "Controller `" + split[0] + "` not found ..." }) };
326
+ return {
327
+ statusCode: 500,
328
+ body: JSON.stringify({ status: "error", message: "Controller `" + split[0] + "` not found ..." }),
329
+ headers: response.headers,
330
+ };
325
331
  }
326
332
  else if (res) {
327
333
  res.writeHead(500, { "Content-Type": "text/html" });
@@ -337,7 +343,7 @@ class RouterFacade {
337
343
  try {
338
344
  yield route.component(request, response);
339
345
  if (this.mode === "aws-lambda") {
340
- return { statusCode: response.statusCode, body: JSON.stringify(response.content) };
346
+ return { statusCode: response.statusCode, body: JSON.stringify(response.content), headers: response.headers };
341
347
  }
342
348
  else if (res && req) {
343
349
  res.end();
@@ -346,7 +352,11 @@ class RouterFacade {
346
352
  }
347
353
  catch (e) {
348
354
  if (this.mode === "aws-lambda") {
349
- return { statusCode: 500, body: JSON.stringify({ status: "error", message: "Error running the component ..." }) };
355
+ return {
356
+ statusCode: 500,
357
+ body: JSON.stringify({ status: "error", message: "Error running the component ..." }),
358
+ headers: response.headers,
359
+ };
350
360
  }
351
361
  else if (res && req) {
352
362
  this.sendError(res, 500);
@@ -356,7 +366,11 @@ class RouterFacade {
356
366
  }
357
367
  else {
358
368
  if (this.mode === "aws-lambda") {
359
- return { statusCode: 500, body: JSON.stringify({ status: "error", message: "Route component not found ..." }) };
369
+ return {
370
+ statusCode: 500,
371
+ body: JSON.stringify({ status: "error", message: "Route component not found ..." }),
372
+ headers: response.headers,
373
+ };
360
374
  }
361
375
  else if (res && req) {
362
376
  this.sendError(res, 404);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.0.36",
3
+ "version": "0.0.37",
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",
@@ -294,6 +294,7 @@ class RouterFacade {
294
294
  return {
295
295
  statusCode: 500,
296
296
  body: JSON.stringify({ status: "error", message: "Unknown middleware `" + middlewareKey + "` ..." }),
297
+ headers: response.headers,
297
298
  };
298
299
  } else if (req && res) {
299
300
  this.requestConsoleLog(req, 500);
@@ -319,6 +320,7 @@ class RouterFacade {
319
320
  return {
320
321
  statusCode: 500,
321
322
  body: JSON.stringify({ status: "error", message: "Middleware run error `" + middlewareKey + "` ..." }),
323
+ headers: response.headers,
322
324
  };
323
325
  } else if (req && res) {
324
326
  this.requestConsoleLog(req, 500);
@@ -329,7 +331,7 @@ class RouterFacade {
329
331
  } catch (e: any) {
330
332
  // Send Middleware-Abort
331
333
  if (this.mode === "aws-lambda") {
332
- return { statusCode: 500, body: JSON.stringify({ status: "error", message: e.data }) };
334
+ return { statusCode: 500, body: JSON.stringify({ status: "error", message: e.data }), headers: response.headers };
333
335
  } else if (res) {
334
336
  res.writeHead(e.status, typeof e.data === "object" ? { "Content-Type": "application/json" } : { "Content-Type": "text/html" });
335
337
  res.end(typeof e.data === "object" ? JSON.stringify(e.data) : e.data ? e.data : " ");
@@ -362,7 +364,11 @@ class RouterFacade {
362
364
  const controller = this.kernel.controller[split[0]];
363
365
  if (!controller) {
364
366
  if (this.mode === "aws-lambda") {
365
- return { statusCode: 500, body: JSON.stringify({ status: "error", message: "Controller `" + split[0] + "` not found ..." }) };
367
+ return {
368
+ statusCode: 500,
369
+ body: JSON.stringify({ status: "error", message: "Controller `" + split[0] + "` not found ..." }),
370
+ headers: response.headers,
371
+ };
366
372
  } else if (res) {
367
373
  res.writeHead(500, { "Content-Type": "text/html" });
368
374
  res.end("Controller `" + split[0] + "` not found ...");
@@ -381,14 +387,18 @@ class RouterFacade {
381
387
  await route.component(request, response);
382
388
 
383
389
  if (this.mode === "aws-lambda") {
384
- return { statusCode: response.statusCode, body: JSON.stringify(response.content) };
390
+ return { statusCode: response.statusCode, body: JSON.stringify(response.content), headers: response.headers };
385
391
  } else if (res && req) {
386
392
  res.end();
387
393
  this.requestConsoleLog(req, response.statusCode);
388
394
  }
389
395
  } catch (e) {
390
396
  if (this.mode === "aws-lambda") {
391
- return { statusCode: 500, body: JSON.stringify({ status: "error", message: "Error running the component ..." }) };
397
+ return {
398
+ statusCode: 500,
399
+ body: JSON.stringify({ status: "error", message: "Error running the component ..." }),
400
+ headers: response.headers,
401
+ };
392
402
  } else if (res && req) {
393
403
  this.sendError(res, 500);
394
404
  this.requestConsoleLog(req, 500);
@@ -396,7 +406,11 @@ class RouterFacade {
396
406
  }
397
407
  } else {
398
408
  if (this.mode === "aws-lambda") {
399
- return { statusCode: 500, body: JSON.stringify({ status: "error", message: "Route component not found ..." }) };
409
+ return {
410
+ statusCode: 500,
411
+ body: JSON.stringify({ status: "error", message: "Route component not found ..." }),
412
+ headers: response.headers,
413
+ };
400
414
  } else if (res && req) {
401
415
  this.sendError(res, 404);
402
416
  this.requestConsoleLog(req, 404);