@aeriajs/http 0.0.154 → 0.0.155
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 +4 -3
- package/dist/routing.mjs +4 -3
- package/package.json +1 -1
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);
|