remult 0.20.0-exp.4 → 0.20.0-exp.6
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 +27 -22
- package/package.json +1 -1
- package/server/expressBridge.js +28 -23
|
@@ -255,7 +255,8 @@ export class RemultServerImplementation {
|
|
|
255
255
|
}
|
|
256
256
|
process(what) {
|
|
257
257
|
return async (req, origRes) => {
|
|
258
|
-
|
|
258
|
+
const genReq = this.coreOptions.buildGenericRequest(req);
|
|
259
|
+
let myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
|
|
259
260
|
let myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
|
|
260
261
|
await this.runWithRemult(async (remult) => {
|
|
261
262
|
remult.liveQueryPublisher = new LiveQueryPublisher(() => remult.subscriptionServer, () => remult.liveQueryStorage, this.runWithSerializedJsonContextData);
|
|
@@ -285,7 +286,7 @@ export class RemultServerImplementation {
|
|
|
285
286
|
});
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
|
-
await what(remult, myReq, myRes,
|
|
289
|
+
await what(remult, myReq, myRes, genReq, origRes);
|
|
289
290
|
});
|
|
290
291
|
};
|
|
291
292
|
}
|
|
@@ -617,6 +618,22 @@ export class RemultServerImplementation {
|
|
|
617
618
|
class ExpressRequestBridgeToDataApiRequest {
|
|
618
619
|
constructor(r) {
|
|
619
620
|
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
|
+
}
|
|
620
637
|
}
|
|
621
638
|
get(key) {
|
|
622
639
|
return this.r.query[key];
|
|
@@ -852,27 +869,8 @@ class RouteImplementation {
|
|
|
852
869
|
}
|
|
853
870
|
middleware(origReq, res, next) {
|
|
854
871
|
const req = this.coreOptions.buildGenericRequest(origReq);
|
|
855
|
-
|
|
856
|
-
if (theUrl.startsWith('/')) //next sends a partial url '/api/tasks' and not the full url
|
|
857
|
-
theUrl = 'http://stam' + theUrl;
|
|
858
|
-
const url = new URL(theUrl);
|
|
872
|
+
const url = getUrlFromReq(req);
|
|
859
873
|
const path = url.pathname;
|
|
860
|
-
if (!req.query) {
|
|
861
|
-
let query = {};
|
|
862
|
-
url.searchParams.forEach((val, key) => {
|
|
863
|
-
let current = query[key];
|
|
864
|
-
if (!current) {
|
|
865
|
-
query[key] = val;
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
if (Array.isArray(current)) {
|
|
869
|
-
current.push(val);
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
query[key] = [current, val];
|
|
873
|
-
});
|
|
874
|
-
req.query = query;
|
|
875
|
-
}
|
|
876
874
|
let lowerPath = path.toLowerCase();
|
|
877
875
|
let m = this.map.get(lowerPath);
|
|
878
876
|
if (m) {
|
|
@@ -941,3 +939,10 @@ JobsInQueueEntity = __decorate([
|
|
|
941
939
|
], JobsInQueueEntity);
|
|
942
940
|
export { JobsInQueueEntity };
|
|
943
941
|
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
|
@@ -472,12 +472,13 @@ var RemultServerImplementation = /** @class */ (function () {
|
|
|
472
472
|
RemultServerImplementation.prototype.process = function (what) {
|
|
473
473
|
var _this = this;
|
|
474
474
|
return function (req, origRes) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
475
|
-
var myReq, myRes;
|
|
475
|
+
var genReq, myReq, myRes;
|
|
476
476
|
var _this = this;
|
|
477
477
|
return tslib_1.__generator(this, function (_a) {
|
|
478
478
|
switch (_a.label) {
|
|
479
479
|
case 0:
|
|
480
|
-
|
|
480
|
+
genReq = this.coreOptions.buildGenericRequest(req);
|
|
481
|
+
myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
|
|
481
482
|
myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
|
|
482
483
|
return [4 /*yield*/, this.runWithRemult(function (remult) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
483
484
|
var _a, user;
|
|
@@ -519,7 +520,7 @@ var RemultServerImplementation = /** @class */ (function () {
|
|
|
519
520
|
case 5:
|
|
520
521
|
_b.sent();
|
|
521
522
|
_b.label = 6;
|
|
522
|
-
case 6: return [4 /*yield*/, what(remult, myReq, myRes,
|
|
523
|
+
case 6: return [4 /*yield*/, what(remult, myReq, myRes, genReq, origRes)];
|
|
523
524
|
case 7:
|
|
524
525
|
_b.sent();
|
|
525
526
|
return [2 /*return*/];
|
|
@@ -901,6 +902,22 @@ exports.RemultServerImplementation = RemultServerImplementation;
|
|
|
901
902
|
var ExpressRequestBridgeToDataApiRequest = /** @class */ (function () {
|
|
902
903
|
function ExpressRequestBridgeToDataApiRequest(r) {
|
|
903
904
|
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
|
+
}
|
|
904
921
|
}
|
|
905
922
|
ExpressRequestBridgeToDataApiRequest.prototype.get = function (key) {
|
|
906
923
|
return this.r.query[key];
|
|
@@ -1226,27 +1243,8 @@ var RouteImplementation = /** @class */ (function () {
|
|
|
1226
1243
|
};
|
|
1227
1244
|
RouteImplementation.prototype.middleware = function (origReq, res, next) {
|
|
1228
1245
|
var req = this.coreOptions.buildGenericRequest(origReq);
|
|
1229
|
-
var
|
|
1230
|
-
if (theUrl.startsWith('/')) //next sends a partial url '/api/tasks' and not the full url
|
|
1231
|
-
theUrl = 'http://stam' + theUrl;
|
|
1232
|
-
var url = new URL(theUrl);
|
|
1246
|
+
var url = getUrlFromReq(req);
|
|
1233
1247
|
var path = url.pathname;
|
|
1234
|
-
if (!req.query) {
|
|
1235
|
-
var query_1 = {};
|
|
1236
|
-
url.searchParams.forEach(function (val, key) {
|
|
1237
|
-
var current = query_1[key];
|
|
1238
|
-
if (!current) {
|
|
1239
|
-
query_1[key] = val;
|
|
1240
|
-
return;
|
|
1241
|
-
}
|
|
1242
|
-
if (Array.isArray(current)) {
|
|
1243
|
-
current.push(val);
|
|
1244
|
-
return;
|
|
1245
|
-
}
|
|
1246
|
-
query_1[key] = [current, val];
|
|
1247
|
-
});
|
|
1248
|
-
req.query = query_1;
|
|
1249
|
-
}
|
|
1250
1248
|
var lowerPath = path.toLowerCase();
|
|
1251
1249
|
var m = this.map.get(lowerPath);
|
|
1252
1250
|
if (m) {
|
|
@@ -1321,3 +1319,10 @@ var JobsInQueueEntity = /** @class */ (function (_super) {
|
|
|
1321
1319
|
}(id_entity_1.IdEntity));
|
|
1322
1320
|
exports.JobsInQueueEntity = JobsInQueueEntity;
|
|
1323
1321
|
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
|
+
}
|