remult 0.14.25 → 0.14.26
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/remult-middleware.js
CHANGED
|
@@ -40,17 +40,23 @@ class middleware {
|
|
|
40
40
|
};
|
|
41
41
|
return route;
|
|
42
42
|
}
|
|
43
|
-
async handle(req) {
|
|
43
|
+
async handle(req, gRes) {
|
|
44
44
|
return new Promise(res => {
|
|
45
45
|
const response = new class {
|
|
46
46
|
json(data) {
|
|
47
|
+
if (gRes)
|
|
48
|
+
gRes.json(data);
|
|
47
49
|
res({ statusCode: this.statusCode, data });
|
|
48
50
|
}
|
|
49
51
|
status(statusCode) {
|
|
52
|
+
if (gRes)
|
|
53
|
+
gRes.status(statusCode);
|
|
50
54
|
this.statusCode = statusCode;
|
|
51
55
|
return this;
|
|
52
56
|
}
|
|
53
57
|
end() {
|
|
58
|
+
if (gRes)
|
|
59
|
+
gRes.end();
|
|
54
60
|
res({
|
|
55
61
|
statusCode: this.statusCode
|
|
56
62
|
});
|
package/package.json
CHANGED
package/remult-middleware.js
CHANGED
|
@@ -45,7 +45,7 @@ var middleware = /** @class */ (function () {
|
|
|
45
45
|
};
|
|
46
46
|
return route;
|
|
47
47
|
};
|
|
48
|
-
middleware.prototype.handle = function (req) {
|
|
48
|
+
middleware.prototype.handle = function (req, gRes) {
|
|
49
49
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
50
50
|
var _this = this;
|
|
51
51
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -54,13 +54,19 @@ var middleware = /** @class */ (function () {
|
|
|
54
54
|
function class_1() {
|
|
55
55
|
}
|
|
56
56
|
class_1.prototype.json = function (data) {
|
|
57
|
+
if (gRes)
|
|
58
|
+
gRes.json(data);
|
|
57
59
|
res({ statusCode: this.statusCode, data: data });
|
|
58
60
|
};
|
|
59
61
|
class_1.prototype.status = function (statusCode) {
|
|
62
|
+
if (gRes)
|
|
63
|
+
gRes.status(statusCode);
|
|
60
64
|
this.statusCode = statusCode;
|
|
61
65
|
return this;
|
|
62
66
|
};
|
|
63
67
|
class_1.prototype.end = function () {
|
|
68
|
+
if (gRes)
|
|
69
|
+
gRes.end();
|
|
64
70
|
res({
|
|
65
71
|
statusCode: this.statusCode
|
|
66
72
|
});
|