@nestia/core 3.0.0-dev.20231209 → 3.0.0

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 (132) hide show
  1. package/README.md +12 -9
  2. package/lib/decorators/DynamicModule.js +3 -3
  3. package/lib/decorators/DynamicModule.js.map +1 -1
  4. package/lib/decorators/EncryptedBody.js +14 -13
  5. package/lib/decorators/EncryptedBody.js.map +1 -1
  6. package/lib/decorators/EncryptedModule.d.ts +1 -1
  7. package/lib/decorators/EncryptedModule.js +45 -21
  8. package/lib/decorators/EncryptedModule.js.map +1 -1
  9. package/lib/decorators/EncryptedRoute.d.ts +5 -5
  10. package/lib/decorators/EncryptedRoute.js +12 -29
  11. package/lib/decorators/EncryptedRoute.js.map +1 -1
  12. package/lib/decorators/PlainBody.js +3 -0
  13. package/lib/decorators/PlainBody.js.map +1 -1
  14. package/lib/decorators/SwaggerCustomizer.d.ts +79 -0
  15. package/lib/decorators/SwaggerCustomizer.js +32 -0
  16. package/lib/decorators/SwaggerCustomizer.js.map +1 -0
  17. package/lib/decorators/TypedBody.js +3 -0
  18. package/lib/decorators/TypedBody.js.map +1 -1
  19. package/lib/decorators/TypedException.d.ts +0 -1
  20. package/lib/decorators/TypedException.js +0 -1
  21. package/lib/decorators/TypedException.js.map +1 -1
  22. package/lib/decorators/TypedFormData.d.ts +60 -0
  23. package/lib/decorators/TypedFormData.js +403 -0
  24. package/lib/decorators/TypedFormData.js.map +1 -0
  25. package/lib/decorators/TypedQuery.d.ts +11 -6
  26. package/lib/decorators/TypedQuery.js +6 -1
  27. package/lib/decorators/TypedQuery.js.map +1 -1
  28. package/lib/decorators/TypedRoute.d.ts +5 -5
  29. package/lib/decorators/internal/get_path_and_querify.js +3 -0
  30. package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
  31. package/lib/decorators/internal/load_controller.js.map +1 -1
  32. package/lib/decorators/internal/validate_request_body.d.ts +1 -3
  33. package/lib/decorators/internal/validate_request_body.js +15 -0
  34. package/lib/decorators/internal/validate_request_body.js.map +1 -1
  35. package/lib/decorators/internal/validate_request_form_data.js +79 -0
  36. package/lib/decorators/internal/validate_request_form_data.js.map +1 -0
  37. package/lib/decorators/internal/validate_request_headers.d.ts +1 -3
  38. package/lib/decorators/internal/validate_request_headers.js +15 -0
  39. package/lib/decorators/internal/validate_request_headers.js.map +1 -1
  40. package/lib/decorators/internal/validate_request_query.d.ts +1 -3
  41. package/lib/decorators/internal/validate_request_query.js +15 -0
  42. package/lib/decorators/internal/validate_request_query.js.map +1 -1
  43. package/lib/module.d.ts +2 -0
  44. package/lib/module.js +2 -0
  45. package/lib/module.js.map +1 -1
  46. package/lib/options/IRequestFormDataProps.d.ts +23 -0
  47. package/lib/options/IRequestFormDataProps.js +3 -0
  48. package/lib/options/IRequestFormDataProps.js.map +1 -0
  49. package/lib/programmers/PlainBodyProgrammer.js +1 -1
  50. package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
  51. package/lib/programmers/TypedExceptionProgrammer.js +5 -5
  52. package/lib/programmers/TypedExceptionProgrammer.js.map +1 -1
  53. package/lib/programmers/TypedFormDataBodyProgrammer.d.ts +6 -0
  54. package/lib/programmers/TypedFormDataBodyProgrammer.js +84 -0
  55. package/lib/programmers/TypedFormDataBodyProgrammer.js.map +1 -0
  56. package/lib/programmers/http/HttpQuerifyProgrammer.js +2 -2
  57. package/lib/programmers/http/HttpQuerifyProgrammer.js.map +1 -1
  58. package/lib/transformers/NodeTransformer.js.map +1 -1
  59. package/lib/transformers/ParameterDecoratorTransformer.js +7 -1
  60. package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
  61. package/lib/transformers/TypedExceptionTransformer.js +1 -1
  62. package/lib/transformers/TypedExceptionTransformer.js.map +1 -1
  63. package/lib/transformers/TypedRouteTransformer.js +1 -1
  64. package/lib/transformers/TypedRouteTransformer.js.map +1 -1
  65. package/package.json +15 -16
  66. package/src/decorators/DynamicModule.ts +39 -39
  67. package/src/decorators/EncryptedBody.ts +105 -107
  68. package/src/decorators/EncryptedController.ts +38 -38
  69. package/src/decorators/EncryptedModule.ts +96 -79
  70. package/src/decorators/EncryptedRoute.ts +182 -206
  71. package/src/decorators/PlainBody.ts +75 -72
  72. package/src/decorators/SwaggerCustomizer.ts +115 -0
  73. package/src/decorators/TypedBody.ts +62 -59
  74. package/src/decorators/TypedException.ts +90 -89
  75. package/src/decorators/TypedFormData.ts +219 -0
  76. package/src/decorators/TypedHeaders.ts +69 -69
  77. package/src/decorators/TypedParam.ts +65 -65
  78. package/src/decorators/TypedQuery.ts +251 -246
  79. package/src/decorators/TypedRoute.ts +144 -144
  80. package/src/decorators/internal/EncryptedConstant.ts +4 -4
  81. package/src/decorators/internal/NoTransformConfigureError.ts +8 -8
  82. package/src/decorators/internal/get_path_and_querify.ts +106 -103
  83. package/src/decorators/internal/get_path_and_stringify.ts +91 -91
  84. package/src/decorators/internal/get_text_body.ts +20 -20
  85. package/src/decorators/internal/headers_to_object.ts +13 -13
  86. package/src/decorators/internal/load_controller.ts +51 -51
  87. package/src/decorators/internal/route_error.ts +45 -45
  88. package/src/decorators/internal/validate_request_body.ts +72 -57
  89. package/src/decorators/internal/validate_request_form_data.ts +75 -0
  90. package/src/decorators/internal/validate_request_headers.ts +83 -68
  91. package/src/decorators/internal/validate_request_query.ts +71 -56
  92. package/src/index.ts +5 -5
  93. package/src/module.ts +16 -14
  94. package/src/options/INestiaTransformOptions.ts +17 -17
  95. package/src/options/INestiaTransformProject.ts +7 -7
  96. package/src/options/IRequestBodyValidator.ts +20 -20
  97. package/src/options/IRequestFormDataProps.ts +27 -0
  98. package/src/options/IRequestHeadersValidator.ts +22 -22
  99. package/src/options/IRequestQueryValidator.ts +20 -20
  100. package/src/options/IResponseBodyQuerifier.ts +25 -25
  101. package/src/options/IResponseBodyStringifier.ts +25 -25
  102. package/src/programmers/PlainBodyProgrammer.ts +52 -52
  103. package/src/programmers/TypedBodyProgrammer.ts +108 -108
  104. package/src/programmers/TypedExceptionProgrammer.ts +71 -72
  105. package/src/programmers/TypedFormDataBodyProgrammer.ts +108 -0
  106. package/src/programmers/TypedHeadersProgrammer.ts +56 -56
  107. package/src/programmers/TypedParamProgrammer.ts +24 -24
  108. package/src/programmers/TypedQueryBodyProgrammer.ts +56 -56
  109. package/src/programmers/TypedQueryProgrammer.ts +56 -56
  110. package/src/programmers/TypedQueryRouteProgrammer.ts +51 -51
  111. package/src/programmers/TypedRouteProgrammer.ts +51 -51
  112. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +58 -58
  113. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +62 -62
  114. package/src/programmers/http/HttpQuerifyProgrammer.ts +96 -96
  115. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +63 -63
  116. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  117. package/src/transform.ts +35 -35
  118. package/src/transformers/FileTransformer.ts +66 -66
  119. package/src/transformers/MethodTransformer.ts +94 -94
  120. package/src/transformers/NodeTransformer.ts +16 -16
  121. package/src/transformers/ParameterDecoratorTransformer.ts +120 -121
  122. package/src/transformers/ParameterTransformer.ts +48 -48
  123. package/src/transformers/TypedExceptionTransformer.ts +48 -49
  124. package/src/transformers/TypedRouteTransformer.ts +88 -95
  125. package/src/typings/Creator.ts +3 -3
  126. package/src/utils/ExceptionManager.ts +112 -112
  127. package/src/utils/Singleton.ts +20 -20
  128. package/src/utils/SourceFinder.ts +57 -57
  129. package/lib/decorators/internal/get_binary_body.js +0 -66
  130. package/lib/decorators/internal/get_binary_body.js.map +0 -1
  131. package/src/decorators/internal/get_binary_body.ts +0 -18
  132. /package/lib/decorators/internal/{get_binary_body.d.ts → validate_request_form_data.d.ts} +0 -0
@@ -1,112 +1,112 @@
1
- import { HttpError } from "@nestia/fetcher";
2
- import { HttpException } from "@nestjs/common";
3
-
4
- import { Creator } from "../typings/Creator";
5
-
6
- /**
7
- * Exception manager for HTTP server.
8
- *
9
- * `ExceptionManager` is an utility class who can insert or erase custom error class with
10
- * its convertion method to a regular {@link nest.HttpException} instance.
11
- *
12
- * If you define an API function through {@link TypedRoute} or {@link EncryptedRoute}
13
- * instead of the basic router decorator functions like {@link nest.Get} or
14
- * {@link nest.Post} and the API function throws a custom error whose class has been
15
- * {@link ExceptionManager.insert inserted} in this `EntityManager`, the error would be
16
- * automatically converted to the regular {@link nest.HttpException} instance by the
17
- * {@link ExceptionManager.Closure} function.
18
- *
19
- * Therefore, with this `ExceptionManager` and {@link TypedRoute} or {@link EncryptedRoute},
20
- * you can manage your custom error classes much systemtically. You can avoid 500 internal
21
- * server error or hard coding implementation about the custom error classes.
22
- *
23
- * Below error classes are defaultly configured in this `ExceptionManager`
24
- *
25
- * - `typia.TypeGuardError`
26
- * - `@nestia/fetcher.HttpError`
27
- *
28
- * @author Jeongho Nam - https://github.com/samchon
29
- */
30
- export namespace ExceptionManager {
31
- /**
32
- * Insert an error class with converter.
33
- *
34
- * If you've inserted an duplicated error class, the closure would be overwritten.
35
- *
36
- * @param creator Target error class
37
- * @param closure A closure function converting to the `HttpException` class
38
- */
39
- export function insert<T extends Error>(
40
- creator: Creator<T>,
41
- closure: Closure<T>,
42
- ): void {
43
- const index: number = tuples.findIndex((tuple) => tuple[0] === creator);
44
- if (index !== -1) tuples.splice(index, 1);
45
-
46
- tuples.push([creator, closure]);
47
- tuples.sort(([x], [y]) => (x.prototype instanceof y ? -1 : 1));
48
- }
49
-
50
- /**
51
- * Erase an error class.
52
- *
53
- * @param creator Target error class
54
- * @returns Whether be erased or not
55
- */
56
- export function erase<T extends Error>(creator: Creator<T>): boolean {
57
- const index: number = tuples.findIndex((tuple) => tuple[0] === creator);
58
- if (index === -1) return false;
59
-
60
- tuples.splice(index, 1);
61
- return true;
62
- }
63
-
64
- export function on(closure: (error: any) => any): void {
65
- listeners.add(closure);
66
- }
67
-
68
- export function off(closure: (error: any) => any): void {
69
- listeners.delete(closure);
70
- }
71
-
72
- /**
73
- * Type of a closure function converting to the regular {@link nest.HttpException}.
74
- *
75
- * `ExceptionManager.Closure` is a type of closure function who are converting from
76
- * custom error to the regular {@link nest.HttpException} instance. It would be used
77
- * in the {@link ExceptionManager} with {@link TypedRoute} or {@link EncryptedRoute}.
78
- */
79
- export interface Closure<T extends Error> {
80
- /**
81
- * Error converter.
82
- *
83
- * Convert from custom error to the regular {@link nest.HttpException} instance.
84
- *
85
- * @param exception Custom error instance
86
- * @return Regular {@link nest.HttpException} instance
87
- */
88
- (exception: T): HttpException;
89
- }
90
-
91
- /**
92
- * @internal
93
- */
94
- export const tuples: Array<[Creator<any>, Closure<any>]> = [];
95
-
96
- /**
97
- * @internal
98
- */
99
- export const listeners: Set<(error: any) => any> = new Set();
100
- }
101
-
102
- ExceptionManager.insert(
103
- HttpError,
104
- (error) =>
105
- new HttpException(
106
- {
107
- path: error.path,
108
- message: error.message,
109
- },
110
- error.status,
111
- ),
112
- );
1
+ import { HttpError } from "@nestia/fetcher";
2
+ import { HttpException } from "@nestjs/common";
3
+
4
+ import { Creator } from "../typings/Creator";
5
+
6
+ /**
7
+ * Exception manager for HTTP server.
8
+ *
9
+ * `ExceptionManager` is an utility class who can insert or erase custom error class with
10
+ * its convertion method to a regular {@link nest.HttpException} instance.
11
+ *
12
+ * If you define an API function through {@link TypedRoute} or {@link EncryptedRoute}
13
+ * instead of the basic router decorator functions like {@link nest.Get} or
14
+ * {@link nest.Post} and the API function throws a custom error whose class has been
15
+ * {@link ExceptionManager.insert inserted} in this `EntityManager`, the error would be
16
+ * automatically converted to the regular {@link nest.HttpException} instance by the
17
+ * {@link ExceptionManager.Closure} function.
18
+ *
19
+ * Therefore, with this `ExceptionManager` and {@link TypedRoute} or {@link EncryptedRoute},
20
+ * you can manage your custom error classes much systemtically. You can avoid 500 internal
21
+ * server error or hard coding implementation about the custom error classes.
22
+ *
23
+ * Below error classes are defaultly configured in this `ExceptionManager`
24
+ *
25
+ * - `typia.TypeGuardError`
26
+ * - `@nestia/fetcher.HttpError`
27
+ *
28
+ * @author Jeongho Nam - https://github.com/samchon
29
+ */
30
+ export namespace ExceptionManager {
31
+ /**
32
+ * Insert an error class with converter.
33
+ *
34
+ * If you've inserted an duplicated error class, the closure would be overwritten.
35
+ *
36
+ * @param creator Target error class
37
+ * @param closure A closure function converting to the `HttpException` class
38
+ */
39
+ export function insert<T extends Error>(
40
+ creator: Creator<T>,
41
+ closure: Closure<T>,
42
+ ): void {
43
+ const index: number = tuples.findIndex((tuple) => tuple[0] === creator);
44
+ if (index !== -1) tuples.splice(index, 1);
45
+
46
+ tuples.push([creator, closure]);
47
+ tuples.sort(([x], [y]) => (x.prototype instanceof y ? -1 : 1));
48
+ }
49
+
50
+ /**
51
+ * Erase an error class.
52
+ *
53
+ * @param creator Target error class
54
+ * @returns Whether be erased or not
55
+ */
56
+ export function erase<T extends Error>(creator: Creator<T>): boolean {
57
+ const index: number = tuples.findIndex((tuple) => tuple[0] === creator);
58
+ if (index === -1) return false;
59
+
60
+ tuples.splice(index, 1);
61
+ return true;
62
+ }
63
+
64
+ export function on(closure: (error: any) => any): void {
65
+ listeners.add(closure);
66
+ }
67
+
68
+ export function off(closure: (error: any) => any): void {
69
+ listeners.delete(closure);
70
+ }
71
+
72
+ /**
73
+ * Type of a closure function converting to the regular {@link nest.HttpException}.
74
+ *
75
+ * `ExceptionManager.Closure` is a type of closure function who are converting from
76
+ * custom error to the regular {@link nest.HttpException} instance. It would be used
77
+ * in the {@link ExceptionManager} with {@link TypedRoute} or {@link EncryptedRoute}.
78
+ */
79
+ export interface Closure<T extends Error> {
80
+ /**
81
+ * Error converter.
82
+ *
83
+ * Convert from custom error to the regular {@link nest.HttpException} instance.
84
+ *
85
+ * @param exception Custom error instance
86
+ * @return Regular {@link nest.HttpException} instance
87
+ */
88
+ (exception: T): HttpException;
89
+ }
90
+
91
+ /**
92
+ * @internal
93
+ */
94
+ export const tuples: Array<[Creator<any>, Closure<any>]> = [];
95
+
96
+ /**
97
+ * @internal
98
+ */
99
+ export const listeners: Set<(error: any) => any> = new Set();
100
+ }
101
+
102
+ ExceptionManager.insert(
103
+ HttpError,
104
+ (error) =>
105
+ new HttpException(
106
+ {
107
+ path: error.path,
108
+ message: error.message,
109
+ },
110
+ error.status,
111
+ ),
112
+ );
@@ -1,20 +1,20 @@
1
- /**
2
- * @internal
3
- */
4
- export class Singleton<T> {
5
- private value_: T | object;
6
-
7
- public constructor(private readonly closure_: () => T) {
8
- this.value_ = NOT_MOUNTED_YET;
9
- }
10
-
11
- public get(): T {
12
- if (this.value_ === NOT_MOUNTED_YET) this.value_ = this.closure_();
13
- return this.value_ as T;
14
- }
15
- }
16
-
17
- /**
18
- * @internal
19
- */
20
- const NOT_MOUNTED_YET = {};
1
+ /**
2
+ * @internal
3
+ */
4
+ export class Singleton<T> {
5
+ private value_: T | object;
6
+
7
+ public constructor(private readonly closure_: () => T) {
8
+ this.value_ = NOT_MOUNTED_YET;
9
+ }
10
+
11
+ public get(): T {
12
+ if (this.value_ === NOT_MOUNTED_YET) this.value_ = this.closure_();
13
+ return this.value_ as T;
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @internal
19
+ */
20
+ const NOT_MOUNTED_YET = {};
@@ -1,57 +1,57 @@
1
- import fs from "fs";
2
- import glob from "glob";
3
- import path from "path";
4
-
5
- export namespace SourceFinder {
6
- export const find = async (props: IProps): Promise<string[]> => {
7
- const dict: Set<string> = new Set();
8
-
9
- await emplace(props.filter)(props.include)((str) => dict.add(str));
10
- if (props.exclude?.length)
11
- await emplace(props.filter)(props.exclude)((str) => dict.delete(str));
12
-
13
- return [...dict];
14
- };
15
-
16
- const emplace =
17
- (filter: (file: string) => boolean) =>
18
- (input: string[]) =>
19
- async (closure: (location: string) => void): Promise<void> => {
20
- for (const pattern of input) {
21
- for (const file of await _Glob(path.resolve(pattern))) {
22
- const stats: fs.Stats = await fs.promises.stat(file);
23
- if (stats.isDirectory() === true)
24
- await iterate(filter)(closure)(file);
25
- else if (stats.isFile() && filter(file)) closure(file);
26
- }
27
- }
28
- };
29
-
30
- const iterate =
31
- (filter: (location: string) => boolean) =>
32
- (closure: (location: string) => void) =>
33
- async (location: string): Promise<void> => {
34
- const directory: string[] = await fs.promises.readdir(location);
35
- for (const file of directory) {
36
- const next: string = path.resolve(`${location}/${file}`);
37
- const stats: fs.Stats = await fs.promises.stat(next);
38
-
39
- if (stats.isDirectory() === true) await iterate(filter)(closure)(next);
40
- else if (stats.isFile() && filter(next)) closure(next);
41
- }
42
- };
43
-
44
- const _Glob = (pattern: string): Promise<string[]> =>
45
- new Promise((resolve, reject) => {
46
- glob(pattern, (err, matches) => {
47
- if (err) reject(err);
48
- else resolve(matches.map((str) => path.resolve(str)));
49
- });
50
- });
51
- }
52
-
53
- interface IProps {
54
- exclude?: string[];
55
- include: string[];
56
- filter: (location: string) => boolean;
57
- }
1
+ import fs from "fs";
2
+ import glob from "glob";
3
+ import path from "path";
4
+
5
+ export namespace SourceFinder {
6
+ export const find = async (props: IProps): Promise<string[]> => {
7
+ const dict: Set<string> = new Set();
8
+
9
+ await emplace(props.filter)(props.include)((str) => dict.add(str));
10
+ if (props.exclude?.length)
11
+ await emplace(props.filter)(props.exclude)((str) => dict.delete(str));
12
+
13
+ return [...dict];
14
+ };
15
+
16
+ const emplace =
17
+ (filter: (file: string) => boolean) =>
18
+ (input: string[]) =>
19
+ async (closure: (location: string) => void): Promise<void> => {
20
+ for (const pattern of input) {
21
+ for (const file of await _Glob(path.resolve(pattern))) {
22
+ const stats: fs.Stats = await fs.promises.stat(file);
23
+ if (stats.isDirectory() === true)
24
+ await iterate(filter)(closure)(file);
25
+ else if (stats.isFile() && filter(file)) closure(file);
26
+ }
27
+ }
28
+ };
29
+
30
+ const iterate =
31
+ (filter: (location: string) => boolean) =>
32
+ (closure: (location: string) => void) =>
33
+ async (location: string): Promise<void> => {
34
+ const directory: string[] = await fs.promises.readdir(location);
35
+ for (const file of directory) {
36
+ const next: string = path.resolve(`${location}/${file}`);
37
+ const stats: fs.Stats = await fs.promises.stat(next);
38
+
39
+ if (stats.isDirectory() === true) await iterate(filter)(closure)(next);
40
+ else if (stats.isFile() && filter(next)) closure(next);
41
+ }
42
+ };
43
+
44
+ const _Glob = (pattern: string): Promise<string[]> =>
45
+ new Promise((resolve, reject) => {
46
+ glob(pattern, (err, matches) => {
47
+ if (err) reject(err);
48
+ else resolve(matches.map((str) => path.resolve(str)));
49
+ });
50
+ });
51
+ }
52
+
53
+ interface IProps {
54
+ exclude?: string[];
55
+ include: string[];
56
+ filter: (location: string) => boolean;
57
+ }
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.get_binary_body = void 0;
43
- var raw_body_1 = __importDefault(require("raw-body"));
44
- /**
45
- * @internal
46
- */
47
- var get_binary_body = function (request) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
48
- switch (_b.label) {
49
- case 0:
50
- if (!isExpressRequest(request)) return [3 /*break*/, 2];
51
- return [4 /*yield*/, (0, raw_body_1.default)(request)];
52
- case 1:
53
- _a = _b.sent();
54
- return [3 /*break*/, 3];
55
- case 2:
56
- _a = request.body;
57
- _b.label = 3;
58
- case 3: return [2 /*return*/, _a];
59
- }
60
- }); }); };
61
- exports.get_binary_body = get_binary_body;
62
- /**
63
- * @internal
64
- */
65
- var isExpressRequest = function (request) { return request.app !== undefined; };
66
- //# sourceMappingURL=get_binary_body.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get_binary_body.js","sourceRoot":"","sources":["../../../src/decorators/internal/get_binary_body.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sDAA2B;AAE3B;;GAEG;AACI,IAAM,eAAe,GAAG,UAC7B,OAAyC;;;iBAEzC,gBAAgB,CAAC,OAAO,CAAC,EAAzB,wBAAyB;YAAG,qBAAM,IAAA,kBAAG,EAAC,OAAO,CAAC,EAAA;;YAAlB,KAAA,SAAkB,CAAA;;;YAAG,KAAC,OAAO,CAAC,IAAmB,CAAA;;gBAA7E,0BAA6E;;SAAA,CAAC;AAHnE,QAAA,eAAe,mBAGoD;AAEhF;;GAEG;AACH,IAAM,gBAAgB,GAAG,UACvB,OAAyC,IACV,OAAC,OAA2B,CAAC,GAAG,KAAK,SAAS,EAA9C,CAA8C,CAAC"}
@@ -1,18 +0,0 @@
1
- import type express from "express";
2
- import type { FastifyRequest } from "fastify";
3
- import raw from "raw-body";
4
-
5
- /**
6
- * @internal
7
- */
8
- export const get_binary_body = async (
9
- request: express.Request | FastifyRequest,
10
- ): Promise<Uint8Array> =>
11
- isExpressRequest(request) ? await raw(request) : (request.body as Uint8Array);
12
-
13
- /**
14
- * @internal
15
- */
16
- const isExpressRequest = (
17
- request: express.Request | FastifyRequest,
18
- ): request is express.Request => (request as express.Request).app !== undefined;