remult 0.25.6-exp.0 → 0.25.6-exp.1
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-next.js +1 -0
- package/esm/server/expressBridge.js +12 -8
- package/esm/src/data-providers/array-entity-data-provider.js +1 -1
- package/package.json +1 -1
- package/remult-next.d.ts +1 -0
- package/remult-next.js +1 -0
- package/server/expressBridge.js +14 -9
- package/src/data-providers/array-entity-data-provider.js +1 -1
package/esm/remult-next.js
CHANGED
|
@@ -7,6 +7,7 @@ export function remultNext(options) {
|
|
|
7
7
|
return Object.assign((req, res) => result.handle(req, res).then(() => { }), result, {
|
|
8
8
|
getRemult: (req) => result.getRemult(req),
|
|
9
9
|
openApiDoc: (arg) => result.openApiDoc(arg),
|
|
10
|
+
withRemult: (req, what) => result.withRemultAsync(req, what),
|
|
10
11
|
}, {
|
|
11
12
|
getServerSideProps: (getServerPropsFunction) => {
|
|
12
13
|
return (context) => {
|
|
@@ -274,12 +274,16 @@ export class RemultServerImplementation {
|
|
|
274
274
|
}
|
|
275
275
|
process(what) {
|
|
276
276
|
return async (req, origRes) => {
|
|
277
|
-
const genReq =
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
const genReq = req
|
|
278
|
+
? this.coreOptions.buildGenericRequestInfo(req)
|
|
279
|
+
: undefined;
|
|
280
|
+
if (req) {
|
|
281
|
+
if (!genReq.query) {
|
|
282
|
+
genReq.query = req['_tempQuery'];
|
|
283
|
+
}
|
|
284
|
+
if (!genReq.params)
|
|
285
|
+
genReq.params = req['_tempParams'];
|
|
280
286
|
}
|
|
281
|
-
if (!genReq.params)
|
|
282
|
-
genReq.params = req['_tempParams'];
|
|
283
287
|
let myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
|
|
284
288
|
let myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
|
|
285
289
|
await this.runWithRemult(async (remult) => {
|
|
@@ -653,7 +657,7 @@ export class RemultServerImplementation {
|
|
|
653
657
|
class ExpressRequestBridgeToDataApiRequest {
|
|
654
658
|
r;
|
|
655
659
|
get(key) {
|
|
656
|
-
return this.r
|
|
660
|
+
return this.r?.query[key];
|
|
657
661
|
}
|
|
658
662
|
constructor(r) {
|
|
659
663
|
this.r = r;
|
|
@@ -690,8 +694,8 @@ class ExpressResponseBridgeToDataApiResponse {
|
|
|
690
694
|
console.error({
|
|
691
695
|
message: data.message,
|
|
692
696
|
stack: data.stack?.split('\n'),
|
|
693
|
-
url: this.req
|
|
694
|
-
method: this.req
|
|
697
|
+
url: this.req?.url,
|
|
698
|
+
method: this.req?.method,
|
|
695
699
|
});
|
|
696
700
|
this.setStatus(400).json(data);
|
|
697
701
|
}
|
|
@@ -25,7 +25,7 @@ export class ArrayEntityDataProvider {
|
|
|
25
25
|
async init() {
|
|
26
26
|
if (this.__names)
|
|
27
27
|
return this.__names;
|
|
28
|
-
this.__names = await dbNamesOf(this.entity);
|
|
28
|
+
this.__names = await dbNamesOf(this.entity, (x) => x);
|
|
29
29
|
for (const r of this.rows) {
|
|
30
30
|
this.verifyThatRowHasAllNotNullColumns(r, this.__names);
|
|
31
31
|
}
|
package/package.json
CHANGED
package/remult-next.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type RemultNextServer = RemultServerCore<NextApiRequest> & NextApiHandler
|
|
|
9
9
|
} = {
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}, Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData>(getServerPropsFunction: GetServerSideProps<P, Q, D>): GetServerSideProps<P, Q, D>;
|
|
12
|
+
withRemult<T>(req: NextApiRequest | undefined, what: () => Promise<T>): Promise<T>;
|
|
12
13
|
/** Creates a `next.js` handler with remult defined in the correct context
|
|
13
14
|
* @see
|
|
14
15
|
* https://remult.dev/tutorials/react-next/appendix-1-get-server-side-props.html#using-remult-in-a-next-js-api-handler
|
package/remult-next.js
CHANGED
|
@@ -14,6 +14,7 @@ function remultNext(options) {
|
|
|
14
14
|
return Object.assign(function (req, res) { return result.handle(req, res).then(function () { }); }, result, {
|
|
15
15
|
getRemult: function (req) { return result.getRemult(req); },
|
|
16
16
|
openApiDoc: function (arg) { return result.openApiDoc(arg); },
|
|
17
|
+
withRemult: function (req, what) { return result.withRemultAsync(req, what); },
|
|
17
18
|
}, {
|
|
18
19
|
getServerSideProps: function (getServerPropsFunction) {
|
|
19
20
|
return function (context) {
|
package/server/expressBridge.js
CHANGED
|
@@ -532,12 +532,16 @@ var RemultServerImplementation = /** @class */ (function () {
|
|
|
532
532
|
return tslib_1.__generator(this, function (_a) {
|
|
533
533
|
switch (_a.label) {
|
|
534
534
|
case 0:
|
|
535
|
-
genReq =
|
|
536
|
-
|
|
537
|
-
|
|
535
|
+
genReq = req
|
|
536
|
+
? this.coreOptions.buildGenericRequestInfo(req)
|
|
537
|
+
: undefined;
|
|
538
|
+
if (req) {
|
|
539
|
+
if (!genReq.query) {
|
|
540
|
+
genReq.query = req['_tempQuery'];
|
|
541
|
+
}
|
|
542
|
+
if (!genReq.params)
|
|
543
|
+
genReq.params = req['_tempParams'];
|
|
538
544
|
}
|
|
539
|
-
if (!genReq.params)
|
|
540
|
-
genReq.params = req['_tempParams'];
|
|
541
545
|
myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
|
|
542
546
|
myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
|
|
543
547
|
return [4 /*yield*/, this.runWithRemult(function (remult) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -977,7 +981,8 @@ var ExpressRequestBridgeToDataApiRequest = /** @class */ (function () {
|
|
|
977
981
|
this.r = r;
|
|
978
982
|
}
|
|
979
983
|
ExpressRequestBridgeToDataApiRequest.prototype.get = function (key) {
|
|
980
|
-
|
|
984
|
+
var _a;
|
|
985
|
+
return (_a = this.r) === null || _a === void 0 ? void 0 : _a.query[key];
|
|
981
986
|
};
|
|
982
987
|
return ExpressRequestBridgeToDataApiRequest;
|
|
983
988
|
}());
|
|
@@ -1006,13 +1011,13 @@ var ExpressResponseBridgeToDataApiResponse = /** @class */ (function () {
|
|
|
1006
1011
|
this.setStatus(404).end();
|
|
1007
1012
|
};
|
|
1008
1013
|
ExpressResponseBridgeToDataApiResponse.prototype.error = function (data) {
|
|
1009
|
-
var _a;
|
|
1014
|
+
var _a, _b, _c;
|
|
1010
1015
|
data = (0, data_api_js_1.serializeError)(data);
|
|
1011
1016
|
console.error({
|
|
1012
1017
|
message: data.message,
|
|
1013
1018
|
stack: (_a = data.stack) === null || _a === void 0 ? void 0 : _a.split('\n'),
|
|
1014
|
-
url: this.req.url,
|
|
1015
|
-
method: this.req.method,
|
|
1019
|
+
url: (_b = this.req) === null || _b === void 0 ? void 0 : _b.url,
|
|
1020
|
+
method: (_c = this.req) === null || _c === void 0 ? void 0 : _c.method,
|
|
1016
1021
|
});
|
|
1017
1022
|
this.setStatus(400).json(data);
|
|
1018
1023
|
};
|
|
@@ -32,7 +32,7 @@ var ArrayEntityDataProvider = /** @class */ (function () {
|
|
|
32
32
|
if (this.__names)
|
|
33
33
|
return [2 /*return*/, this.__names];
|
|
34
34
|
_a = this;
|
|
35
|
-
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(this.entity)];
|
|
35
|
+
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(this.entity, function (x) { return x; })];
|
|
36
36
|
case 1:
|
|
37
37
|
_a.__names = _e.sent();
|
|
38
38
|
try {
|