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.
@@ -31,15 +31,16 @@ export interface RemultExpressBridge extends GenericRequestHandler {
31
31
  addArea(rootUrl: string): any;
32
32
  }
33
33
  export interface GenericRequest {
34
- method: any;
35
- url: any;
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.sendStatus(403);
483
+ this.setStatus(403).end();
483
484
  }
484
- sendStatus(status) {
485
- this.r.statusCode = status;
486
- this.r.end();
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.r.statusCode = 201;
495
- this.r.json(data);
496
+ this.setStatus(201).json(data);
496
497
  }
497
498
  deleted() {
498
- this.sendStatus(204);
499
+ this.setStatus(204).end();
499
500
  }
500
501
  notFound() {
501
- this.sendStatus(404);
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.r.statusCode = 400;
512
- this.r.json(data);
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:8000/api';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.14.20",
3
+ "version": "0.14.21",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -31,15 +31,16 @@ export interface RemultExpressBridge extends GenericRequestHandler {
31
31
  addArea(rootUrl: string): any;
32
32
  }
33
33
  export interface GenericRequest {
34
- method: any;
35
- url: any;
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 & {
@@ -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.sendStatus(403);
581
+ this.setStatus(403).end();
581
582
  };
582
- ExpressResponseBridgeToDataApiResponse.prototype.sendStatus = function (status) {
583
- this.r.statusCode = status;
584
- this.r.end();
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.r.statusCode = 201;
593
- this.r.json(data);
594
+ this.setStatus(201).json(data);
594
595
  };
595
596
  ExpressResponseBridgeToDataApiResponse.prototype.deleted = function () {
596
- this.sendStatus(204);
597
+ this.setStatus(204).end();
597
598
  };
598
599
  ExpressResponseBridgeToDataApiResponse.prototype.notFound = function () {
599
- this.sendStatus(404);
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.r.statusCode = 400;
611
- this.r.json(data);
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:8000/api';
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;