@nestia/core 7.3.0 → 7.3.2
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/lib/decorators/DynamicModule.d.ts +3 -2
- package/lib/decorators/DynamicModule.js +3 -2
- package/lib/decorators/DynamicModule.js.map +1 -1
- package/lib/decorators/EncryptedBody.d.ts +11 -11
- package/lib/decorators/EncryptedBody.js +13 -17
- package/lib/decorators/EncryptedBody.js.map +1 -1
- package/lib/decorators/EncryptedController.d.ts +15 -13
- package/lib/decorators/EncryptedController.js +15 -13
- package/lib/decorators/EncryptedController.js.map +1 -1
- package/lib/decorators/EncryptedModule.d.ts +22 -22
- package/lib/decorators/EncryptedModule.js +23 -25
- package/lib/decorators/EncryptedModule.js.map +1 -1
- package/lib/decorators/EncryptedRoute.d.ts +20 -20
- package/lib/decorators/EncryptedRoute.js +23 -29
- package/lib/decorators/EncryptedRoute.js.map +1 -1
- package/lib/decorators/HumanRoute.d.ts +3 -3
- package/lib/decorators/HumanRoute.js +3 -3
- package/lib/decorators/NoTransformConfigurationError.d.ts +10 -8
- package/lib/decorators/NoTransformConfigurationError.js +10 -8
- package/lib/decorators/NoTransformConfigurationError.js.map +1 -1
- package/lib/decorators/PlainBody.d.ts +7 -6
- package/lib/decorators/PlainBody.js +2 -6
- package/lib/decorators/PlainBody.js.map +1 -1
- package/lib/decorators/SwaggerCustomizer.d.ts +12 -30
- package/lib/decorators/SwaggerCustomizer.js +3 -3
- package/lib/decorators/TypedBody.d.ts +7 -7
- package/lib/decorators/TypedBody.js +8 -10
- package/lib/decorators/TypedBody.js.map +1 -1
- package/lib/decorators/TypedException.d.ts +41 -58
- package/lib/decorators/TypedException.js +1 -3
- package/lib/decorators/TypedException.js.map +1 -1
- package/lib/decorators/TypedFormData.d.ts +16 -16
- package/lib/decorators/TypedFormData.js +17 -23
- package/lib/decorators/TypedFormData.js.map +1 -1
- package/lib/decorators/TypedHeaders.d.ts +27 -25
- package/lib/decorators/TypedHeaders.js +27 -25
- package/lib/decorators/TypedHeaders.js.map +1 -1
- package/lib/decorators/TypedParam.d.ts +5 -5
- package/lib/decorators/TypedParam.js +5 -5
- package/lib/decorators/TypedQuery.d.ts +7 -6
- package/lib/decorators/TypedQuery.js +13 -24
- package/lib/decorators/TypedQuery.js.map +1 -1
- package/lib/decorators/TypedRoute.d.ts +24 -34
- package/lib/decorators/TypedRoute.js +19 -28
- package/lib/decorators/TypedRoute.js.map +1 -1
- package/lib/decorators/WebSocketRoute.d.ts +33 -31
- package/lib/decorators/WebSocketRoute.js +34 -34
- package/lib/decorators/WebSocketRoute.js.map +1 -1
- package/lib/decorators/internal/EncryptedConstant.js +1 -3
- package/lib/decorators/internal/EncryptedConstant.js.map +1 -1
- package/lib/decorators/internal/get_path_and_querify.js +7 -21
- package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
- package/lib/decorators/internal/get_path_and_stringify.js +6 -18
- package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
- package/lib/decorators/internal/get_text_body.js +2 -6
- package/lib/decorators/internal/get_text_body.js.map +1 -1
- package/lib/decorators/internal/headers_to_object.js +1 -3
- package/lib/decorators/internal/headers_to_object.js.map +1 -1
- package/lib/decorators/internal/is_request_body_undefined.js +1 -3
- package/lib/decorators/internal/is_request_body_undefined.js.map +1 -1
- package/lib/decorators/internal/load_controller.js +3 -7
- package/lib/decorators/internal/load_controller.js.map +1 -1
- package/lib/decorators/internal/route_error.js +1 -3
- package/lib/decorators/internal/route_error.js.map +1 -1
- package/lib/decorators/internal/validate_request_body.js +5 -15
- package/lib/decorators/internal/validate_request_body.js.map +1 -1
- package/lib/decorators/internal/validate_request_form_data.js +5 -15
- package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
- package/lib/decorators/internal/validate_request_headers.js +5 -15
- package/lib/decorators/internal/validate_request_headers.js.map +1 -1
- package/lib/decorators/internal/validate_request_query.js +5 -15
- package/lib/decorators/internal/validate_request_query.js.map +1 -1
- package/lib/utils/ExceptionManager.d.ts +27 -20
- package/lib/utils/ExceptionManager.js +20 -20
- package/lib/utils/ExceptionManager.js.map +1 -1
- package/lib/utils/Singleton.js +2 -6
- package/lib/utils/Singleton.js.map +1 -1
- package/lib/utils/SourceFinder.js +4 -8
- package/lib/utils/SourceFinder.js.map +1 -1
- package/package.json +7 -8
- package/src/decorators/DynamicModule.ts +3 -2
- package/src/decorators/EncryptedBody.ts +13 -17
- package/src/decorators/EncryptedController.ts +15 -13
- package/src/decorators/EncryptedModule.ts +23 -25
- package/src/decorators/EncryptedRoute.ts +23 -29
- package/src/decorators/HumanRoute.ts +3 -3
- package/src/decorators/NoTransformConfigurationError.ts +10 -8
- package/src/decorators/PlainBody.ts +9 -12
- package/src/decorators/SwaggerCustomizer.ts +12 -30
- package/src/decorators/TypedBody.ts +8 -10
- package/src/decorators/TypedException.ts +42 -61
- package/src/decorators/TypedFormData.ts +34 -34
- package/src/decorators/TypedHeaders.ts +27 -25
- package/src/decorators/TypedParam.ts +5 -5
- package/src/decorators/TypedQuery.ts +13 -24
- package/src/decorators/TypedRoute.ts +28 -46
- package/src/decorators/WebSocketRoute.ts +34 -34
- package/src/decorators/internal/EncryptedConstant.ts +1 -3
- package/src/decorators/internal/get_path_and_querify.ts +7 -21
- package/src/decorators/internal/get_path_and_stringify.ts +6 -18
- package/src/decorators/internal/get_text_body.ts +2 -6
- package/src/decorators/internal/headers_to_object.ts +1 -3
- package/src/decorators/internal/is_request_body_undefined.ts +1 -3
- package/src/decorators/internal/load_controller.ts +3 -7
- package/src/decorators/internal/route_error.ts +1 -3
- package/src/decorators/internal/validate_request_body.ts +5 -15
- package/src/decorators/internal/validate_request_form_data.ts +5 -15
- package/src/decorators/internal/validate_request_headers.ts +5 -15
- package/src/decorators/internal/validate_request_query.ts +5 -15
- package/src/utils/ExceptionManager.ts +29 -26
- package/src/utils/Singleton.ts +2 -6
- package/src/utils/SourceFinder.ts +5 -8
|
@@ -4,9 +4,7 @@ import typia, { IValidation, TypeGuardError } from "typia";
|
|
|
4
4
|
import { IResponseBodyQuerifier } from "../../options/IResponseBodyQuerifier";
|
|
5
5
|
import { NoTransformConfigurationError } from "../NoTransformConfigurationError";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
7
|
+
/** @internal */
|
|
10
8
|
export const get_path_and_querify =
|
|
11
9
|
(method: string) =>
|
|
12
10
|
(
|
|
@@ -23,9 +21,7 @@ export const get_path_and_querify =
|
|
|
23
21
|
return [path ?? undefined, take(method)(functor)];
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
24
|
+
/** @internal */
|
|
29
25
|
const take =
|
|
30
26
|
(method: string) =>
|
|
31
27
|
<T>(functor?: IResponseBodyQuerifier<T> | null) => {
|
|
@@ -42,9 +38,7 @@ const take =
|
|
|
42
38
|
);
|
|
43
39
|
};
|
|
44
40
|
|
|
45
|
-
/**
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
41
|
+
/** @internal */
|
|
48
42
|
const querify = (input: Record<string, any>): URLSearchParams => {
|
|
49
43
|
const output: URLSearchParams = new URLSearchParams();
|
|
50
44
|
for (const [key, value] of Object.entries(input))
|
|
@@ -55,9 +49,7 @@ const querify = (input: Record<string, any>): URLSearchParams => {
|
|
|
55
49
|
return output;
|
|
56
50
|
};
|
|
57
51
|
|
|
58
|
-
/**
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
52
|
+
/** @internal */
|
|
61
53
|
const assert =
|
|
62
54
|
<T>(closure: (data: T) => URLSearchParams) =>
|
|
63
55
|
(data: T) => {
|
|
@@ -76,9 +68,7 @@ const assert =
|
|
|
76
68
|
}
|
|
77
69
|
};
|
|
78
70
|
|
|
79
|
-
/**
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
71
|
+
/** @internal */
|
|
82
72
|
const is =
|
|
83
73
|
<T>(closure: (data: T) => URLSearchParams | null) =>
|
|
84
74
|
(data: T) => {
|
|
@@ -87,9 +77,7 @@ const is =
|
|
|
87
77
|
return result;
|
|
88
78
|
};
|
|
89
79
|
|
|
90
|
-
/**
|
|
91
|
-
* @internal
|
|
92
|
-
*/
|
|
80
|
+
/** @internal */
|
|
93
81
|
const validate =
|
|
94
82
|
<T>(closure: (data: T) => IValidation<URLSearchParams>) =>
|
|
95
83
|
(data: T) => {
|
|
@@ -102,7 +90,5 @@ const validate =
|
|
|
102
90
|
return result.data;
|
|
103
91
|
};
|
|
104
92
|
|
|
105
|
-
/**
|
|
106
|
-
* @internal
|
|
107
|
-
*/
|
|
93
|
+
/** @internal */
|
|
108
94
|
const MESSAGE = "Response body data is not following the promised type.";
|
|
@@ -5,9 +5,7 @@ import { IResponseBodyStringifier } from "../../options/IResponseBodyStringifier
|
|
|
5
5
|
import { NoTransformConfigurationError } from "../NoTransformConfigurationError";
|
|
6
6
|
import { TypedRoute } from "../TypedRoute";
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
8
|
+
/** @internal */
|
|
11
9
|
export const get_path_and_stringify =
|
|
12
10
|
(logger: () => (log: TypedRoute.IValidateErrorLog) => void) =>
|
|
13
11
|
(method: string) =>
|
|
@@ -28,9 +26,7 @@ export const get_path_and_stringify =
|
|
|
28
26
|
return [path ?? undefined, take(logger)(method)(functor)];
|
|
29
27
|
};
|
|
30
28
|
|
|
31
|
-
/**
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
29
|
+
/** @internal */
|
|
34
30
|
const take =
|
|
35
31
|
(logger: () => (log: TypedRoute.IValidateErrorLog) => void) =>
|
|
36
32
|
(method: string) =>
|
|
@@ -53,9 +49,7 @@ const take =
|
|
|
53
49
|
);
|
|
54
50
|
};
|
|
55
51
|
|
|
56
|
-
/**
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
52
|
+
/** @internal */
|
|
59
53
|
const assert =
|
|
60
54
|
<T>(closure: (data: T) => string) =>
|
|
61
55
|
(data: T): string => {
|
|
@@ -74,9 +68,7 @@ const assert =
|
|
|
74
68
|
}
|
|
75
69
|
};
|
|
76
70
|
|
|
77
|
-
/**
|
|
78
|
-
* @internal
|
|
79
|
-
*/
|
|
71
|
+
/** @internal */
|
|
80
72
|
const is =
|
|
81
73
|
<T>(closure: (data: T) => string | null) =>
|
|
82
74
|
(data: T, _method: string, _path: string) => {
|
|
@@ -85,9 +77,7 @@ const is =
|
|
|
85
77
|
return result;
|
|
86
78
|
};
|
|
87
79
|
|
|
88
|
-
/**
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
80
|
+
/** @internal */
|
|
91
81
|
const validate =
|
|
92
82
|
<T>(closure: (data: T) => IValidation<string>) =>
|
|
93
83
|
(data: T, _method: string, _path: string): string => {
|
|
@@ -116,7 +106,5 @@ const validateLog =
|
|
|
116
106
|
return JSON.stringify(data);
|
|
117
107
|
};
|
|
118
108
|
|
|
119
|
-
/**
|
|
120
|
-
* @internal
|
|
121
|
-
*/
|
|
109
|
+
/** @internal */
|
|
122
110
|
const MESSAGE = "Response body data is not following the promised type.";
|
|
@@ -2,9 +2,7 @@ import type express from "express";
|
|
|
2
2
|
import type { FastifyRequest } from "fastify";
|
|
3
3
|
import raw from "raw-body";
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
5
|
+
/** @internal */
|
|
8
6
|
export const get_text_body = async (
|
|
9
7
|
request: express.Request | FastifyRequest,
|
|
10
8
|
): Promise<string> =>
|
|
@@ -12,9 +10,7 @@ export const get_text_body = async (
|
|
|
12
10
|
? (await raw(request)).toString("utf8")
|
|
13
11
|
: (request.body as string);
|
|
14
12
|
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
13
|
+
/** @internal */
|
|
18
14
|
const isExpressRequest = (
|
|
19
15
|
request: express.Request | FastifyRequest,
|
|
20
16
|
): request is express.Request => (request as express.Request).app !== undefined;
|
|
@@ -15,7 +15,7 @@ export const load_controllers = async (
|
|
|
15
15
|
: [path],
|
|
16
16
|
exclude:
|
|
17
17
|
typeof path === "object" && !Array.isArray(path)
|
|
18
|
-
? path.exclude ?? []
|
|
18
|
+
? (path.exclude ?? [])
|
|
19
19
|
: [],
|
|
20
20
|
filter:
|
|
21
21
|
isTsNode === true || EXTENSION === "ts"
|
|
@@ -27,9 +27,7 @@ export const load_controllers = async (
|
|
|
27
27
|
return mount(sources);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
30
|
+
/** @internal */
|
|
33
31
|
async function mount(sources: string[]): Promise<any[]> {
|
|
34
32
|
const controllers: any[] = [];
|
|
35
33
|
for (const file of sources) {
|
|
@@ -43,7 +41,5 @@ async function mount(sources: string[]): Promise<any[]> {
|
|
|
43
41
|
return controllers;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
/**
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
44
|
+
/** @internal */
|
|
49
45
|
const EXTENSION = is_ts_node ? "ts" : "js";
|
|
@@ -4,9 +4,7 @@ import typia, { IValidation, TypeGuardError } from "typia";
|
|
|
4
4
|
import { IRequestBodyValidator } from "../../options/IRequestBodyValidator";
|
|
5
5
|
import { NoTransformConfigurationError } from "../NoTransformConfigurationError";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
7
|
+
/** @internal */
|
|
10
8
|
export const validate_request_body =
|
|
11
9
|
(method: string) =>
|
|
12
10
|
<T>(validator?: IRequestBodyValidator<T>): ((input: T) => Error | null) => {
|
|
@@ -20,9 +18,7 @@ export const validate_request_body =
|
|
|
20
18
|
new Error(`Error on nestia.core.${method}(): invalid typed validator.`);
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
21
|
+
/** @internal */
|
|
26
22
|
const assert =
|
|
27
23
|
<T>(closure: (data: T) => T) =>
|
|
28
24
|
(input: T) => {
|
|
@@ -43,9 +39,7 @@ const assert =
|
|
|
43
39
|
}
|
|
44
40
|
};
|
|
45
41
|
|
|
46
|
-
/**
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
42
|
+
/** @internal */
|
|
49
43
|
const is =
|
|
50
44
|
<T>(closure: (data: T) => boolean) =>
|
|
51
45
|
(input: T) => {
|
|
@@ -53,9 +47,7 @@ const is =
|
|
|
53
47
|
return success ? null : new BadRequestException(MESSAGE);
|
|
54
48
|
};
|
|
55
49
|
|
|
56
|
-
/**
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
50
|
+
/** @internal */
|
|
59
51
|
const validate =
|
|
60
52
|
<T>(closure: (data: T) => IValidation<T>) =>
|
|
61
53
|
(input: T) => {
|
|
@@ -68,7 +60,5 @@ const validate =
|
|
|
68
60
|
});
|
|
69
61
|
};
|
|
70
62
|
|
|
71
|
-
/**
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
63
|
+
/** @internal */
|
|
74
64
|
const MESSAGE = "Request body data is not following the promised type.";
|
|
@@ -4,9 +4,7 @@ import typia, { IValidation, TypeGuardError } from "typia";
|
|
|
4
4
|
import { IRequestFormDataProps } from "../../options/IRequestFormDataProps";
|
|
5
5
|
import { NoTransformConfigurationError } from "../NoTransformConfigurationError";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
7
|
+
/** @internal */
|
|
10
8
|
export const validate_request_form_data = <T>(
|
|
11
9
|
props?: IRequestFormDataProps<T>,
|
|
12
10
|
): ((value: FormData) => T | Error) => {
|
|
@@ -24,9 +22,7 @@ export const validate_request_form_data = <T>(
|
|
|
24
22
|
);
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
/**
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
25
|
+
/** @internal */
|
|
30
26
|
const assert =
|
|
31
27
|
<T>(closure: (input: FormData) => T) =>
|
|
32
28
|
(input: FormData): T | BadRequestException => {
|
|
@@ -46,9 +42,7 @@ const assert =
|
|
|
46
42
|
}
|
|
47
43
|
};
|
|
48
44
|
|
|
49
|
-
/**
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
45
|
+
/** @internal */
|
|
52
46
|
const is =
|
|
53
47
|
<T>(closure: (input: FormData) => T | null) =>
|
|
54
48
|
(input: FormData): T | BadRequestException => {
|
|
@@ -56,9 +50,7 @@ const is =
|
|
|
56
50
|
return result !== null ? result : new BadRequestException(MESSAGE);
|
|
57
51
|
};
|
|
58
52
|
|
|
59
|
-
/**
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
53
|
+
/** @internal */
|
|
62
54
|
const validate =
|
|
63
55
|
<T>(closure: (input: FormData) => IValidation<T>) =>
|
|
64
56
|
(input: FormData): T | BadRequestException => {
|
|
@@ -71,7 +63,5 @@ const validate =
|
|
|
71
63
|
});
|
|
72
64
|
};
|
|
73
65
|
|
|
74
|
-
/**
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
66
|
+
/** @internal */
|
|
77
67
|
const MESSAGE = "Request multipart data is not following the promised type.";
|
|
@@ -4,9 +4,7 @@ import typia, { IValidation, TypeGuardError } from "typia";
|
|
|
4
4
|
import { IRequestHeadersValidator } from "../../options/IRequestHeadersValidator";
|
|
5
5
|
import { NoTransformConfigurationError } from "../NoTransformConfigurationError";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
7
|
+
/** @internal */
|
|
10
8
|
export const validate_request_headers = <T>(
|
|
11
9
|
validator?: IRequestHeadersValidator<T>,
|
|
12
10
|
): ((input: Record<string, string | string[] | undefined>) => T | Error) => {
|
|
@@ -21,9 +19,7 @@ export const validate_request_headers = <T>(
|
|
|
21
19
|
new Error(`Error on nestia.core.TypedHeaders(): invalid typed validator.`);
|
|
22
20
|
};
|
|
23
21
|
|
|
24
|
-
/**
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
22
|
+
/** @internal */
|
|
27
23
|
const assert =
|
|
28
24
|
<T>(closure: (input: Record<string, string | string[] | undefined>) => T) =>
|
|
29
25
|
(
|
|
@@ -45,9 +41,7 @@ const assert =
|
|
|
45
41
|
}
|
|
46
42
|
};
|
|
47
43
|
|
|
48
|
-
/**
|
|
49
|
-
* @internal
|
|
50
|
-
*/
|
|
44
|
+
/** @internal */
|
|
51
45
|
const is =
|
|
52
46
|
<T>(
|
|
53
47
|
closure: (input: Record<string, string | string[] | undefined>) => T | null,
|
|
@@ -59,9 +53,7 @@ const is =
|
|
|
59
53
|
return result !== null ? result : new BadRequestException(MESSAGE);
|
|
60
54
|
};
|
|
61
55
|
|
|
62
|
-
/**
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
56
|
+
/** @internal */
|
|
65
57
|
const validate =
|
|
66
58
|
<T>(
|
|
67
59
|
closure: (
|
|
@@ -80,7 +72,5 @@ const validate =
|
|
|
80
72
|
});
|
|
81
73
|
};
|
|
82
74
|
|
|
83
|
-
/**
|
|
84
|
-
* @internal
|
|
85
|
-
*/
|
|
75
|
+
/** @internal */
|
|
86
76
|
const MESSAGE = "Request headers data is not following the promised type.";
|
|
@@ -4,9 +4,7 @@ import typia, { IValidation, TypeGuardError } from "typia";
|
|
|
4
4
|
import { IRequestQueryValidator } from "../../options/IRequestQueryValidator";
|
|
5
5
|
import { NoTransformConfigurationError } from "../NoTransformConfigurationError";
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
7
|
+
/** @internal */
|
|
10
8
|
export const validate_request_query =
|
|
11
9
|
(method: string) =>
|
|
12
10
|
<T>(validator?: IRequestQueryValidator<T>) => {
|
|
@@ -21,9 +19,7 @@ export const validate_request_query =
|
|
|
21
19
|
new Error(`Error on nestia.core.${method}(): invalid typed validator.`);
|
|
22
20
|
};
|
|
23
21
|
|
|
24
|
-
/**
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
22
|
+
/** @internal */
|
|
27
23
|
const assert =
|
|
28
24
|
<T>(closure: (input: URLSearchParams) => T) =>
|
|
29
25
|
(input: URLSearchParams): T | BadRequestException => {
|
|
@@ -43,9 +39,7 @@ const assert =
|
|
|
43
39
|
}
|
|
44
40
|
};
|
|
45
41
|
|
|
46
|
-
/**
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
42
|
+
/** @internal */
|
|
49
43
|
const is =
|
|
50
44
|
<T>(closure: (input: URLSearchParams) => T | null) =>
|
|
51
45
|
(input: URLSearchParams): T | BadRequestException => {
|
|
@@ -53,9 +47,7 @@ const is =
|
|
|
53
47
|
return result !== null ? result : new BadRequestException(MESSAGE);
|
|
54
48
|
};
|
|
55
49
|
|
|
56
|
-
/**
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
50
|
+
/** @internal */
|
|
59
51
|
const validate =
|
|
60
52
|
<T>(closure: (input: URLSearchParams) => IValidation<T>) =>
|
|
61
53
|
(input: URLSearchParams): T | BadRequestException => {
|
|
@@ -68,7 +60,5 @@ const validate =
|
|
|
68
60
|
});
|
|
69
61
|
};
|
|
70
62
|
|
|
71
|
-
/**
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
63
|
+
/** @internal */
|
|
74
64
|
const MESSAGE = "Request query data is not following the promised type.";
|
|
@@ -6,24 +6,27 @@ import { Creator } from "../typings/Creator";
|
|
|
6
6
|
/**
|
|
7
7
|
* Exception manager for HTTP server.
|
|
8
8
|
*
|
|
9
|
-
* `ExceptionManager` is an utility class who can insert or erase custom error
|
|
10
|
-
* its conversion method to a regular {@link nest.HttpException}
|
|
9
|
+
* `ExceptionManager` is an utility class who can insert or erase custom error
|
|
10
|
+
* class with its conversion method to a regular {@link nest.HttpException}
|
|
11
|
+
* instance.
|
|
11
12
|
*
|
|
12
|
-
* If you define an API function through {@link TypedRoute} or
|
|
13
|
-
* instead of the basic router decorator functions like
|
|
14
|
-
* {@link nest.Post} and the API function throws a custom
|
|
15
|
-
* {@link ExceptionManager.insert inserted} in this
|
|
16
|
-
* automatically converted to the regular
|
|
17
|
-
* {@link ExceptionManager.Closure}
|
|
13
|
+
* If you define an API function through {@link TypedRoute} or
|
|
14
|
+
* {@link EncryptedRoute} instead of the basic router decorator functions like
|
|
15
|
+
* {@link nest.Get} or {@link nest.Post} and the API function throws a custom
|
|
16
|
+
* error whose class has been {@link ExceptionManager.insert inserted} in this
|
|
17
|
+
* `EntityManager`, the error would be automatically converted to the regular
|
|
18
|
+
* {@link nest.HttpException} instance by the {@link ExceptionManager.Closure}
|
|
19
|
+
* function.
|
|
18
20
|
*
|
|
19
|
-
* Therefore, with this `ExceptionManager` and {@link TypedRoute} or
|
|
20
|
-
* you can manage your custom error classes much
|
|
21
|
-
*
|
|
21
|
+
* Therefore, with this `ExceptionManager` and {@link TypedRoute} or
|
|
22
|
+
* {@link EncryptedRoute}, you can manage your custom error classes much
|
|
23
|
+
* systemtically. You can avoid 500 internal server error or hard coding
|
|
24
|
+
* implementation about the custom error classes.
|
|
22
25
|
*
|
|
23
26
|
* Below error classes are defaultly configured in this `ExceptionManager`
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
28
|
+
* - `typia.TypeGuardError`
|
|
29
|
+
* - `@nestia/fetcher.HttpError`
|
|
27
30
|
*
|
|
28
31
|
* @author Jeongho Nam - https://github.com/samchon
|
|
29
32
|
*/
|
|
@@ -31,7 +34,8 @@ export namespace ExceptionManager {
|
|
|
31
34
|
/**
|
|
32
35
|
* Insert an error class with converter.
|
|
33
36
|
*
|
|
34
|
-
* If you've inserted an duplicated error class, the closure would be
|
|
37
|
+
* If you've inserted an duplicated error class, the closure would be
|
|
38
|
+
* overwritten.
|
|
35
39
|
*
|
|
36
40
|
* @param creator Target error class
|
|
37
41
|
* @param closure A closure function converting to the `HttpException` class
|
|
@@ -70,32 +74,31 @@ export namespace ExceptionManager {
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
/**
|
|
73
|
-
* Type of a closure function converting to the regular
|
|
77
|
+
* Type of a closure function converting to the regular
|
|
78
|
+
* {@link nest.HttpException}.
|
|
74
79
|
*
|
|
75
|
-
* `ExceptionManager.Closure` is a type of closure function who are converting
|
|
76
|
-
* custom error to the regular {@link nest.HttpException} instance. It
|
|
77
|
-
* in the {@link ExceptionManager} with {@link TypedRoute} or
|
|
80
|
+
* `ExceptionManager.Closure` is a type of closure function who are converting
|
|
81
|
+
* from custom error to the regular {@link nest.HttpException} instance. It
|
|
82
|
+
* would be used in the {@link ExceptionManager} with {@link TypedRoute} or
|
|
83
|
+
* {@link EncryptedRoute}.
|
|
78
84
|
*/
|
|
79
85
|
export interface Closure<T extends Error> {
|
|
80
86
|
/**
|
|
81
87
|
* Error converter.
|
|
82
88
|
*
|
|
83
|
-
* Convert from custom error to the regular {@link nest.HttpException}
|
|
89
|
+
* Convert from custom error to the regular {@link nest.HttpException}
|
|
90
|
+
* instance.
|
|
84
91
|
*
|
|
85
92
|
* @param exception Custom error instance
|
|
86
|
-
* @
|
|
93
|
+
* @returns Regular {@link nest.HttpException} instance
|
|
87
94
|
*/
|
|
88
95
|
(exception: T): HttpException;
|
|
89
96
|
}
|
|
90
97
|
|
|
91
|
-
/**
|
|
92
|
-
* @internal
|
|
93
|
-
*/
|
|
98
|
+
/** @internal */
|
|
94
99
|
export const tuples: Array<[Creator<any>, Closure<any>]> = [];
|
|
95
100
|
|
|
96
|
-
/**
|
|
97
|
-
* @internal
|
|
98
|
-
*/
|
|
101
|
+
/** @internal */
|
|
99
102
|
export const listeners: Set<(error: any) => any> = new Set();
|
|
100
103
|
}
|
|
101
104
|
|
package/src/utils/Singleton.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import glob from "glob";
|
|
2
|
+
import { glob } from "glob";
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
5
|
export namespace SourceFinder {
|
|
@@ -41,13 +41,10 @@ export namespace SourceFinder {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const _Glob = (pattern: string): Promise<string[]> =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
else resolve(matches.map((str) => path.resolve(str)));
|
|
49
|
-
});
|
|
50
|
-
});
|
|
44
|
+
const _Glob = async (pattern: string): Promise<string[]> => {
|
|
45
|
+
const matches = await glob(pattern);
|
|
46
|
+
return matches.map((str) => path.resolve(str));
|
|
47
|
+
};
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
interface IProps {
|