@nestia/core 7.3.1 → 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/package.json +6 -6
- 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
|
@@ -8,32 +8,32 @@ import { load_controllers } from "./internal/load_controller";
|
|
|
8
8
|
/**
|
|
9
9
|
* Encrypted module.
|
|
10
10
|
*
|
|
11
|
-
* `EncryptedModule` is an extension of the {@link Module} class decorator
|
|
12
|
-
* who configures encryption password of the AES-128/256 algorithm. The
|
|
13
|
-
* algorithm and password would be used by {@link EncryptedRoute} and
|
|
14
|
-
* to encrypt the request and response bod of the HTTP
|
|
11
|
+
* `EncryptedModule` is an extension of the {@link Module} class decorator
|
|
12
|
+
* function who configures encryption password of the AES-128/256 algorithm. The
|
|
13
|
+
* encryption algorithm and password would be used by {@link EncryptedRoute} and
|
|
14
|
+
* {@link EncryptedBody} to encrypt the request and response bod of the HTTP
|
|
15
|
+
* protocol.
|
|
15
16
|
*
|
|
16
17
|
* By using this `EncryptedModule` decorator function, all of the
|
|
17
|
-
* {@link Controller controllers} configured in the
|
|
18
|
-
* changed to the {@link EncryptedController} with the
|
|
19
|
-
* original {@link EncryptedController} decorated classes in the
|
|
20
|
-
* encryption password would be kept.
|
|
18
|
+
* {@link Controller controllers} configured in the _metadata_ would be
|
|
19
|
+
* automatically changed to the {@link EncryptedController} with the _password_.
|
|
20
|
+
* If there're some original {@link EncryptedController} decorated classes in the
|
|
21
|
+
* _metadata_, their encryption password would be kept.
|
|
21
22
|
*
|
|
22
|
-
* Therefore, if you're planning to place original {@link EncryptedController}
|
|
23
|
-
* classes in the
|
|
24
|
-
* module level. If not, I recommend you use the
|
|
25
|
-
* function instead.
|
|
23
|
+
* Therefore, if you're planning to place original {@link EncryptedController}
|
|
24
|
+
* decorated classes in the _metadata_, I hope them to have different encryption
|
|
25
|
+
* password from the module level. If not, I recommend you use the
|
|
26
|
+
* {@link Controller} decorator function instead.
|
|
26
27
|
*
|
|
27
|
-
* In addition, the `EncryptedModule` supports a convenient dynamic controller
|
|
28
|
-
* function, {@link EncryptedModule.dynamic}. If you utilize the
|
|
29
|
-
* path of the controller classes, it imports and
|
|
30
|
-
* the `Module`, automatically.
|
|
28
|
+
* In addition, the `EncryptedModule` supports a convenient dynamic controller
|
|
29
|
+
* importing function, {@link EncryptedModule.dynamic}. If you utilize the
|
|
30
|
+
* function with directory path of the controller classes, it imports and
|
|
31
|
+
* configures the controller classes into the `Module`, automatically.
|
|
31
32
|
*
|
|
33
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
32
34
|
* @param metadata Module configuration metadata
|
|
33
35
|
* @param password Encryption password or its getter function
|
|
34
36
|
* @returns Class decorator
|
|
35
|
-
*
|
|
36
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
37
37
|
*/
|
|
38
38
|
export function EncryptedModule(
|
|
39
39
|
metadata: Parameters<typeof Module>[0],
|
|
@@ -49,10 +49,10 @@ export namespace EncryptedModule {
|
|
|
49
49
|
/**
|
|
50
50
|
* Dynamic encrypted module.
|
|
51
51
|
*
|
|
52
|
-
* `EncryptedModule.dynamic` is an extension of the {@link EncryptedModule}
|
|
53
|
-
* who configures controller classes by the dynamic importing. By
|
|
54
|
-
* path of the controller classes, those controllers
|
|
55
|
-
* and configured.
|
|
52
|
+
* `EncryptedModule.dynamic` is an extension of the {@link EncryptedModule}
|
|
53
|
+
* function who configures controller classes by the dynamic importing. By
|
|
54
|
+
* specifying directory path of the controller classes, those controllers
|
|
55
|
+
* would be automatically imported and configured.
|
|
56
56
|
*
|
|
57
57
|
* @param path Directory path of the controller classes
|
|
58
58
|
* @param password Encryption password or its getter function
|
|
@@ -81,9 +81,7 @@ export namespace EncryptedModule {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
/**
|
|
85
|
-
* @internal
|
|
86
|
-
*/
|
|
84
|
+
/** @internal */
|
|
87
85
|
const iterate =
|
|
88
86
|
(password: IEncryptionPassword.Closure) =>
|
|
89
87
|
(modulo: any): void => {
|
|
@@ -28,20 +28,21 @@ import { route_error } from "./internal/route_error";
|
|
|
28
28
|
/**
|
|
29
29
|
* Encrypted router decorator functions.
|
|
30
30
|
*
|
|
31
|
-
* `EncryptedRoute` is a module containing router decorator functions which
|
|
32
|
-
* response body data through AES-128/256 encryption. Furthermore, they
|
|
33
|
-
* up JSON string conversion speed about 50x times faster than
|
|
34
|
-
* even type safe through
|
|
31
|
+
* `EncryptedRoute` is a module containing router decorator functions which
|
|
32
|
+
* encrypts response body data through AES-128/256 encryption. Furthermore, they
|
|
33
|
+
* can boost up JSON string conversion speed about 50x times faster than
|
|
34
|
+
* `class-transformer`, even type safe through
|
|
35
|
+
* [typia](https://github.com/samchon/typia).
|
|
35
36
|
*
|
|
36
37
|
* For reference, if you try to invalid data that is not following the promised
|
|
37
|
-
* type `T`, 500 internal server error would be thrown. Also, as
|
|
38
|
-
* composes JSON string through `typia.assertStringify<T>()`
|
|
39
|
-
* possible to modify response data through interceptors.
|
|
38
|
+
* type `T`, 500 internal server error would be thrown. Also, as
|
|
39
|
+
* `EncryptedRoute` composes JSON string through `typia.assertStringify<T>()`
|
|
40
|
+
* function, it is not possible to modify response data through interceptors.
|
|
40
41
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* - AES-128/256
|
|
43
|
+
* - CBC mode
|
|
44
|
+
* - PKCS #5 Padding
|
|
45
|
+
* - Base64 Encoding
|
|
45
46
|
*
|
|
46
47
|
* @author Jeongho Nam - https://github.com/samchon
|
|
47
48
|
*/
|
|
@@ -89,18 +90,17 @@ export namespace EncryptedRoute {
|
|
|
89
90
|
/**
|
|
90
91
|
* Set the logger function for the response validation failure.
|
|
91
92
|
*
|
|
92
|
-
* If you've configured the transformation option to `validate.log`
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
93
|
+
* If you've configured the transformation option to `validate.log` in the
|
|
94
|
+
* `tsconfig.json` file, then the error log information of the response
|
|
95
|
+
* validation failure would be logged through this function instead of
|
|
96
|
+
* throwing the 400 bad request error.
|
|
96
97
|
*
|
|
97
|
-
* By the way, be careful. If you've configured the response
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* backend server case.
|
|
98
|
+
* By the way, be careful. If you've configured the response transformation
|
|
99
|
+
* option to be `validate.log`, client may get wrong response data. Therefore,
|
|
100
|
+
* this way is not recommended in the common backend server case.
|
|
101
101
|
*
|
|
102
|
-
* @param func Logger function
|
|
103
102
|
* @default console.log
|
|
103
|
+
* @param func Logger function
|
|
104
104
|
*/
|
|
105
105
|
export function setValidateErrorLogger(
|
|
106
106
|
func: (log: IValidateErrorLog) => void,
|
|
@@ -110,9 +110,7 @@ export namespace EncryptedRoute {
|
|
|
110
110
|
|
|
111
111
|
export import IValidateErrorLog = TypedRoute.IValidateErrorLog;
|
|
112
112
|
|
|
113
|
-
/**
|
|
114
|
-
* @internal
|
|
115
|
-
*/
|
|
113
|
+
/** @internal */
|
|
116
114
|
function Generator(method: "Get" | "Post" | "Put" | "Patch" | "Delete") {
|
|
117
115
|
function route(path?: string | string[]): MethodDecorator;
|
|
118
116
|
function route<T>(
|
|
@@ -152,9 +150,7 @@ for (const method of [
|
|
|
152
150
|
])
|
|
153
151
|
(deco as any)[key] = value;
|
|
154
152
|
|
|
155
|
-
/**
|
|
156
|
-
* @internal
|
|
157
|
-
*/
|
|
153
|
+
/** @internal */
|
|
158
154
|
class EncryptedRouteInterceptor implements NestInterceptor {
|
|
159
155
|
public constructor(
|
|
160
156
|
private readonly method: string,
|
|
@@ -207,9 +203,7 @@ class EncryptedRouteInterceptor implements NestInterceptor {
|
|
|
207
203
|
}
|
|
208
204
|
}
|
|
209
205
|
|
|
210
|
-
/**
|
|
211
|
-
* @internal
|
|
212
|
-
*/
|
|
206
|
+
/** @internal */
|
|
213
207
|
const ROUTERS = {
|
|
214
208
|
Get,
|
|
215
209
|
Post,
|
|
@@ -7,13 +7,13 @@ import { SwaggerCustomizer } from "./SwaggerCustomizer";
|
|
|
7
7
|
* schema composer (of [`@samchon/openapi`](https://github.com/samchon/openapi))
|
|
8
8
|
* excludes the API.
|
|
9
9
|
*
|
|
10
|
-
* In other words, if you adjust the `@HumanRoute()` decorator to the API,
|
|
11
|
-
*
|
|
10
|
+
* In other words, if you adjust the `@HumanRoute()` decorator to the API, the
|
|
11
|
+
* API never participates in the LLM function calling. When calling the
|
|
12
12
|
* {@link HttpLlm.application} function, matched {@link IHttpLlmFunction} data
|
|
13
13
|
* never be composed.
|
|
14
14
|
*
|
|
15
|
-
* @returns Method decorator
|
|
16
15
|
* @author Jeongho Nam - https://github.com/samchon
|
|
16
|
+
* @returns Method decorator
|
|
17
17
|
*/
|
|
18
18
|
export function HumanRoute(): MethodDecorator {
|
|
19
19
|
return SwaggerCustomizer((props) => {
|
|
@@ -16,17 +16,19 @@ export namespace NoTransformConfigurationError {
|
|
|
16
16
|
* If you set this value to `false`, {@link NoTransformConfigurationError} will
|
|
17
17
|
* not throw an error.
|
|
18
18
|
*
|
|
19
|
-
* Even if you've not configured the plugin transformer of `tsconfig.json`
|
|
20
|
-
* the error will not be thrown and the program will be continued.
|
|
21
|
-
* validations and assertions will be skipped and the value
|
|
22
|
-
* Furthermore, unexpected behaviors may occur.
|
|
19
|
+
* Even if you've not configured the plugin transformer of `tsconfig.json`
|
|
20
|
+
* file, the error will not be thrown and the program will be continued.
|
|
21
|
+
* Instead, every validations and assertions will be skipped and the value
|
|
22
|
+
* will be returned as it is. Furthermore, unexpected behaviors may occur.
|
|
23
23
|
*
|
|
24
24
|
* Therefore, it is not recommended to set this value to `false` in production
|
|
25
|
-
* environment. Configure this value to be `false` only when you're debugging
|
|
25
|
+
* environment. Configure this value to be `false` only when you're debugging
|
|
26
|
+
* or testing.
|
|
26
27
|
*
|
|
27
|
-
* By the way, if you hope the `false` value to be set, you have to do it
|
|
28
|
-
* If you configure the `false` value after the
|
|
29
|
-
* composed, the value will not be
|
|
28
|
+
* By the way, if you hope the `false` value to be set, you have to do it
|
|
29
|
+
* before the first. If you configure the `false` value after the
|
|
30
|
+
* `@nestia/core` decorator functions are composed, the value will not be
|
|
31
|
+
* applied and the error will be thrown.
|
|
30
32
|
*/
|
|
31
33
|
export let throws = true;
|
|
32
34
|
}
|
|
@@ -13,12 +13,13 @@ import { validate_request_body } from "./internal/validate_request_body";
|
|
|
13
13
|
/**
|
|
14
14
|
* Plain body decorator.
|
|
15
15
|
*
|
|
16
|
-
* `PlainBody` is a decorator function getting full body text from the HTTP
|
|
16
|
+
* `PlainBody` is a decorator function getting full body text from the HTTP
|
|
17
|
+
* request.
|
|
17
18
|
*
|
|
18
|
-
* If you adjust the regular {@link Body} decorator function to the body
|
|
19
|
-
* you can't get the full body text because the {@link Body} tries to
|
|
20
|
-
* body text to JSON object. Therefore, `@nestia/core` provides this
|
|
21
|
-
* decorator function to get the full body text.
|
|
19
|
+
* If you adjust the regular {@link Body} decorator function to the body
|
|
20
|
+
* parameter, you can't get the full body text because the {@link Body} tries to
|
|
21
|
+
* convert the body text to JSON object. Therefore, `@nestia/core` provides this
|
|
22
|
+
* `PlainBody` decorator function to get the full body text.
|
|
22
23
|
*
|
|
23
24
|
* ```typescript
|
|
24
25
|
* \@TypedRoute.Post("memo")
|
|
@@ -28,14 +29,12 @@ import { validate_request_body } from "./internal/validate_request_body";
|
|
|
28
29
|
* ): void;
|
|
29
30
|
* ```
|
|
30
31
|
*
|
|
31
|
-
* @return Parameter decorator
|
|
32
32
|
* @author Jeongho Nam - https://github.com/samchon
|
|
33
|
+
* @returns Parameter decorator
|
|
33
34
|
*/
|
|
34
35
|
export function PlainBody(): ParameterDecorator;
|
|
35
36
|
|
|
36
|
-
/**
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
37
|
+
/** @internal */
|
|
39
38
|
export function PlainBody(
|
|
40
39
|
assert?: (input: unknown) => string,
|
|
41
40
|
): ParameterDecorator {
|
|
@@ -68,9 +67,7 @@ export function PlainBody(
|
|
|
68
67
|
})();
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
/**
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
70
|
+
/** @internal */
|
|
74
71
|
const isTextPlain = (text?: string): boolean =>
|
|
75
72
|
text !== undefined &&
|
|
76
73
|
text
|
|
@@ -7,12 +7,12 @@ import { OpenApi } from "@samchon/openapi";
|
|
|
7
7
|
* customizing the swagger data with `npx nestia swagger` command. Furthermore,
|
|
8
8
|
* it is possible to add plugin properties starting with `x-` characters.
|
|
9
9
|
*
|
|
10
|
-
* In other words, this decorator function does not affect to the runtime,
|
|
11
|
-
*
|
|
10
|
+
* In other words, this decorator function does not affect to the runtime, but
|
|
11
|
+
* only for the swagger data customization.
|
|
12
12
|
*
|
|
13
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
13
14
|
* @param closure Callback function which can customize the swagger data
|
|
14
15
|
* @returns Method decorator
|
|
15
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
16
16
|
*/
|
|
17
17
|
export function SwaggerCustomizer(
|
|
18
18
|
closure: (props: SwaggerCustomizer.IProps) => unknown,
|
|
@@ -51,24 +51,16 @@ export namespace SwaggerCustomizer {
|
|
|
51
51
|
* the swagger data.
|
|
52
52
|
*/
|
|
53
53
|
export interface IProps {
|
|
54
|
-
/**
|
|
55
|
-
* Swagger data.
|
|
56
|
-
*/
|
|
54
|
+
/** Swagger data. */
|
|
57
55
|
swagger: OpenApi.IDocument;
|
|
58
56
|
|
|
59
|
-
/**
|
|
60
|
-
* Method of the route.
|
|
61
|
-
*/
|
|
57
|
+
/** Method of the route. */
|
|
62
58
|
method: string;
|
|
63
59
|
|
|
64
|
-
/**
|
|
65
|
-
* Path of the route.
|
|
66
|
-
*/
|
|
60
|
+
/** Path of the route. */
|
|
67
61
|
path: string;
|
|
68
62
|
|
|
69
|
-
/**
|
|
70
|
-
* Route data.
|
|
71
|
-
*/
|
|
63
|
+
/** Route data. */
|
|
72
64
|
route: OpenApi.IOperation;
|
|
73
65
|
|
|
74
66
|
/**
|
|
@@ -88,28 +80,18 @@ export namespace SwaggerCustomizer {
|
|
|
88
80
|
get(accessor: IAccessor): OpenApi.IOperation | undefined;
|
|
89
81
|
}
|
|
90
82
|
|
|
91
|
-
/**
|
|
92
|
-
* Accessor for getting neighbor route data.
|
|
93
|
-
*/
|
|
83
|
+
/** Accessor for getting neighbor route data. */
|
|
94
84
|
export interface IAccessor {
|
|
95
|
-
/**
|
|
96
|
-
* Path of the neighbor route.
|
|
97
|
-
*/
|
|
85
|
+
/** Path of the neighbor route. */
|
|
98
86
|
path: string;
|
|
99
87
|
|
|
100
|
-
/**
|
|
101
|
-
* Method of the neighbor route.
|
|
102
|
-
*/
|
|
88
|
+
/** Method of the neighbor route. */
|
|
103
89
|
method: string;
|
|
104
90
|
}
|
|
105
91
|
|
|
106
|
-
/**
|
|
107
|
-
* Endpoint info of the route.
|
|
108
|
-
*/
|
|
92
|
+
/** Endpoint info of the route. */
|
|
109
93
|
export interface ISwaggerEndpoint extends IAccessor {
|
|
110
|
-
/**
|
|
111
|
-
* Route data.
|
|
112
|
-
*/
|
|
94
|
+
/** Route data. */
|
|
113
95
|
route: OpenApi.IOperation;
|
|
114
96
|
}
|
|
115
97
|
}
|
|
@@ -13,16 +13,16 @@ import { validate_request_body } from "./internal/validate_request_body";
|
|
|
13
13
|
/**
|
|
14
14
|
* Type safe body decorator.
|
|
15
15
|
*
|
|
16
|
-
* `TypedBody` is a decorator function getting `application/json` typed data
|
|
17
|
-
* request body. Also, it validates the request body data type through
|
|
18
|
-
* [typia](https://github.com/samchon/typia) and the validation speed is
|
|
19
|
-
*
|
|
16
|
+
* `TypedBody` is a decorator function getting `application/json` typed data
|
|
17
|
+
* from request body. Also, it validates the request body data type through
|
|
18
|
+
* [typia](https://github.com/samchon/typia) and the validation speed is maximum
|
|
19
|
+
* 20,000x times faster than `class-validator`.
|
|
20
20
|
*
|
|
21
|
-
* For reference, when the request body data is not following the promised type
|
|
22
|
-
* `BadRequestException` error (status code: 400) would be thrown.
|
|
21
|
+
* For reference, when the request body data is not following the promised type
|
|
22
|
+
* `T`, `BadRequestException` error (status code: 400) would be thrown.
|
|
23
23
|
*
|
|
24
|
-
* @param validator Custom validator if required. Default is `typia.assert()`
|
|
25
24
|
* @author Jeongho Nam - https://github.com/samchon
|
|
25
|
+
* @param validator Custom validator if required. Default is `typia.assert()`
|
|
26
26
|
*/
|
|
27
27
|
export function TypedBody<T>(
|
|
28
28
|
validator?: IRequestBodyValidator<T>,
|
|
@@ -48,9 +48,7 @@ export function TypedBody<T>(
|
|
|
48
48
|
})();
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
51
|
+
/** @internal */
|
|
54
52
|
const isApplicationJson = (text?: string): boolean =>
|
|
55
53
|
text !== undefined &&
|
|
56
54
|
text
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exception decorator.
|
|
5
5
|
*
|
|
6
|
-
* `TypedException` is a decorator function describing HTTP exception and its
|
|
7
|
-
* which could be occurred in the method.
|
|
6
|
+
* `TypedException` is a decorator function describing HTTP exception and its
|
|
7
|
+
* type which could be occurred in the method.
|
|
8
8
|
*
|
|
9
|
-
* For reference, this decorator function does not affect to the method's
|
|
10
|
-
* but only affects to the swagger documents generation. Also, it does
|
|
11
|
-
* the SDK library generation yet, but will be used in the
|
|
9
|
+
* For reference, this decorator function does not affect to the method's
|
|
10
|
+
* behavior, but only affects to the swagger documents generation. Also, it does
|
|
11
|
+
* not affect to the SDK library generation yet, but will be used in the
|
|
12
|
+
* future.
|
|
12
13
|
*
|
|
14
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
13
15
|
* @param props Properties for the exception
|
|
14
16
|
* @returns Method decorator
|
|
15
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
16
17
|
*/
|
|
17
18
|
export function TypedException(props: TypedException.IProps<unknown>): never;
|
|
18
19
|
|
|
@@ -21,20 +22,20 @@ export function TypedException(props: TypedException.IProps<unknown>): never;
|
|
|
21
22
|
*
|
|
22
23
|
* Exception decorator.
|
|
23
24
|
*
|
|
24
|
-
* `TypedException` is a decorator function describing HTTP exception and its
|
|
25
|
-
* which could be occurred in the method.
|
|
25
|
+
* `TypedException` is a decorator function describing HTTP exception and its
|
|
26
|
+
* type which could be occurred in the method.
|
|
26
27
|
*
|
|
27
|
-
* For reference, this decorator function does not affect to the method's
|
|
28
|
-
* but only affects to the swagger documents generation. Also, it does
|
|
29
|
-
* the SDK library generation yet, but will be used in the
|
|
28
|
+
* For reference, this decorator function does not affect to the method's
|
|
29
|
+
* behavior, but only affects to the swagger documents generation. Also, it does
|
|
30
|
+
* not affect to the SDK library generation yet, but will be used in the
|
|
31
|
+
* future.
|
|
30
32
|
*
|
|
33
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
+
* @deprecated Use {@link TypedException.IProps} typed function instead. This
|
|
35
|
+
* typed function is deprecated and will be removed in the next major update.
|
|
31
36
|
* @param status Status number or pattern like "2XX", "3XX", "4XX", "5XX"
|
|
32
37
|
* @param description Description about the exception
|
|
33
38
|
* @returns Method decorator
|
|
34
|
-
*
|
|
35
|
-
* @deprecated Use {@link TypedException.IProps} typed function instead.
|
|
36
|
-
* This typed function is deprecated and will be removed in the next major update.
|
|
37
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
38
39
|
*/
|
|
39
40
|
export function TypedException(
|
|
40
41
|
status: number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
@@ -44,18 +45,18 @@ export function TypedException(
|
|
|
44
45
|
/**
|
|
45
46
|
* Exception decorator.
|
|
46
47
|
*
|
|
47
|
-
* `TypedException` is a decorator function describing HTTP exception and its
|
|
48
|
-
* which could be occurred in the method.
|
|
48
|
+
* `TypedException` is a decorator function describing HTTP exception and its
|
|
49
|
+
* type which could be occurred in the method.
|
|
49
50
|
*
|
|
50
|
-
* For reference, this decorator function does not affect to the method's
|
|
51
|
-
* but only affects to the swagger documents generation. Also, it does
|
|
52
|
-
* the SDK library generation yet, but will be used in the
|
|
51
|
+
* For reference, this decorator function does not affect to the method's
|
|
52
|
+
* behavior, but only affects to the swagger documents generation. Also, it does
|
|
53
|
+
* not affect to the SDK library generation yet, but will be used in the
|
|
54
|
+
* future.
|
|
53
55
|
*
|
|
56
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
54
57
|
* @template T Type of the exception
|
|
55
58
|
* @param props Properties for the exception
|
|
56
59
|
* @returns Method decorator
|
|
57
|
-
*
|
|
58
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
59
60
|
*/
|
|
60
61
|
export function TypedException<T>(
|
|
61
62
|
props: TypedException.IProps<T>,
|
|
@@ -64,30 +65,28 @@ export function TypedException<T>(
|
|
|
64
65
|
/**
|
|
65
66
|
* Exception decorator.
|
|
66
67
|
*
|
|
67
|
-
* `TypedException` is a decorator function describing HTTP exception and its
|
|
68
|
-
* which could be occurred in the method.
|
|
68
|
+
* `TypedException` is a decorator function describing HTTP exception and its
|
|
69
|
+
* type which could be occurred in the method.
|
|
69
70
|
*
|
|
70
|
-
* For reference, this decorator function does not affect to the method's
|
|
71
|
-
* but only affects to the swagger documents generation. Also, it does
|
|
72
|
-
* the SDK library generation yet, but will be used in the
|
|
71
|
+
* For reference, this decorator function does not affect to the method's
|
|
72
|
+
* behavior, but only affects to the swagger documents generation. Also, it does
|
|
73
|
+
* not affect to the SDK library generation yet, but will be used in the
|
|
74
|
+
* future.
|
|
73
75
|
*
|
|
76
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
77
|
+
* @deprecated Use {@link TypedException.IProps} typed function instead. This
|
|
78
|
+
* typed function is deprecated and will be removed in the next major update.
|
|
74
79
|
* @template T Type of the exception
|
|
75
80
|
* @param status Status number or pattern like "2XX", "3XX", "4XX", "5XX"
|
|
76
81
|
* @param description Description about the exception
|
|
77
82
|
* @returns Method decorator
|
|
78
|
-
*
|
|
79
|
-
* @deprecated Use {@link TypedException.IProps} typed function instead.
|
|
80
|
-
* This typed function is deprecated and will be removed in the next major update.
|
|
81
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
82
83
|
*/
|
|
83
84
|
export function TypedException<T>(
|
|
84
85
|
status: number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
85
86
|
description?: string | undefined,
|
|
86
87
|
): MethodDecorator;
|
|
87
88
|
|
|
88
|
-
/**
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
89
|
+
/** @internal */
|
|
91
90
|
export function TypedException<T>(...args: any[]): MethodDecorator {
|
|
92
91
|
const props: TypedException.IProps<T> =
|
|
93
92
|
typeof args[0] === "object"
|
|
@@ -119,48 +118,30 @@ export function TypedException<T>(...args: any[]): MethodDecorator {
|
|
|
119
118
|
};
|
|
120
119
|
}
|
|
121
120
|
export namespace TypedException {
|
|
122
|
-
/**
|
|
123
|
-
* Properties for the exception.
|
|
124
|
-
*/
|
|
121
|
+
/** Properties for the exception. */
|
|
125
122
|
export interface IProps<T> {
|
|
126
|
-
/**
|
|
127
|
-
* Status number or pattern like "2XX", "3XX", "4XX", "5XX".
|
|
128
|
-
*/
|
|
123
|
+
/** Status number or pattern like "2XX", "3XX", "4XX", "5XX". */
|
|
129
124
|
status: number | "2XX" | "3XX" | "4XX" | "5XX";
|
|
130
125
|
|
|
131
|
-
/**
|
|
132
|
-
* Description about the exception.
|
|
133
|
-
*/
|
|
126
|
+
/** Description about the exception. */
|
|
134
127
|
description?: string | undefined;
|
|
135
128
|
|
|
136
|
-
/**
|
|
137
|
-
* Example value.
|
|
138
|
-
*/
|
|
129
|
+
/** Example value. */
|
|
139
130
|
example?: T | undefined;
|
|
140
131
|
|
|
141
|
-
/**
|
|
142
|
-
* Collection of examples for the exception.
|
|
143
|
-
*/
|
|
132
|
+
/** Collection of examples for the exception. */
|
|
144
133
|
examples?: Record<string, IExample<T>> | undefined;
|
|
145
134
|
}
|
|
146
135
|
|
|
147
|
-
/**
|
|
148
|
-
* Metadata collected in the {@link IProps.examples}.
|
|
149
|
-
*/
|
|
136
|
+
/** Metadata collected in the {@link IProps.examples}. */
|
|
150
137
|
export interface IExample<T> {
|
|
151
|
-
/**
|
|
152
|
-
* Summary of the example.
|
|
153
|
-
*/
|
|
138
|
+
/** Summary of the example. */
|
|
154
139
|
summary?: string | undefined;
|
|
155
140
|
|
|
156
|
-
/**
|
|
157
|
-
* Description of the example.
|
|
158
|
-
*/
|
|
141
|
+
/** Description of the example. */
|
|
159
142
|
description?: string | undefined;
|
|
160
143
|
|
|
161
|
-
/**
|
|
162
|
-
* Value of the example.
|
|
163
|
-
*/
|
|
144
|
+
/** Value of the example. */
|
|
164
145
|
value: T;
|
|
165
146
|
}
|
|
166
147
|
}
|