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.
- package/esm/remult-express.js +1 -1
- package/esm/server/expressBridge.d.ts +1 -1
- package/esm/server/expressBridge.js +1 -1
- package/esm/src/data-providers/rest-data-provider.d.ts +4 -1
- package/esm/src/data-providers/rest-data-provider.js +12 -11
- package/package.json +1 -1
- package/remult-express.js +2 -2
- package/server/expressBridge.d.ts +1 -1
- package/server/expressBridge.js +1 -1
- package/src/data-providers/rest-data-provider.d.ts +4 -1
- package/src/data-providers/rest-data-provider.js +12 -11
package/esm/remult-express.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
36
|
+
withRemult(req: GenericRequest, res: GenericResponse, next: VoidFunction): any;
|
|
37
37
|
}
|
|
38
38
|
export declare type GenericRouter = {
|
|
39
39
|
route(path: string): SpecificRoute;
|
|
@@ -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,
|
|
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'
|
|
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,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
140
|
+
headers['X-XSRF-TOKEN'] = cookie.split('=')[1];
|
|
145
141
|
}
|
|
146
142
|
}
|
|
147
|
-
return (this.fetch || fetch)(url,
|
|
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
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
|
-
|
|
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.
|
|
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
|
-
|
|
36
|
+
withRemult(req: GenericRequest, res: GenericResponse, next: VoidFunction): any;
|
|
37
37
|
}
|
|
38
38
|
export declare type GenericRouter = {
|
|
39
39
|
route(path: string): SpecificRoute;
|
package/server/expressBridge.js
CHANGED
|
@@ -109,7 +109,7 @@ var RemultServerImplementation = /** @class */ (function () {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
RemultServerImplementation.prototype.
|
|
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,
|
|
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'
|
|
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,
|
|
208
|
+
RestDataProviderHttpProviderUsingFetch.prototype.myFetch = function (url, options) {
|
|
209
209
|
var e_4, _a;
|
|
210
210
|
var _this = this;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
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,
|
|
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;
|