remult 0.14.20 → 0.14.21
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.d.ts +5 -4
- package/esm/server/expressBridge.js +11 -10
- package/esm/src/backend-tests/test-http-server.backend-spec.js +1 -1
- package/package.json +1 -1
- package/server/expressBridge.d.ts +5 -4
- package/server/expressBridge.js +11 -10
- package/src/backend-tests/test-http-server.backend-spec.js +1 -1
|
@@ -31,15 +31,16 @@ export interface RemultExpressBridge extends GenericRequestHandler {
|
|
|
31
31
|
addArea(rootUrl: string): any;
|
|
32
32
|
}
|
|
33
33
|
export interface GenericRequest {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
url: string;
|
|
35
|
+
method?: any;
|
|
36
|
+
body?: any;
|
|
36
37
|
query?: any;
|
|
37
|
-
body: any;
|
|
38
38
|
params?: any;
|
|
39
39
|
}
|
|
40
40
|
export interface GenericResponse {
|
|
41
41
|
json(data: any): any;
|
|
42
|
-
statusCode: number;
|
|
42
|
+
status?(statusCode: number): GenericResponse;
|
|
43
|
+
setStatus?(statusCode: number): GenericResponse;
|
|
43
44
|
end(): any;
|
|
44
45
|
}
|
|
45
46
|
export declare type GenericRouter = GenericRequestHandler & {
|
|
@@ -58,6 +58,7 @@ export function remultMiddlewareBase(app, options) {
|
|
|
58
58
|
addArea: x => bridge.addArea(x)
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
;
|
|
61
62
|
class ExpressBridge {
|
|
62
63
|
constructor(app, queue, initRequest, dataProvider) {
|
|
63
64
|
this.app = app;
|
|
@@ -479,11 +480,12 @@ class ExpressResponseBridgeToDataApiResponse {
|
|
|
479
480
|
this.req = req;
|
|
480
481
|
}
|
|
481
482
|
forbidden() {
|
|
482
|
-
this.
|
|
483
|
+
this.setStatus(403).end();
|
|
483
484
|
}
|
|
484
|
-
|
|
485
|
-
this.r.
|
|
486
|
-
|
|
485
|
+
setStatus(status) {
|
|
486
|
+
if (this.r.setStatus)
|
|
487
|
+
return this.r.setStatus(status);
|
|
488
|
+
return this.r.status(status);
|
|
487
489
|
}
|
|
488
490
|
progress(progress) {
|
|
489
491
|
}
|
|
@@ -491,14 +493,13 @@ class ExpressResponseBridgeToDataApiResponse {
|
|
|
491
493
|
this.r.json(data);
|
|
492
494
|
}
|
|
493
495
|
created(data) {
|
|
494
|
-
this.
|
|
495
|
-
this.r.json(data);
|
|
496
|
+
this.setStatus(201).json(data);
|
|
496
497
|
}
|
|
497
498
|
deleted() {
|
|
498
|
-
this.
|
|
499
|
+
this.setStatus(204).end();
|
|
499
500
|
}
|
|
500
501
|
notFound() {
|
|
501
|
-
this.
|
|
502
|
+
this.setStatus(404).end();
|
|
502
503
|
}
|
|
503
504
|
error(data) {
|
|
504
505
|
data = serializeError(data);
|
|
@@ -508,8 +509,8 @@ class ExpressResponseBridgeToDataApiResponse {
|
|
|
508
509
|
url: this.req.url,
|
|
509
510
|
method: this.req.method
|
|
510
511
|
});
|
|
511
|
-
this.
|
|
512
|
-
|
|
512
|
+
this.setStatus(400).json(data);
|
|
513
|
+
;
|
|
513
514
|
}
|
|
514
515
|
}
|
|
515
516
|
function throwError() {
|
|
@@ -3,7 +3,7 @@ import axios from 'axios';
|
|
|
3
3
|
import { HttpProviderBridgeToRestDataProviderHttpProvider, Remult } from '../context';
|
|
4
4
|
import { Entity, Fields } from '../remult3';
|
|
5
5
|
import { Action, BackendMethod } from '../server-action';
|
|
6
|
-
Remult.apiBaseUrl = 'http://localhost:
|
|
6
|
+
Remult.apiBaseUrl = 'http://localhost:3001/api';
|
|
7
7
|
const path = Remult.apiBaseUrl + '/tasks';
|
|
8
8
|
fit("works", async () => {
|
|
9
9
|
const repo = await create3Tasks();
|
package/package.json
CHANGED
|
@@ -31,15 +31,16 @@ export interface RemultExpressBridge extends GenericRequestHandler {
|
|
|
31
31
|
addArea(rootUrl: string): any;
|
|
32
32
|
}
|
|
33
33
|
export interface GenericRequest {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
url: string;
|
|
35
|
+
method?: any;
|
|
36
|
+
body?: any;
|
|
36
37
|
query?: any;
|
|
37
|
-
body: any;
|
|
38
38
|
params?: any;
|
|
39
39
|
}
|
|
40
40
|
export interface GenericResponse {
|
|
41
41
|
json(data: any): any;
|
|
42
|
-
statusCode: number;
|
|
42
|
+
status?(statusCode: number): GenericResponse;
|
|
43
|
+
setStatus?(statusCode: number): GenericResponse;
|
|
43
44
|
end(): any;
|
|
44
45
|
}
|
|
45
46
|
export declare type GenericRouter = GenericRequestHandler & {
|
package/server/expressBridge.js
CHANGED
|
@@ -71,6 +71,7 @@ function remultMiddlewareBase(app, options) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
exports.remultMiddlewareBase = remultMiddlewareBase;
|
|
74
|
+
;
|
|
74
75
|
var ExpressBridge = /** @class */ (function () {
|
|
75
76
|
function ExpressBridge(app, queue, initRequest, dataProvider) {
|
|
76
77
|
this.app = app;
|
|
@@ -577,11 +578,12 @@ var ExpressResponseBridgeToDataApiResponse = /** @class */ (function () {
|
|
|
577
578
|
this.req = req;
|
|
578
579
|
}
|
|
579
580
|
ExpressResponseBridgeToDataApiResponse.prototype.forbidden = function () {
|
|
580
|
-
this.
|
|
581
|
+
this.setStatus(403).end();
|
|
581
582
|
};
|
|
582
|
-
ExpressResponseBridgeToDataApiResponse.prototype.
|
|
583
|
-
this.r.
|
|
584
|
-
|
|
583
|
+
ExpressResponseBridgeToDataApiResponse.prototype.setStatus = function (status) {
|
|
584
|
+
if (this.r.setStatus)
|
|
585
|
+
return this.r.setStatus(status);
|
|
586
|
+
return this.r.status(status);
|
|
585
587
|
};
|
|
586
588
|
ExpressResponseBridgeToDataApiResponse.prototype.progress = function (progress) {
|
|
587
589
|
};
|
|
@@ -589,14 +591,13 @@ var ExpressResponseBridgeToDataApiResponse = /** @class */ (function () {
|
|
|
589
591
|
this.r.json(data);
|
|
590
592
|
};
|
|
591
593
|
ExpressResponseBridgeToDataApiResponse.prototype.created = function (data) {
|
|
592
|
-
this.
|
|
593
|
-
this.r.json(data);
|
|
594
|
+
this.setStatus(201).json(data);
|
|
594
595
|
};
|
|
595
596
|
ExpressResponseBridgeToDataApiResponse.prototype.deleted = function () {
|
|
596
|
-
this.
|
|
597
|
+
this.setStatus(204).end();
|
|
597
598
|
};
|
|
598
599
|
ExpressResponseBridgeToDataApiResponse.prototype.notFound = function () {
|
|
599
|
-
this.
|
|
600
|
+
this.setStatus(404).end();
|
|
600
601
|
};
|
|
601
602
|
ExpressResponseBridgeToDataApiResponse.prototype.error = function (data) {
|
|
602
603
|
var _a;
|
|
@@ -607,8 +608,8 @@ var ExpressResponseBridgeToDataApiResponse = /** @class */ (function () {
|
|
|
607
608
|
url: this.req.url,
|
|
608
609
|
method: this.req.method
|
|
609
610
|
});
|
|
610
|
-
this.
|
|
611
|
-
|
|
611
|
+
this.setStatus(400).json(data);
|
|
612
|
+
;
|
|
612
613
|
};
|
|
613
614
|
return ExpressResponseBridgeToDataApiResponse;
|
|
614
615
|
}());
|
|
@@ -6,7 +6,7 @@ var axios_1 = require("axios");
|
|
|
6
6
|
var context_1 = require("../context");
|
|
7
7
|
var remult3_1 = require("../remult3");
|
|
8
8
|
var server_action_1 = require("../server-action");
|
|
9
|
-
context_1.Remult.apiBaseUrl = 'http://localhost:
|
|
9
|
+
context_1.Remult.apiBaseUrl = 'http://localhost:3001/api';
|
|
10
10
|
var path = context_1.Remult.apiBaseUrl + '/tasks';
|
|
11
11
|
fit("works", function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
12
12
|
var repo, tasks, _a;
|