@aeriajs/http 0.0.154 → 0.0.156

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/routing.js CHANGED
@@ -20,7 +20,7 @@ const checkUnprocessable = (what, schema, context, validateOptions = {}) => {
20
20
  else {
21
21
  result = (0, validation_1.validate)(what, schema, validateOptions);
22
22
  }
23
- const { error } = result;
23
+ const { error, result: validated } = result;
24
24
  if (error) {
25
25
  if ('code' in error) {
26
26
  return context.error(types_1.HTTPStatus.UnprocessableContent, {
@@ -34,7 +34,7 @@ const checkUnprocessable = (what, schema, context, validateOptions = {}) => {
34
34
  details: error,
35
35
  });
36
36
  }
37
- return types_1.Result.result({});
37
+ return types_1.Result.result(validated);
38
38
  };
39
39
  const matches = (req, method, exp, options = {}, config) => {
40
40
  const base = config?.baseUrl && config.baseUrl !== '/'
@@ -100,12 +100,13 @@ const registerRoute = async (context, method, exp, cb, contract, options = {}) =
100
100
  }
101
101
  }
102
102
  if ('query' in contract && contract.query) {
103
- const { error } = checkUnprocessable(context.request.query, contract.query, context, {
103
+ const { error, result: validated } = checkUnprocessable(context.request.query, contract.query, context, {
104
104
  coerce: true,
105
105
  });
106
106
  if (error) {
107
107
  return types_1.Result.error(error);
108
108
  }
109
+ context.request.query = validated;
109
110
  }
110
111
  }
111
112
  const result = await cb(context);
package/dist/routing.mjs CHANGED
@@ -17,7 +17,7 @@ const checkUnprocessable = (what, schema, context, validateOptions = {}) => {
17
17
  } else {
18
18
  result = validate(what, schema, validateOptions);
19
19
  }
20
- const { error } = result;
20
+ const { error, result: validated } = result;
21
21
  if (error) {
22
22
  if ("code" in error) {
23
23
  return context.error(HTTPStatus.UnprocessableContent, {
@@ -31,7 +31,7 @@ const checkUnprocessable = (what, schema, context, validateOptions = {}) => {
31
31
  details: error
32
32
  });
33
33
  }
34
- return Result.result({});
34
+ return Result.result(validated);
35
35
  };
36
36
  export const matches = (req, method, exp, options = {}, config) => {
37
37
  const base = config?.baseUrl && config.baseUrl !== "/" ? options.base ? `${config.baseUrl}${options.base}` : config.baseUrl : options.base ? options.base : "";
@@ -97,12 +97,13 @@ export const registerRoute = async (context, method, exp, cb, contract, options
97
97
  }
98
98
  }
99
99
  if ("query" in contract && contract.query) {
100
- const { error } = checkUnprocessable(context.request.query, contract.query, context, {
100
+ const { error, result: validated } = checkUnprocessable(context.request.query, contract.query, context, {
101
101
  coerce: true
102
102
  });
103
103
  if (error) {
104
104
  return Result.error(error);
105
105
  }
106
+ context.request.query = validated;
106
107
  }
107
108
  }
108
109
  const result = await cb(context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/http",
3
- "version": "0.0.154",
3
+ "version": "0.0.156",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,10 +28,10 @@
28
28
  "@aeriajs/validation": "link:../validation"
29
29
  },
30
30
  "peerDependencies": {
31
- "@aeriajs/common": "^0.0.128",
32
- "@aeriajs/entrypoint": "^0.0.131",
33
- "@aeriajs/types": "^0.0.110",
34
- "@aeriajs/validation": "^0.0.143"
31
+ "@aeriajs/common": "^0.0.129",
32
+ "@aeriajs/entrypoint": "^0.0.132",
33
+ "@aeriajs/types": "^0.0.111",
34
+ "@aeriajs/validation": "^0.0.144"
35
35
  },
36
36
  "scripts": {
37
37
  "test": "vitest run",