@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
|
}
|
package/lib/Router/Response.d.ts
CHANGED
package/lib/Router/Response.js
CHANGED
|
@@ -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
|
}
|
package/lib/Router/Router.d.ts
CHANGED
|
@@ -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
|
}
|
package/lib/Router/Router.js
CHANGED
|
@@ -299,11 +299,20 @@ class RouterFacade {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
// Handle OPTIONS-Request
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
package/src/Router/Response.ts
CHANGED
|
@@ -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
|
}
|
package/src/Router/Router.ts
CHANGED
|
@@ -340,11 +340,19 @@ class RouterFacade {
|
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
// Handle OPTIONS-Request
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
|