@nestia/core 10.0.2 → 11.0.0-dev.20260305

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.
Files changed (155) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +93 -93
  3. package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
  4. package/lib/decorators/DynamicModule.js +54 -10
  5. package/lib/decorators/DynamicModule.js.map +1 -1
  6. package/lib/decorators/EncryptedBody.js +2 -2
  7. package/lib/decorators/EncryptedBody.js.map +1 -1
  8. package/lib/decorators/EncryptedController.d.ts +1 -1
  9. package/lib/decorators/EncryptedModule.d.ts +1 -1
  10. package/lib/decorators/EncryptedModule.js +54 -10
  11. package/lib/decorators/EncryptedModule.js.map +1 -1
  12. package/lib/decorators/EncryptedRoute.js +2 -2
  13. package/lib/decorators/EncryptedRoute.js.map +1 -1
  14. package/lib/decorators/HumanRoute.d.ts +1 -2
  15. package/lib/decorators/HumanRoute.js +1 -2
  16. package/lib/decorators/HumanRoute.js.map +1 -1
  17. package/lib/decorators/NoTransformConfigurationError.js +1 -1
  18. package/lib/decorators/NoTransformConfigurationError.js.map +1 -1
  19. package/lib/decorators/SwaggerCustomizer.d.ts +1 -1
  20. package/lib/decorators/TypedFormData.js.map +1 -1
  21. package/lib/decorators/TypedParam.js +1 -1
  22. package/lib/decorators/TypedParam.js.map +1 -1
  23. package/lib/decorators/internal/get_path_and_querify.js +1 -1
  24. package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
  25. package/lib/decorators/internal/get_path_and_stringify.js +1 -1
  26. package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
  27. package/lib/decorators/internal/headers_to_object.js.map +1 -1
  28. package/lib/decorators/internal/validate_request_body.js +1 -1
  29. package/lib/decorators/internal/validate_request_body.js.map +1 -1
  30. package/lib/decorators/internal/validate_request_form_data.js +1 -1
  31. package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
  32. package/lib/decorators/internal/validate_request_headers.js +1 -1
  33. package/lib/decorators/internal/validate_request_headers.js.map +1 -1
  34. package/lib/decorators/internal/validate_request_query.js +1 -1
  35. package/lib/decorators/internal/validate_request_query.js.map +1 -1
  36. package/lib/module.d.ts +1 -0
  37. package/lib/module.js +1 -0
  38. package/lib/module.js.map +1 -1
  39. package/lib/options/INestiaTransformProject.d.ts +1 -1
  40. package/lib/programmers/PlainBodyProgrammer.js +5 -8
  41. package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
  42. package/lib/programmers/TypedBodyProgrammer.js +13 -21
  43. package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
  44. package/lib/programmers/TypedFormDataBodyProgrammer.js +11 -20
  45. package/lib/programmers/TypedFormDataBodyProgrammer.js.map +1 -1
  46. package/lib/programmers/TypedHeadersProgrammer.js +4 -6
  47. package/lib/programmers/TypedHeadersProgrammer.js.map +1 -1
  48. package/lib/programmers/TypedParamProgrammer.js +2 -2
  49. package/lib/programmers/TypedParamProgrammer.js.map +1 -1
  50. package/lib/programmers/TypedQueryBodyProgrammer.js +9 -16
  51. package/lib/programmers/TypedQueryBodyProgrammer.js.map +1 -1
  52. package/lib/programmers/TypedQueryProgrammer.js +9 -16
  53. package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
  54. package/lib/programmers/TypedQueryRouteProgrammer.js +6 -10
  55. package/lib/programmers/TypedQueryRouteProgrammer.js.map +1 -1
  56. package/lib/programmers/TypedRouteProgrammer.js +8 -13
  57. package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
  58. package/lib/programmers/http/HttpAssertQuerifyProgrammer.d.ts +1 -1
  59. package/lib/programmers/http/HttpAssertQuerifyProgrammer.js +5 -7
  60. package/lib/programmers/http/HttpAssertQuerifyProgrammer.js.map +1 -1
  61. package/lib/programmers/http/HttpIsQuerifyProgrammer.d.ts +1 -1
  62. package/lib/programmers/http/HttpIsQuerifyProgrammer.js +5 -7
  63. package/lib/programmers/http/HttpIsQuerifyProgrammer.js.map +1 -1
  64. package/lib/programmers/http/HttpQuerifyProgrammer.d.ts +1 -1
  65. package/lib/programmers/http/HttpQuerifyProgrammer.js +13 -19
  66. package/lib/programmers/http/HttpQuerifyProgrammer.js.map +1 -1
  67. package/lib/programmers/http/HttpValidateQuerifyProgrammer.d.ts +1 -1
  68. package/lib/programmers/http/HttpValidateQuerifyProgrammer.js +6 -8
  69. package/lib/programmers/http/HttpValidateQuerifyProgrammer.js.map +1 -1
  70. package/lib/programmers/internal/CoreMetadataUtil.d.ts +3 -3
  71. package/lib/programmers/internal/CoreMetadataUtil.js.map +1 -1
  72. package/lib/transform.d.ts +1 -1
  73. package/lib/transform.js.map +1 -1
  74. package/lib/transformers/FileTransformer.js +2 -2
  75. package/lib/transformers/FileTransformer.js.map +1 -1
  76. package/lib/transformers/MethodTransformer.js.map +1 -1
  77. package/lib/transformers/ParameterDecoratorTransformer.js +1 -1
  78. package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
  79. package/lib/transformers/TypedRouteTransformer.js +1 -1
  80. package/lib/transformers/TypedRouteTransformer.js.map +1 -1
  81. package/lib/transformers/WebSocketRouteTransformer.js +1 -1
  82. package/lib/transformers/WebSocketRouteTransformer.js.map +1 -1
  83. package/package.json +34 -26
  84. package/src/adaptors/WebSocketAdaptor.ts +429 -429
  85. package/src/decorators/DynamicModule.ts +44 -44
  86. package/src/decorators/EncryptedBody.ts +96 -97
  87. package/src/decorators/EncryptedController.ts +40 -40
  88. package/src/decorators/EncryptedModule.ts +98 -98
  89. package/src/decorators/EncryptedRoute.ts +212 -213
  90. package/src/decorators/HumanRoute.ts +21 -22
  91. package/src/decorators/NoTransformConfigurationError.ts +34 -34
  92. package/src/decorators/PlainBody.ts +76 -76
  93. package/src/decorators/SwaggerCustomizer.ts +97 -97
  94. package/src/decorators/SwaggerExample.ts +100 -100
  95. package/src/decorators/TypedBody.ts +57 -57
  96. package/src/decorators/TypedException.ts +147 -147
  97. package/src/decorators/TypedFormData.ts +187 -195
  98. package/src/decorators/TypedHeaders.ts +66 -66
  99. package/src/decorators/TypedParam.ts +77 -77
  100. package/src/decorators/TypedQuery.ts +234 -234
  101. package/src/decorators/TypedRoute.ts +196 -196
  102. package/src/decorators/WebSocketRoute.ts +242 -242
  103. package/src/decorators/internal/EncryptedConstant.ts +2 -2
  104. package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
  105. package/src/decorators/internal/NoTransformConfigureError.ts +2 -2
  106. package/src/decorators/internal/get_path_and_querify.ts +94 -94
  107. package/src/decorators/internal/get_path_and_stringify.ts +110 -110
  108. package/src/decorators/internal/get_text_body.ts +16 -16
  109. package/src/decorators/internal/headers_to_object.ts +11 -11
  110. package/src/decorators/internal/is_request_body_undefined.ts +12 -12
  111. package/src/decorators/internal/load_controller.ts +45 -45
  112. package/src/decorators/internal/route_error.ts +43 -43
  113. package/src/decorators/internal/validate_request_body.ts +64 -64
  114. package/src/decorators/internal/validate_request_form_data.ts +67 -67
  115. package/src/decorators/internal/validate_request_headers.ts +76 -76
  116. package/src/decorators/internal/validate_request_query.ts +64 -64
  117. package/src/index.ts +5 -5
  118. package/src/module.ts +23 -22
  119. package/src/options/INestiaTransformOptions.ts +34 -34
  120. package/src/options/INestiaTransformProject.ts +10 -8
  121. package/src/options/IRequestBodyValidator.ts +20 -20
  122. package/src/options/IRequestFormDataProps.ts +27 -27
  123. package/src/options/IRequestHeadersValidator.ts +22 -22
  124. package/src/options/IRequestQueryValidator.ts +20 -20
  125. package/src/options/IResponseBodyQuerifier.ts +25 -25
  126. package/src/options/IResponseBodyStringifier.ts +30 -30
  127. package/src/programmers/PlainBodyProgrammer.ts +72 -70
  128. package/src/programmers/TypedBodyProgrammer.ts +144 -142
  129. package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
  130. package/src/programmers/TypedHeadersProgrammer.ts +65 -63
  131. package/src/programmers/TypedParamProgrammer.ts +33 -33
  132. package/src/programmers/TypedQueryBodyProgrammer.ts +111 -109
  133. package/src/programmers/TypedQueryProgrammer.ts +113 -111
  134. package/src/programmers/TypedQueryRouteProgrammer.ts +104 -102
  135. package/src/programmers/TypedRouteProgrammer.ts +96 -94
  136. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +74 -72
  137. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +77 -75
  138. package/src/programmers/http/HttpQuerifyProgrammer.ts +110 -108
  139. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +78 -76
  140. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  141. package/src/transform.ts +35 -35
  142. package/src/transformers/FileTransformer.ts +109 -110
  143. package/src/transformers/MethodTransformer.ts +103 -103
  144. package/src/transformers/NodeTransformer.ts +23 -23
  145. package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
  146. package/src/transformers/ParameterTransformer.ts +57 -57
  147. package/src/transformers/TypedRouteTransformer.ts +85 -85
  148. package/src/transformers/WebSocketRouteTransformer.ts +120 -120
  149. package/src/typings/Creator.ts +3 -3
  150. package/src/typings/get-function-location.d.ts +7 -7
  151. package/src/utils/ArrayUtil.ts +7 -7
  152. package/src/utils/ExceptionManager.ts +115 -115
  153. package/src/utils/Singleton.ts +16 -16
  154. package/src/utils/SourceFinder.ts +54 -54
  155. package/src/utils/VersioningStrategy.ts +27 -27
@@ -1,213 +1,212 @@
1
- import { AesPkcs5 } from "@nestia/fetcher/lib/AesPkcs5";
2
- import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
3
- import {
4
- CallHandler,
5
- Delete,
6
- ExecutionContext,
7
- Get,
8
- NestInterceptor,
9
- Patch,
10
- Post,
11
- Put,
12
- UseInterceptors,
13
- applyDecorators,
14
- } from "@nestjs/common";
15
- import { HttpArgumentsHost } from "@nestjs/common/interfaces";
16
- import express from "express";
17
- import { catchError, map } from "rxjs/operators";
18
- import typia from "typia";
19
-
20
- import { IResponseBodyStringifier } from "../options/IResponseBodyStringifier";
21
- import { Singleton } from "../utils/Singleton";
22
- import { TypedRoute } from "./TypedRoute";
23
- import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
24
- import { get_path_and_stringify } from "./internal/get_path_and_stringify";
25
- import { headers_to_object } from "./internal/headers_to_object";
26
- import { route_error } from "./internal/route_error";
27
-
28
- /**
29
- * Encrypted router decorator functions.
30
- *
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).
36
- *
37
- * For reference, if you try to invalid data that is not following the promised
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.
41
- *
42
- * - AES-128/256
43
- * - CBC mode
44
- * - PKCS #5 Padding
45
- * - Base64 Encoding
46
- *
47
- * @author Jeongho Nam - https://github.com/samchon
48
- */
49
- export namespace EncryptedRoute {
50
- /**
51
- * Encrypted router decorator function for the GET method.
52
- *
53
- * @param paths Path(s) of the HTTP request
54
- * @returns Method decorator
55
- */
56
- export const Get = Generator("Get");
57
-
58
- /**
59
- * Encrypted router decorator function for the GET method.
60
- *
61
- * @param paths Path(s) of the HTTP request
62
- * @returns Method decorator
63
- */
64
- export const Post = Generator("Post");
65
-
66
- /**
67
- * Encrypted router decorator function for the PATCH method.
68
- *
69
- * @param path Path of the HTTP request
70
- * @returns Method decorator
71
- */
72
- export const Patch = Generator("Patch");
73
-
74
- /**
75
- * Encrypted router decorator function for the PUT method.
76
- *
77
- * @param path Path of the HTTP request
78
- * @returns Method decorator
79
- */
80
- export const Put = Generator("Put");
81
-
82
- /**
83
- * Encrypted router decorator function for the DELETE method.
84
- *
85
- * @param path Path of the HTTP request
86
- * @returns Method decorator
87
- */
88
- export const Delete = Generator("Delete");
89
-
90
- /**
91
- * Set the logger function for the response validation failure.
92
- *
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.
97
- *
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
- *
102
- * @default console.log
103
- * @param func Logger function
104
- */
105
- export function setValidateErrorLogger(
106
- func: (log: IValidateErrorLog) => void,
107
- ): void {
108
- TypedRoute.setValidateErrorLogger(func);
109
- }
110
-
111
- export import IValidateErrorLog = TypedRoute.IValidateErrorLog;
112
-
113
- /** @internal */
114
- function Generator(method: "Get" | "Post" | "Put" | "Patch" | "Delete") {
115
- function route(path?: string | string[]): MethodDecorator;
116
- function route<T>(
117
- stringify?: IResponseBodyStringifier<T> | null,
118
- ): MethodDecorator;
119
- function route<T>(
120
- path: string | string[],
121
- stringify?: IResponseBodyStringifier<T> | null,
122
- ): MethodDecorator;
123
-
124
- function route(...args: any[]): MethodDecorator {
125
- const [path, stringify] = get_path_and_stringify(
126
- () => TypedRoute.__logger,
127
- )(`EncryptedRoute.${method}`)(...args);
128
- return applyDecorators(
129
- ROUTERS[method](path),
130
- UseInterceptors(new EncryptedRouteInterceptor(method, stringify)),
131
- );
132
- }
133
- return route;
134
- }
135
- }
136
-
137
- for (const method of [
138
- typia.json.isStringify,
139
- typia.json.assertStringify,
140
- typia.json.validateStringify,
141
- typia.json.stringify,
142
- ])
143
- for (const [key, value] of Object.entries(method))
144
- for (const deco of [
145
- EncryptedRoute.Get,
146
- EncryptedRoute.Delete,
147
- EncryptedRoute.Post,
148
- EncryptedRoute.Put,
149
- EncryptedRoute.Patch,
150
- ])
151
- (deco as any)[key] = value;
152
-
153
- /** @internal */
154
- class EncryptedRouteInterceptor implements NestInterceptor {
155
- public constructor(
156
- private readonly method: string,
157
- private readonly stringify: (
158
- input: any,
159
- method: string,
160
- path: string,
161
- ) => string,
162
- ) {}
163
-
164
- public intercept(context: ExecutionContext, next: CallHandler) {
165
- const http: HttpArgumentsHost = context.switchToHttp();
166
- return next.handle().pipe(
167
- map((value) => {
168
- const param:
169
- | IEncryptionPassword
170
- | IEncryptionPassword.Closure
171
- | undefined = Reflect.getMetadata(
172
- ENCRYPTION_METADATA_KEY,
173
- context.getClass(),
174
- );
175
- if (!param)
176
- return Error(
177
- `Error on EncryptedRoute.${this.method}(): no password found.`,
178
- );
179
-
180
- const request: express.Request = http.getRequest();
181
- const headers: Singleton<Record<string, string>> = new Singleton(() =>
182
- headers_to_object(request.headers),
183
- );
184
- const body: string | undefined = this.stringify(
185
- value,
186
- request.method,
187
- request.url,
188
- );
189
- const password: IEncryptionPassword =
190
- typeof param === "function"
191
- ? param({
192
- headers: headers.get(),
193
- body,
194
- direction: "encode",
195
- })
196
- : param;
197
-
198
- if (body === undefined) return body;
199
- return AesPkcs5.encrypt(body, password.key, password.iv);
200
- }),
201
- catchError((err) => route_error(http.getRequest(), err)),
202
- );
203
- }
204
- }
205
-
206
- /** @internal */
207
- const ROUTERS = {
208
- Get,
209
- Post,
210
- Put,
211
- Patch,
212
- Delete,
213
- };
1
+ import { AesPkcs5, IEncryptionPassword } from "@nestia/fetcher";
2
+ import {
3
+ CallHandler,
4
+ Delete,
5
+ ExecutionContext,
6
+ Get,
7
+ NestInterceptor,
8
+ Patch,
9
+ Post,
10
+ Put,
11
+ UseInterceptors,
12
+ applyDecorators,
13
+ } from "@nestjs/common";
14
+ import { HttpArgumentsHost } from "@nestjs/common/interfaces";
15
+ import express from "express";
16
+ import { catchError, map } from "rxjs/operators";
17
+ import typia from "typia";
18
+
19
+ import { IResponseBodyStringifier } from "../options/IResponseBodyStringifier";
20
+ import { Singleton } from "../utils/Singleton";
21
+ import { TypedRoute } from "./TypedRoute";
22
+ import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
23
+ import { get_path_and_stringify } from "./internal/get_path_and_stringify";
24
+ import { headers_to_object } from "./internal/headers_to_object";
25
+ import { route_error } from "./internal/route_error";
26
+
27
+ /**
28
+ * Encrypted router decorator functions.
29
+ *
30
+ * `EncryptedRoute` is a module containing router decorator functions which
31
+ * encrypts response body data through AES-128/256 encryption. Furthermore, they
32
+ * can boost up JSON string conversion speed about 50x times faster than
33
+ * `class-transformer`, even type safe through
34
+ * [typia](https://github.com/samchon/typia).
35
+ *
36
+ * 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
+ * `EncryptedRoute` composes JSON string through `typia.assertStringify<T>()`
39
+ * function, it is not possible to modify response data through interceptors.
40
+ *
41
+ * - AES-128/256
42
+ * - CBC mode
43
+ * - PKCS #5 Padding
44
+ * - Base64 Encoding
45
+ *
46
+ * @author Jeongho Nam - https://github.com/samchon
47
+ */
48
+ export namespace EncryptedRoute {
49
+ /**
50
+ * Encrypted router decorator function for the GET method.
51
+ *
52
+ * @param paths Path(s) of the HTTP request
53
+ * @returns Method decorator
54
+ */
55
+ export const Get = Generator("Get");
56
+
57
+ /**
58
+ * Encrypted router decorator function for the GET method.
59
+ *
60
+ * @param paths Path(s) of the HTTP request
61
+ * @returns Method decorator
62
+ */
63
+ export const Post = Generator("Post");
64
+
65
+ /**
66
+ * Encrypted router decorator function for the PATCH method.
67
+ *
68
+ * @param path Path of the HTTP request
69
+ * @returns Method decorator
70
+ */
71
+ export const Patch = Generator("Patch");
72
+
73
+ /**
74
+ * Encrypted router decorator function for the PUT method.
75
+ *
76
+ * @param path Path of the HTTP request
77
+ * @returns Method decorator
78
+ */
79
+ export const Put = Generator("Put");
80
+
81
+ /**
82
+ * Encrypted router decorator function for the DELETE method.
83
+ *
84
+ * @param path Path of the HTTP request
85
+ * @returns Method decorator
86
+ */
87
+ export const Delete = Generator("Delete");
88
+
89
+ /**
90
+ * Set the logger function for the response validation failure.
91
+ *
92
+ * If you've configured the transformation option to `validate.log` in the
93
+ * `tsconfig.json` file, then the error log information of the response
94
+ * validation failure would be logged through this function instead of
95
+ * throwing the 400 bad request error.
96
+ *
97
+ * By the way, be careful. If you've configured the response transformation
98
+ * option to be `validate.log`, client may get wrong response data. Therefore,
99
+ * this way is not recommended in the common backend server case.
100
+ *
101
+ * @default console.log
102
+ * @param func Logger function
103
+ */
104
+ export function setValidateErrorLogger(
105
+ func: (log: IValidateErrorLog) => void,
106
+ ): void {
107
+ TypedRoute.setValidateErrorLogger(func);
108
+ }
109
+
110
+ export import IValidateErrorLog = TypedRoute.IValidateErrorLog;
111
+
112
+ /** @internal */
113
+ function Generator(method: "Get" | "Post" | "Put" | "Patch" | "Delete") {
114
+ function route(path?: string | string[]): MethodDecorator;
115
+ function route<T>(
116
+ stringify?: IResponseBodyStringifier<T> | null,
117
+ ): MethodDecorator;
118
+ function route<T>(
119
+ path: string | string[],
120
+ stringify?: IResponseBodyStringifier<T> | null,
121
+ ): MethodDecorator;
122
+
123
+ function route(...args: any[]): MethodDecorator {
124
+ const [path, stringify] = get_path_and_stringify(
125
+ () => TypedRoute.__logger,
126
+ )(`EncryptedRoute.${method}`)(...args);
127
+ return applyDecorators(
128
+ ROUTERS[method](path),
129
+ UseInterceptors(new EncryptedRouteInterceptor(method, stringify)),
130
+ );
131
+ }
132
+ return route;
133
+ }
134
+ }
135
+
136
+ for (const method of [
137
+ typia.json.isStringify,
138
+ typia.json.assertStringify,
139
+ typia.json.validateStringify,
140
+ typia.json.stringify,
141
+ ])
142
+ for (const [key, value] of Object.entries(method))
143
+ for (const deco of [
144
+ EncryptedRoute.Get,
145
+ EncryptedRoute.Delete,
146
+ EncryptedRoute.Post,
147
+ EncryptedRoute.Put,
148
+ EncryptedRoute.Patch,
149
+ ])
150
+ (deco as any)[key] = value;
151
+
152
+ /** @internal */
153
+ class EncryptedRouteInterceptor implements NestInterceptor {
154
+ public constructor(
155
+ private readonly method: string,
156
+ private readonly stringify: (
157
+ input: any,
158
+ method: string,
159
+ path: string,
160
+ ) => string,
161
+ ) {}
162
+
163
+ public intercept(context: ExecutionContext, next: CallHandler) {
164
+ const http: HttpArgumentsHost = context.switchToHttp();
165
+ return next.handle().pipe(
166
+ map((value) => {
167
+ const param:
168
+ | IEncryptionPassword
169
+ | IEncryptionPassword.Closure
170
+ | undefined = Reflect.getMetadata(
171
+ ENCRYPTION_METADATA_KEY,
172
+ context.getClass(),
173
+ );
174
+ if (!param)
175
+ return Error(
176
+ `Error on EncryptedRoute.${this.method}(): no password found.`,
177
+ );
178
+
179
+ const request: express.Request = http.getRequest();
180
+ const headers: Singleton<Record<string, string>> = new Singleton(() =>
181
+ headers_to_object(request.headers),
182
+ );
183
+ const body: string | undefined = this.stringify(
184
+ value,
185
+ request.method,
186
+ request.url,
187
+ );
188
+ const password: IEncryptionPassword =
189
+ typeof param === "function"
190
+ ? param({
191
+ headers: headers.get(),
192
+ body,
193
+ direction: "encode",
194
+ })
195
+ : param;
196
+
197
+ if (body === undefined) return body;
198
+ return AesPkcs5.encrypt(body, password.key, password.iv);
199
+ }),
200
+ catchError((err) => route_error(http.getRequest(), err)),
201
+ );
202
+ }
203
+ }
204
+
205
+ /** @internal */
206
+ const ROUTERS = {
207
+ Get,
208
+ Post,
209
+ Put,
210
+ Patch,
211
+ Delete,
212
+ };
@@ -1,22 +1,21 @@
1
- import { SwaggerCustomizer } from "./SwaggerCustomizer";
2
-
3
- /**
4
- * Human only API marking.
5
- *
6
- * This decorator marks the API for human only, so that LLM function calling
7
- * schema composer (of [`@samchon/openapi`](https://github.com/samchon/openapi))
8
- * excludes the API.
9
- *
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
- * {@link HttpLlm.application} function, matched {@link IHttpLlmFunction} data
13
- * never be composed.
14
- *
15
- * @author Jeongho Nam - https://github.com/samchon
16
- * @returns Method decorator
17
- */
18
- export function HumanRoute(): MethodDecorator {
19
- return SwaggerCustomizer((props) => {
20
- props.route["x-samchon-human"] = true;
21
- });
22
- }
1
+ import { SwaggerCustomizer } from "./SwaggerCustomizer";
2
+
3
+ /**
4
+ * Human only API marking.
5
+ *
6
+ * This decorator marks the API for human only, so that LLM function calling
7
+ * schema composer excludes the API.
8
+ *
9
+ * In other words, if you adjust the `@HumanRoute()` decorator to the API, the
10
+ * API never participates in the LLM function calling. When calling the
11
+ * {@link HttpLlm.application} function, matched {@link IHttpLlmFunction} data
12
+ * never be composed.
13
+ *
14
+ * @author Jeongho Nam - https://github.com/samchon
15
+ * @returns Method decorator
16
+ */
17
+ export function HumanRoute(): MethodDecorator {
18
+ return SwaggerCustomizer((props) => {
19
+ props.route["x-samchon-human"] = true;
20
+ });
21
+ }
@@ -1,34 +1,34 @@
1
- export function NoTransformConfigurationError(method: string) {
2
- if (NoTransformConfigurationError.throws === true)
3
- throw new Error(
4
- [
5
- `Error on nestia.core.${method}(): no transform has been configured.`,
6
- `Run "npx typia setup" command, or check if you're using non-standard TypeScript compiler like Babel or SWC.`,
7
- `Otherwise you're running "npx nestia sdk/swagger" or similar, run "npx tsc" command to find the reason why.`,
8
- ].join(" "),
9
- );
10
- return undefined as never;
11
- }
12
- export namespace NoTransformConfigurationError {
13
- /**
14
- * Whether to throw an error or not.
15
- *
16
- * If you set this value to `false`, {@link NoTransformConfigurationError} will
17
- * not throw an error.
18
- *
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
- *
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
26
- * or testing.
27
- *
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.
32
- */
33
- export let throws = true;
34
- }
1
+ export function NoTransformConfigurationError(method: string) {
2
+ if (NoTransformConfigurationError.throws === true)
3
+ throw new Error(
4
+ [
5
+ `Error on nestia.core.${method}(): no transform has been configured.`,
6
+ `Run "npx nestia setup" command, or check if you're using non-standard TypeScript compiler like Babel or SWC.`,
7
+ `Otherwise you're running "npx nestia sdk/swagger" or similar, run "npx tsc" command to find the reason why.`,
8
+ ].join(" "),
9
+ );
10
+ return undefined as never;
11
+ }
12
+ export namespace NoTransformConfigurationError {
13
+ /**
14
+ * Whether to throw an error or not.
15
+ *
16
+ * If you set this value to `false`, {@link NoTransformConfigurationError} will
17
+ * not throw an error.
18
+ *
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
+ *
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
26
+ * or testing.
27
+ *
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.
32
+ */
33
+ export let throws = true;
34
+ }