vovk 3.0.0-draft.21 → 3.0.0-draft.22
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/Segment.js
CHANGED
|
@@ -50,8 +50,9 @@ class _Segment {
|
|
|
50
50
|
},
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
|
-
#respondWithError = (statusCode, message, options) => {
|
|
53
|
+
#respondWithError = (statusCode, message, options, cause) => {
|
|
54
54
|
return this.respond(statusCode, {
|
|
55
|
+
cause,
|
|
55
56
|
statusCode,
|
|
56
57
|
message,
|
|
57
58
|
isError: true,
|
|
@@ -172,7 +173,7 @@ class _Segment {
|
|
|
172
173
|
}
|
|
173
174
|
if (err.message !== 'NEXT_REDIRECT' && err.message !== 'NEXT_NOT_FOUND') {
|
|
174
175
|
const statusCode = err.statusCode ?? types_1._HttpStatus.INTERNAL_SERVER_ERROR;
|
|
175
|
-
return this.#respondWithError(statusCode, err.message, staticMethod._options);
|
|
176
|
+
return this.#respondWithError(statusCode, err.message, staticMethod._options, err.cause);
|
|
176
177
|
}
|
|
177
178
|
throw e; // if NEXT_REDIRECT or NEXT_NOT_FOUND, rethrow it
|
|
178
179
|
}
|
package/client/defaultHandler.js
CHANGED
|
@@ -14,7 +14,8 @@ const _defaultHandler = async (response) => {
|
|
|
14
14
|
}
|
|
15
15
|
if (!response.ok) {
|
|
16
16
|
// handle server errors
|
|
17
|
-
|
|
17
|
+
const errorResponse = result;
|
|
18
|
+
throw new HttpException_1._HttpException(response.status, errorResponse?.message ?? exports.DEFAULT_ERROR_MESSAGE, errorResponse?.cause);
|
|
18
19
|
}
|
|
19
20
|
return result;
|
|
20
21
|
};
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
package/utils/getSchema.js
CHANGED
|
@@ -20,7 +20,7 @@ function getSchema(options) {
|
|
|
20
20
|
handlers: {
|
|
21
21
|
...(exposeValidation
|
|
22
22
|
? controller._handlers
|
|
23
|
-
: Object.fromEntries(Object.entries(controller._handlers).map(([key, value]) => [
|
|
23
|
+
: Object.fromEntries(Object.entries(controller._handlers ?? {}).map(([key, value]) => [
|
|
24
24
|
key,
|
|
25
25
|
{ ...value, validation: undefined },
|
|
26
26
|
]))),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _KnownAny as KnownAny } from '../types';
|
|
2
|
-
export default function setClientValidatorsForHandler(h: (...args: KnownAny[]) => KnownAny,
|
|
2
|
+
export default function setClientValidatorsForHandler(h: (...args: KnownAny[]) => KnownAny, validation: {
|
|
3
3
|
body: unknown;
|
|
4
4
|
query: unknown;
|
|
5
5
|
}): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = setClientValidatorsForHandler;
|
|
4
|
-
function setClientValidatorsForHandler(h,
|
|
4
|
+
function setClientValidatorsForHandler(h, validation) {
|
|
5
5
|
return new Promise((resolve) => {
|
|
6
6
|
setTimeout(() => {
|
|
7
7
|
const controller = h._controller;
|
|
@@ -16,10 +16,7 @@ function setClientValidatorsForHandler(h, validators) {
|
|
|
16
16
|
...controller._handlers,
|
|
17
17
|
[handlerName]: {
|
|
18
18
|
...controller._handlers[handlerName],
|
|
19
|
-
validation
|
|
20
|
-
body: validators.body,
|
|
21
|
-
query: validators.query,
|
|
22
|
-
},
|
|
19
|
+
validation,
|
|
23
20
|
},
|
|
24
21
|
};
|
|
25
22
|
resolve();
|