@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.
- package/lib/LambdaApplication.d.ts +1 -1
- package/lib/Router/Router.d.ts +1 -1
- package/lib/Router/Router.js +21 -13
- package/package.json +1 -1
- package/src/Router/Router.ts +25 -16
package/lib/Router/Router.d.ts
CHANGED
package/lib/Router/Router.js
CHANGED
|
@@ -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.
|
|
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 (
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
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
package/src/Router/Router.ts
CHANGED
|
@@ -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:
|
|
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 (
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
entry.indexOf("=")
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
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
|
};
|