@tahminator/sapling 2.0.2-beta.131088cd → 2.0.2-beta.62de85fd

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/dist/index.cjs CHANGED
@@ -695,13 +695,20 @@ Split these into separate @MiddlewareClass classes, or merge the logic into a si
695
695
  if (schemas.body) request.body = await _parseOrThrow(schemas.body, request.body, "reqbody");
696
696
  if (schemas.param) request.params = await _parseOrThrow(schemas.param, request.params, "reqparams");
697
697
  if (schemas.query) {
698
+ console.log("schemas.query exists");
699
+ console.log("schemas.query exists as " + JSON.stringify(schemas.query));
698
700
  const parsedQuery = await _parseOrThrow(schemas.query, request.query, "reqquery");
699
- if (request.query && typeof request.query === "object") {
700
- Object.keys(request.query).forEach((key) => {
701
- delete request.query[key];
701
+ console.log({ parsedQuery: JSON.stringify(parsedQuery) });
702
+ try {
703
+ Object.defineProperty(request, "query", {
704
+ value: parsedQuery,
705
+ writable: true,
706
+ configurable: true
702
707
  });
703
- Object.assign(request.query, parsedQuery);
708
+ } catch {
709
+ request.query = parsedQuery;
704
710
  }
711
+ console.log("request.query rewritten, now is", { query: JSON.stringify(request.query) });
705
712
  }
706
713
  }
707
714
  const result = await fn.bind(controllerInstance)(request, response, next);
package/dist/index.mjs CHANGED
@@ -671,13 +671,20 @@ Split these into separate @MiddlewareClass classes, or merge the logic into a si
671
671
  if (schemas.body) request.body = await _parseOrThrow(schemas.body, request.body, "reqbody");
672
672
  if (schemas.param) request.params = await _parseOrThrow(schemas.param, request.params, "reqparams");
673
673
  if (schemas.query) {
674
+ console.log("schemas.query exists");
675
+ console.log("schemas.query exists as " + JSON.stringify(schemas.query));
674
676
  const parsedQuery = await _parseOrThrow(schemas.query, request.query, "reqquery");
675
- if (request.query && typeof request.query === "object") {
676
- Object.keys(request.query).forEach((key) => {
677
- delete request.query[key];
677
+ console.log({ parsedQuery: JSON.stringify(parsedQuery) });
678
+ try {
679
+ Object.defineProperty(request, "query", {
680
+ value: parsedQuery,
681
+ writable: true,
682
+ configurable: true
678
683
  });
679
- Object.assign(request.query, parsedQuery);
684
+ } catch {
685
+ request.query = parsedQuery;
680
686
  }
687
+ console.log("request.query rewritten, now is", { query: JSON.stringify(request.query) });
681
688
  }
682
689
  }
683
690
  const result = await fn.bind(controllerInstance)(request, response, next);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tahminator/sapling",
3
- "version": "2.0.2-beta.131088cd",
3
+ "version": "2.0.2-beta.62de85fd",
4
4
  "author": "Tahmid Ahmed",
5
5
  "description": "A library to help you write cleaner Express.js code",
6
6
  "repository": {