remult 0.16.0-exp.11 → 0.16.0-exp.13

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.
@@ -18,6 +18,6 @@ export function remultExpress(options) {
18
18
  getRemult: (req) => server.getRemult(req),
19
19
  openApiDoc: (options) => server.openApiDoc(options),
20
20
  registerRouter: x => server.registerRouter(x),
21
- withRemultMiddleware: (...args) => server.withRemultMiddleware(...args)
21
+ withRemult: (...args) => server.withRemult(...args)
22
22
  });
23
23
  }
@@ -33,7 +33,7 @@ export interface RemultServer {
33
33
  }): any;
34
34
  registerRouter(r: GenericRouter): void;
35
35
  handle(req: GenericRequest, gRes?: GenericResponse): Promise<ServerHandleResponse | undefined>;
36
- withRemultMiddleware(req: GenericRequest, res: GenericResponse, next: VoidFunction): any;
36
+ withRemult(req: GenericRequest, res: GenericResponse, next: VoidFunction): any;
37
37
  }
38
38
  export declare type GenericRouter = {
39
39
  route(path: string): SpecificRoute;
@@ -82,7 +82,7 @@ class RemultServerImplementation {
82
82
  };
83
83
  }
84
84
  }
85
- withRemultMiddleware(req, res, next) {
85
+ withRemult(req, res, next) {
86
86
  this.process(async () => { next(); })(req, res);
87
87
  }
88
88
  handle(req, gRes) {
@@ -30,6 +30,9 @@ export declare class RestDataProviderHttpProviderUsingFetch implements RestDataP
30
30
  put(url: string, data: any): Promise<any>;
31
31
  delete(url: string): Promise<any>;
32
32
  post(url: string, data: any): Promise<any>;
33
- myFetch(url: string, init?: RequestInit): Promise<any>;
33
+ myFetch(url: string, options?: {
34
+ method?: string;
35
+ body?: string;
36
+ }): Promise<any>;
34
37
  }
35
38
  export declare function addFilterToUrlAndReturnTrueIfSuccessful(filter: any, url: UrlBuilder): boolean;
@@ -122,7 +122,7 @@ export class RestDataProviderHttpProviderUsingFetch {
122
122
  });
123
123
  }
124
124
  delete(url) {
125
- return this.myFetch(url, { method: 'delete', credentials: 'include' });
125
+ return this.myFetch(url, { method: 'delete' });
126
126
  }
127
127
  async post(url, data) {
128
128
  return await retry(() => this.myFetch(url, {
@@ -130,21 +130,22 @@ export class RestDataProviderHttpProviderUsingFetch {
130
130
  body: JSON.stringify(data)
131
131
  }));
132
132
  }
133
- myFetch(url, init) {
134
- if (!init)
135
- init = {};
136
- if (!init.headers)
137
- init.headers = new Headers();
138
- var h = init.headers;
139
- h.append('Content-type', "application/json");
140
- init.credentials = 'include';
133
+ myFetch(url, options) {
134
+ const headers = {
135
+ "Content-type": "application/json"
136
+ };
141
137
  if (typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof (window.document.cookie !== 'undefined'))
142
138
  for (const cookie of window.document.cookie.split(';')) {
143
139
  if (cookie.trim().startsWith('XSRF-TOKEN=')) {
144
- h.append('X-XSRF-TOKEN', cookie.split('=')[1]);
140
+ headers['X-XSRF-TOKEN'] = cookie.split('=')[1];
145
141
  }
146
142
  }
147
- return (this.fetch || fetch)(url, init).then(response => {
143
+ return (this.fetch || fetch)(url, {
144
+ credentials: 'include',
145
+ method: options?.method,
146
+ body: options?.body,
147
+ headers
148
+ }).then(response => {
148
149
  return onSuccess(response);
149
150
  }).catch(async (error) => {
150
151
  let r = await error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.16.0-exp.11",
3
+ "version": "0.16.0-exp.13",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/remult-express.js CHANGED
@@ -22,12 +22,12 @@ function remultExpress(options) {
22
22
  getRemult: function (req) { return server.getRemult(req); },
23
23
  openApiDoc: function (options) { return server.openApiDoc(options); },
24
24
  registerRouter: function (x) { return server.registerRouter(x); },
25
- withRemultMiddleware: function () {
25
+ withRemult: function () {
26
26
  var args = [];
27
27
  for (var _i = 0; _i < arguments.length; _i++) {
28
28
  args[_i] = arguments[_i];
29
29
  }
30
- return server.withRemultMiddleware.apply(server, tslib_1.__spread(args));
30
+ return server.withRemult.apply(server, tslib_1.__spread(args));
31
31
  }
32
32
  });
33
33
  }
@@ -33,7 +33,7 @@ export interface RemultServer {
33
33
  }): any;
34
34
  registerRouter(r: GenericRouter): void;
35
35
  handle(req: GenericRequest, gRes?: GenericResponse): Promise<ServerHandleResponse | undefined>;
36
- withRemultMiddleware(req: GenericRequest, res: GenericResponse, next: VoidFunction): any;
36
+ withRemult(req: GenericRequest, res: GenericResponse, next: VoidFunction): any;
37
37
  }
38
38
  export declare type GenericRouter = {
39
39
  route(path: string): SpecificRoute;
@@ -109,7 +109,7 @@ var RemultServerImplementation = /** @class */ (function () {
109
109
  };
110
110
  }
111
111
  }
112
- RemultServerImplementation.prototype.withRemultMiddleware = function (req, res, next) {
112
+ RemultServerImplementation.prototype.withRemult = function (req, res, next) {
113
113
  var _this = this;
114
114
  this.process(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
115
115
  next();
@@ -30,6 +30,9 @@ export declare class RestDataProviderHttpProviderUsingFetch implements RestDataP
30
30
  put(url: string, data: any): Promise<any>;
31
31
  delete(url: string): Promise<any>;
32
32
  post(url: string, data: any): Promise<any>;
33
- myFetch(url: string, init?: RequestInit): Promise<any>;
33
+ myFetch(url: string, options?: {
34
+ method?: string;
35
+ body?: string;
36
+ }): Promise<any>;
34
37
  }
35
38
  export declare function addFilterToUrlAndReturnTrueIfSuccessful(filter: any, url: UrlBuilder): boolean;
@@ -189,7 +189,7 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
189
189
  });
190
190
  };
191
191
  RestDataProviderHttpProviderUsingFetch.prototype.delete = function (url) {
192
- return this.myFetch(url, { method: 'delete', credentials: 'include' });
192
+ return this.myFetch(url, { method: 'delete' });
193
193
  };
194
194
  RestDataProviderHttpProviderUsingFetch.prototype.post = function (url, data) {
195
195
  return tslib_1.__awaiter(this, void 0, void 0, function () {
@@ -205,22 +205,18 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
205
205
  });
206
206
  });
207
207
  };
208
- RestDataProviderHttpProviderUsingFetch.prototype.myFetch = function (url, init) {
208
+ RestDataProviderHttpProviderUsingFetch.prototype.myFetch = function (url, options) {
209
209
  var e_4, _a;
210
210
  var _this = this;
211
- if (!init)
212
- init = {};
213
- if (!init.headers)
214
- init.headers = new Headers();
215
- var h = init.headers;
216
- h.append('Content-type', "application/json");
217
- init.credentials = 'include';
211
+ var headers = {
212
+ "Content-type": "application/json"
213
+ };
218
214
  if (typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof (window.document.cookie !== 'undefined'))
219
215
  try {
220
216
  for (var _b = tslib_1.__values(window.document.cookie.split(';')), _c = _b.next(); !_c.done; _c = _b.next()) {
221
217
  var cookie = _c.value;
222
218
  if (cookie.trim().startsWith('XSRF-TOKEN=')) {
223
- h.append('X-XSRF-TOKEN', cookie.split('=')[1]);
219
+ headers['X-XSRF-TOKEN'] = cookie.split('=')[1];
224
220
  }
225
221
  }
226
222
  }
@@ -231,7 +227,12 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
231
227
  }
232
228
  finally { if (e_4) throw e_4.error; }
233
229
  }
234
- return (this.fetch || fetch)(url, init).then(function (response) {
230
+ return (this.fetch || fetch)(url, {
231
+ credentials: 'include',
232
+ method: options === null || options === void 0 ? void 0 : options.method,
233
+ body: options === null || options === void 0 ? void 0 : options.body,
234
+ headers: headers
235
+ }).then(function (response) {
235
236
  return onSuccess(response);
236
237
  }).catch(function (error) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
237
238
  var r;