@webtypen/webframez-core 0.0.35 → 0.0.36

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.
@@ -5,5 +5,12 @@ export declare class LambdaApplication {
5
5
  boot(event: any, context: any, options?: any): Promise<void | {
6
6
  statusCode: number;
7
7
  body: string;
8
+ headers?: undefined;
9
+ } | {
10
+ statusCode: number;
11
+ body: string;
12
+ headers: {
13
+ [key: string]: string;
14
+ };
8
15
  }>;
9
16
  }
@@ -4,6 +4,9 @@ export declare class Response {
4
4
  res?: ServerResponse;
5
5
  statusCode: number;
6
6
  content?: any | null | undefined;
7
+ headers: {
8
+ [key: string]: string;
9
+ };
7
10
  /**
8
11
  * Mode
9
12
  */
@@ -4,6 +4,7 @@ exports.Response = void 0;
4
4
  class Response {
5
5
  constructor(options) {
6
6
  this.statusCode = 200;
7
+ this.headers = {};
7
8
  /**
8
9
  * Mode
9
10
  */
@@ -41,6 +42,7 @@ class Response {
41
42
  * @returns
42
43
  */
43
44
  header(type, value) {
45
+ this.headers[type] = value;
44
46
  if (!this.res) {
45
47
  return this;
46
48
  }
@@ -109,6 +109,13 @@ declare class RouterFacade {
109
109
  handleRequest(req: null | IncomingMessage, res: null | ServerResponse, options?: any): Promise<void | {
110
110
  statusCode: number;
111
111
  body: string;
112
+ headers?: undefined;
113
+ } | {
114
+ statusCode: number;
115
+ body: string;
116
+ headers: {
117
+ [key: string]: string;
118
+ };
112
119
  }>;
113
120
  requestConsoleLog(req: IncomingMessage, httpCode: number): void;
114
121
  }
@@ -299,11 +299,20 @@ class RouterFacade {
299
299
  }
300
300
  }
301
301
  // Handle OPTIONS-Request
302
- if (req && res && req.method === "OPTIONS") {
303
- res.statusCode = 200;
304
- res.setHeader("Content-Length", "0");
305
- res.end();
306
- this.requestConsoleLog(req, 200);
302
+ if (request && request.method === "OPTIONS") {
303
+ if (this.mode === "aws-lambda") {
304
+ return {
305
+ statusCode: 200,
306
+ body: "",
307
+ headers: response.headers,
308
+ };
309
+ }
310
+ else if (res && req) {
311
+ res.statusCode = 200;
312
+ res.setHeader("Content-Length", "0");
313
+ res.end();
314
+ this.requestConsoleLog(req, 200);
315
+ }
307
316
  return;
308
317
  }
309
318
  // Resolve route-component (handle controller definition)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
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",
@@ -4,6 +4,7 @@ export class Response {
4
4
  res?: ServerResponse;
5
5
  statusCode: number = 200;
6
6
  content?: any | null | undefined;
7
+ headers: { [key: string]: string } = {};
7
8
 
8
9
  /**
9
10
  * Mode
@@ -49,6 +50,8 @@ export class Response {
49
50
  * @returns
50
51
  */
51
52
  header(type: string, value: string) {
53
+ this.headers[type] = value;
54
+
52
55
  if (!this.res) {
53
56
  return this;
54
57
  }
@@ -340,11 +340,19 @@ class RouterFacade {
340
340
  }
341
341
 
342
342
  // Handle OPTIONS-Request
343
- if (req && res && req.method === "OPTIONS") {
344
- res.statusCode = 200;
345
- res.setHeader("Content-Length", "0");
346
- res.end();
347
- this.requestConsoleLog(req, 200);
343
+ if (request && request.method === "OPTIONS") {
344
+ if (this.mode === "aws-lambda") {
345
+ return {
346
+ statusCode: 200,
347
+ body: "",
348
+ headers: response.headers,
349
+ };
350
+ } else if (res && req) {
351
+ res.statusCode = 200;
352
+ res.setHeader("Content-Length", "0");
353
+ res.end();
354
+ this.requestConsoleLog(req, 200);
355
+ }
348
356
  return;
349
357
  }
350
358