remult 0.20.0-exp.6 → 0.20.0-exp.8
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/esm/server/expressBridge.js +29 -25
- package/package.json +1 -1
- package/server/expressBridge.js +29 -25
|
@@ -256,6 +256,11 @@ export class RemultServerImplementation {
|
|
|
256
256
|
process(what) {
|
|
257
257
|
return async (req, origRes) => {
|
|
258
258
|
const genReq = this.coreOptions.buildGenericRequest(req);
|
|
259
|
+
if (!genReq.query) {
|
|
260
|
+
genReq.query = req["_tempQuery"];
|
|
261
|
+
}
|
|
262
|
+
if (!genReq.params)
|
|
263
|
+
genReq.params = req["_tempParams"];
|
|
259
264
|
let myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
|
|
260
265
|
let myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
|
|
261
266
|
await this.runWithRemult(async (remult) => {
|
|
@@ -618,22 +623,6 @@ export class RemultServerImplementation {
|
|
|
618
623
|
class ExpressRequestBridgeToDataApiRequest {
|
|
619
624
|
constructor(r) {
|
|
620
625
|
this.r = r;
|
|
621
|
-
if (!this.r.query) {
|
|
622
|
-
let query = {};
|
|
623
|
-
getUrlFromReq(this.r).searchParams.forEach((val, key) => {
|
|
624
|
-
let current = query[key];
|
|
625
|
-
if (!current) {
|
|
626
|
-
query[key] = val;
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
if (Array.isArray(current)) {
|
|
630
|
-
current.push(val);
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
query[key] = [current, val];
|
|
634
|
-
});
|
|
635
|
-
this.r.query = query;
|
|
636
|
-
}
|
|
637
626
|
}
|
|
638
627
|
get(key) {
|
|
639
628
|
return this.r.query[key];
|
|
@@ -869,8 +858,28 @@ class RouteImplementation {
|
|
|
869
858
|
}
|
|
870
859
|
middleware(origReq, res, next) {
|
|
871
860
|
const req = this.coreOptions.buildGenericRequest(origReq);
|
|
872
|
-
|
|
861
|
+
let theUrl = req.url;
|
|
862
|
+
if (theUrl.startsWith('/')) //next sends a partial url '/api/tasks' and not the full url
|
|
863
|
+
theUrl = 'http://stam' + theUrl;
|
|
864
|
+
const url = new URL(theUrl);
|
|
873
865
|
const path = url.pathname;
|
|
866
|
+
if (!req.query) {
|
|
867
|
+
let query = {};
|
|
868
|
+
url.searchParams.forEach((val, key) => {
|
|
869
|
+
let current = query[key];
|
|
870
|
+
if (!current) {
|
|
871
|
+
query[key] = val;
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
if (Array.isArray(current)) {
|
|
875
|
+
current.push(val);
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
query[key] = [current, val];
|
|
879
|
+
});
|
|
880
|
+
origReq["_tempQuery"] = query;
|
|
881
|
+
req.query = query;
|
|
882
|
+
}
|
|
874
883
|
let lowerPath = path.toLowerCase();
|
|
875
884
|
let m = this.map.get(lowerPath);
|
|
876
885
|
if (m) {
|
|
@@ -887,8 +896,10 @@ class RouteImplementation {
|
|
|
887
896
|
if (m) {
|
|
888
897
|
let h = m.get(req.method.toLowerCase());
|
|
889
898
|
if (h) {
|
|
890
|
-
if (!req.params)
|
|
899
|
+
if (!req.params) {
|
|
891
900
|
req.params = {};
|
|
901
|
+
origReq["_tempParams"] = req.params;
|
|
902
|
+
}
|
|
892
903
|
req.params.id = path.substring(idPosition + 1);
|
|
893
904
|
h(origReq, res, next);
|
|
894
905
|
return;
|
|
@@ -939,10 +950,3 @@ JobsInQueueEntity = __decorate([
|
|
|
939
950
|
], JobsInQueueEntity);
|
|
940
951
|
export { JobsInQueueEntity };
|
|
941
952
|
allEntities.splice(allEntities.indexOf(JobsInQueueEntity), 1);
|
|
942
|
-
function getUrlFromReq(req) {
|
|
943
|
-
let theUrl = req.url;
|
|
944
|
-
if (theUrl.startsWith('/')) //next sends a partial url '/api/tasks' and not the full url
|
|
945
|
-
theUrl = 'http://stam' + theUrl;
|
|
946
|
-
const url = new URL(theUrl);
|
|
947
|
-
return url;
|
|
948
|
-
}
|
package/package.json
CHANGED
package/server/expressBridge.js
CHANGED
|
@@ -478,6 +478,11 @@ var RemultServerImplementation = /** @class */ (function () {
|
|
|
478
478
|
switch (_a.label) {
|
|
479
479
|
case 0:
|
|
480
480
|
genReq = this.coreOptions.buildGenericRequest(req);
|
|
481
|
+
if (!genReq.query) {
|
|
482
|
+
genReq.query = req["_tempQuery"];
|
|
483
|
+
}
|
|
484
|
+
if (!genReq.params)
|
|
485
|
+
genReq.params = req["_tempParams"];
|
|
481
486
|
myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
|
|
482
487
|
myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
|
|
483
488
|
return [4 /*yield*/, this.runWithRemult(function (remult) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -902,22 +907,6 @@ exports.RemultServerImplementation = RemultServerImplementation;
|
|
|
902
907
|
var ExpressRequestBridgeToDataApiRequest = /** @class */ (function () {
|
|
903
908
|
function ExpressRequestBridgeToDataApiRequest(r) {
|
|
904
909
|
this.r = r;
|
|
905
|
-
if (!this.r.query) {
|
|
906
|
-
var query_1 = {};
|
|
907
|
-
getUrlFromReq(this.r).searchParams.forEach(function (val, key) {
|
|
908
|
-
var current = query_1[key];
|
|
909
|
-
if (!current) {
|
|
910
|
-
query_1[key] = val;
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
if (Array.isArray(current)) {
|
|
914
|
-
current.push(val);
|
|
915
|
-
return;
|
|
916
|
-
}
|
|
917
|
-
query_1[key] = [current, val];
|
|
918
|
-
});
|
|
919
|
-
this.r.query = query_1;
|
|
920
|
-
}
|
|
921
910
|
}
|
|
922
911
|
ExpressRequestBridgeToDataApiRequest.prototype.get = function (key) {
|
|
923
912
|
return this.r.query[key];
|
|
@@ -1243,8 +1232,28 @@ var RouteImplementation = /** @class */ (function () {
|
|
|
1243
1232
|
};
|
|
1244
1233
|
RouteImplementation.prototype.middleware = function (origReq, res, next) {
|
|
1245
1234
|
var req = this.coreOptions.buildGenericRequest(origReq);
|
|
1246
|
-
var
|
|
1235
|
+
var theUrl = req.url;
|
|
1236
|
+
if (theUrl.startsWith('/')) //next sends a partial url '/api/tasks' and not the full url
|
|
1237
|
+
theUrl = 'http://stam' + theUrl;
|
|
1238
|
+
var url = new URL(theUrl);
|
|
1247
1239
|
var path = url.pathname;
|
|
1240
|
+
if (!req.query) {
|
|
1241
|
+
var query_1 = {};
|
|
1242
|
+
url.searchParams.forEach(function (val, key) {
|
|
1243
|
+
var current = query_1[key];
|
|
1244
|
+
if (!current) {
|
|
1245
|
+
query_1[key] = val;
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
if (Array.isArray(current)) {
|
|
1249
|
+
current.push(val);
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
query_1[key] = [current, val];
|
|
1253
|
+
});
|
|
1254
|
+
origReq["_tempQuery"] = query_1;
|
|
1255
|
+
req.query = query_1;
|
|
1256
|
+
}
|
|
1248
1257
|
var lowerPath = path.toLowerCase();
|
|
1249
1258
|
var m = this.map.get(lowerPath);
|
|
1250
1259
|
if (m) {
|
|
@@ -1261,8 +1270,10 @@ var RouteImplementation = /** @class */ (function () {
|
|
|
1261
1270
|
if (m) {
|
|
1262
1271
|
var h = m.get(req.method.toLowerCase());
|
|
1263
1272
|
if (h) {
|
|
1264
|
-
if (!req.params)
|
|
1273
|
+
if (!req.params) {
|
|
1265
1274
|
req.params = {};
|
|
1275
|
+
origReq["_tempParams"] = req.params;
|
|
1276
|
+
}
|
|
1266
1277
|
req.params.id = path.substring(idPosition + 1);
|
|
1267
1278
|
h(origReq, res, next);
|
|
1268
1279
|
return;
|
|
@@ -1319,10 +1330,3 @@ var JobsInQueueEntity = /** @class */ (function (_super) {
|
|
|
1319
1330
|
}(id_entity_1.IdEntity));
|
|
1320
1331
|
exports.JobsInQueueEntity = JobsInQueueEntity;
|
|
1321
1332
|
context_1.allEntities.splice(context_1.allEntities.indexOf(JobsInQueueEntity), 1);
|
|
1322
|
-
function getUrlFromReq(req) {
|
|
1323
|
-
var theUrl = req.url;
|
|
1324
|
-
if (theUrl.startsWith('/')) //next sends a partial url '/api/tasks' and not the full url
|
|
1325
|
-
theUrl = 'http://stam' + theUrl;
|
|
1326
|
-
var url = new URL(theUrl);
|
|
1327
|
-
return url;
|
|
1328
|
-
}
|