@lerianstudio/sindarian-server 1.0.0-beta.1 → 1.0.0-beta.11

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 (199) hide show
  1. package/README.md +367 -0
  2. package/dist/constants/index.d.ts +1 -0
  3. package/dist/constants/index.d.ts.map +1 -1
  4. package/dist/constants/index.js +1 -0
  5. package/dist/constants/index.js.map +1 -1
  6. package/dist/constants/keys.d.ts +5 -0
  7. package/dist/constants/keys.d.ts.map +1 -1
  8. package/dist/constants/keys.js +6 -1
  9. package/dist/constants/keys.js.map +1 -1
  10. package/dist/constants/scopes.d.ts +6 -0
  11. package/dist/constants/scopes.d.ts.map +1 -0
  12. package/dist/constants/scopes.js +10 -0
  13. package/dist/constants/scopes.js.map +1 -0
  14. package/dist/context/arguments-host.d.ts +14 -0
  15. package/dist/context/arguments-host.d.ts.map +1 -0
  16. package/dist/context/arguments-host.js +28 -0
  17. package/dist/context/arguments-host.js.map +1 -0
  18. package/dist/context/execution-context.d.ts +10 -0
  19. package/dist/context/execution-context.d.ts.map +1 -0
  20. package/dist/context/execution-context.js +19 -0
  21. package/dist/context/execution-context.js.map +1 -0
  22. package/dist/context/http-arguments-host.d.ts +8 -0
  23. package/dist/context/http-arguments-host.d.ts.map +1 -0
  24. package/dist/context/http-arguments-host.js +17 -0
  25. package/dist/context/http-arguments-host.js.map +1 -0
  26. package/dist/context/index.d.ts +4 -0
  27. package/dist/context/index.d.ts.map +1 -0
  28. package/dist/context/index.js +20 -0
  29. package/dist/context/index.js.map +1 -0
  30. package/dist/controllers/base-controller.d.ts +0 -2
  31. package/dist/controllers/base-controller.d.ts.map +1 -1
  32. package/dist/controllers/base-controller.js +0 -15
  33. package/dist/controllers/base-controller.js.map +1 -1
  34. package/dist/controllers/decorators/body-decorator.d.ts +12 -17
  35. package/dist/controllers/decorators/body-decorator.d.ts.map +1 -1
  36. package/dist/controllers/decorators/body-decorator.js +55 -43
  37. package/dist/controllers/decorators/body-decorator.js.map +1 -1
  38. package/dist/controllers/decorators/controller-decorator.d.ts +5 -8
  39. package/dist/controllers/decorators/controller-decorator.d.ts.map +1 -1
  40. package/dist/controllers/decorators/controller-decorator.js +30 -66
  41. package/dist/controllers/decorators/controller-decorator.js.map +1 -1
  42. package/dist/controllers/decorators/param-decorator.d.ts +4 -9
  43. package/dist/controllers/decorators/param-decorator.d.ts.map +1 -1
  44. package/dist/controllers/decorators/param-decorator.js +33 -29
  45. package/dist/controllers/decorators/param-decorator.js.map +1 -1
  46. package/dist/controllers/decorators/query-decorator.d.ts +11 -15
  47. package/dist/controllers/decorators/query-decorator.d.ts.map +1 -1
  48. package/dist/controllers/decorators/query-decorator.js +24 -38
  49. package/dist/controllers/decorators/query-decorator.js.map +1 -1
  50. package/dist/controllers/decorators/request-decorator.d.ts +8 -12
  51. package/dist/controllers/decorators/request-decorator.d.ts.map +1 -1
  52. package/dist/controllers/decorators/request-decorator.js +21 -17
  53. package/dist/controllers/decorators/request-decorator.js.map +1 -1
  54. package/dist/controllers/decorators/route-decorator.d.ts +12 -1
  55. package/dist/controllers/decorators/route-decorator.d.ts.map +1 -1
  56. package/dist/controllers/decorators/route-decorator.js +24 -16
  57. package/dist/controllers/decorators/route-decorator.js.map +1 -1
  58. package/dist/dependency-injection/container.js +1 -1
  59. package/dist/dependency-injection/container.js.map +1 -1
  60. package/dist/dependency-injection/index.d.ts +2 -1
  61. package/dist/dependency-injection/index.d.ts.map +1 -1
  62. package/dist/dependency-injection/index.js +3 -2
  63. package/dist/dependency-injection/index.js.map +1 -1
  64. package/dist/dependency-injection/injectable-decorator.d.ts +7 -0
  65. package/dist/dependency-injection/injectable-decorator.d.ts.map +1 -0
  66. package/dist/dependency-injection/injectable-decorator.js +21 -0
  67. package/dist/dependency-injection/injectable-decorator.js.map +1 -0
  68. package/dist/exceptions/api-exception.d.ts +4 -7
  69. package/dist/exceptions/api-exception.d.ts.map +1 -1
  70. package/dist/exceptions/api-exception.js +8 -4
  71. package/dist/exceptions/api-exception.js.map +1 -1
  72. package/dist/exceptions/base-exception-filter.d.ts +8 -0
  73. package/dist/exceptions/base-exception-filter.d.ts.map +1 -0
  74. package/dist/exceptions/base-exception-filter.js +21 -0
  75. package/dist/exceptions/base-exception-filter.js.map +1 -0
  76. package/dist/exceptions/decorators/catch-decorator.d.ts +8 -0
  77. package/dist/exceptions/decorators/catch-decorator.d.ts.map +1 -0
  78. package/dist/exceptions/decorators/catch-decorator.js +14 -0
  79. package/dist/exceptions/decorators/catch-decorator.js.map +1 -0
  80. package/dist/exceptions/decorators/index.d.ts +3 -0
  81. package/dist/exceptions/decorators/index.d.ts.map +1 -0
  82. package/dist/exceptions/decorators/index.js +8 -0
  83. package/dist/exceptions/decorators/index.js.map +1 -0
  84. package/dist/exceptions/decorators/use-filters-decorator.d.ts +15 -0
  85. package/dist/exceptions/decorators/use-filters-decorator.d.ts.map +1 -0
  86. package/dist/exceptions/decorators/use-filters-decorator.js +47 -0
  87. package/dist/exceptions/decorators/use-filters-decorator.js.map +1 -0
  88. package/dist/exceptions/exception-filter.d.ts +6 -0
  89. package/dist/exceptions/exception-filter.d.ts.map +1 -0
  90. package/dist/exceptions/exception-filter.js +7 -0
  91. package/dist/exceptions/exception-filter.js.map +1 -0
  92. package/dist/exceptions/index.d.ts +3 -0
  93. package/dist/exceptions/index.d.ts.map +1 -1
  94. package/dist/exceptions/index.js +3 -0
  95. package/dist/exceptions/index.js.map +1 -1
  96. package/dist/index.d.ts +10 -0
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +15 -1
  99. package/dist/index.js.map +1 -1
  100. package/dist/interceptor/call-handler.d.ts +4 -0
  101. package/dist/interceptor/call-handler.d.ts.map +1 -0
  102. package/dist/interceptor/call-handler.js +3 -0
  103. package/dist/interceptor/call-handler.js.map +1 -0
  104. package/dist/interceptor/decorators/index.d.ts +2 -0
  105. package/dist/interceptor/decorators/index.d.ts.map +1 -0
  106. package/dist/interceptor/decorators/index.js +6 -0
  107. package/dist/interceptor/decorators/index.js.map +1 -0
  108. package/dist/interceptor/decorators/use-interceptor-decorator.d.ts +15 -0
  109. package/dist/interceptor/decorators/use-interceptor-decorator.d.ts.map +1 -0
  110. package/dist/interceptor/decorators/use-interceptor-decorator.js +76 -0
  111. package/dist/interceptor/decorators/use-interceptor-decorator.js.map +1 -0
  112. package/dist/interceptor/index.d.ts +4 -0
  113. package/dist/interceptor/index.d.ts.map +1 -0
  114. package/dist/interceptor/index.js +20 -0
  115. package/dist/interceptor/index.js.map +1 -0
  116. package/dist/interceptor/interceptor.d.ts +3 -5
  117. package/dist/interceptor/interceptor.d.ts.map +1 -1
  118. package/dist/interceptor/interceptor.js.map +1 -1
  119. package/dist/logger/console-logger.d.ts +24 -0
  120. package/dist/logger/console-logger.d.ts.map +1 -0
  121. package/dist/logger/console-logger.js +78 -0
  122. package/dist/logger/console-logger.js.map +1 -0
  123. package/dist/logger/index.d.ts +4 -0
  124. package/dist/logger/index.d.ts.map +1 -0
  125. package/dist/logger/index.js +8 -0
  126. package/dist/logger/index.js.map +1 -0
  127. package/dist/logger/logger-service.d.ts +34 -0
  128. package/dist/logger/logger-service.d.ts.map +1 -0
  129. package/dist/logger/logger-service.js +12 -0
  130. package/dist/logger/logger-service.js.map +1 -0
  131. package/dist/logger/logger.d.ts +21 -0
  132. package/dist/logger/logger.d.ts.map +1 -0
  133. package/dist/logger/logger.js +86 -0
  134. package/dist/logger/logger.js.map +1 -0
  135. package/dist/modules/module-decorator.d.ts +5 -3
  136. package/dist/modules/module-decorator.d.ts.map +1 -1
  137. package/dist/modules/module-decorator.js +78 -24
  138. package/dist/modules/module-decorator.js.map +1 -1
  139. package/dist/pipes/decorators/index.d.ts +2 -0
  140. package/dist/pipes/decorators/index.d.ts.map +1 -0
  141. package/dist/pipes/decorators/index.js +6 -0
  142. package/dist/pipes/decorators/index.js.map +1 -0
  143. package/dist/pipes/decorators/use-pipes.d.ts +19 -0
  144. package/dist/pipes/decorators/use-pipes.d.ts.map +1 -0
  145. package/dist/pipes/decorators/use-pipes.js +118 -0
  146. package/dist/pipes/decorators/use-pipes.js.map +1 -0
  147. package/dist/pipes/index.d.ts +3 -0
  148. package/dist/pipes/index.d.ts.map +1 -0
  149. package/dist/pipes/index.js +18 -0
  150. package/dist/pipes/index.js.map +1 -0
  151. package/dist/pipes/pipe-transform.d.ts +46 -0
  152. package/dist/pipes/pipe-transform.d.ts.map +1 -0
  153. package/dist/pipes/pipe-transform.js +3 -0
  154. package/dist/pipes/pipe-transform.js.map +1 -0
  155. package/dist/server/server-factory.d.ts +23 -6
  156. package/dist/server/server-factory.d.ts.map +1 -1
  157. package/dist/server/server-factory.js +114 -48
  158. package/dist/server/server-factory.js.map +1 -1
  159. package/dist/services/filters.d.ts +2 -0
  160. package/dist/services/filters.d.ts.map +1 -0
  161. package/dist/services/filters.js +5 -0
  162. package/dist/services/filters.js.map +1 -0
  163. package/dist/services/http-service.d.ts +68 -0
  164. package/dist/services/http-service.d.ts.map +1 -0
  165. package/dist/services/http-service.js +233 -0
  166. package/dist/services/http-service.js.map +1 -0
  167. package/dist/services/interceptor.d.ts +2 -0
  168. package/dist/services/interceptor.d.ts.map +1 -0
  169. package/dist/services/interceptor.js +5 -0
  170. package/dist/services/interceptor.js.map +1 -0
  171. package/dist/services/pipes.d.ts +2 -0
  172. package/dist/services/pipes.d.ts.map +1 -0
  173. package/dist/services/pipes.js +5 -0
  174. package/dist/services/pipes.js.map +1 -0
  175. package/dist/utils/form-data/get-form-data.d.ts +2 -0
  176. package/dist/utils/form-data/get-form-data.d.ts.map +1 -0
  177. package/dist/utils/form-data/get-form-data.js +11 -0
  178. package/dist/utils/form-data/get-form-data.js.map +1 -0
  179. package/dist/utils/search/create-query-string.d.ts +9 -0
  180. package/dist/utils/search/create-query-string.d.ts.map +1 -0
  181. package/dist/utils/search/create-query-string.js +26 -0
  182. package/dist/utils/search/create-query-string.js.map +1 -0
  183. package/dist/zod/create-zod-dto.d.ts +16 -0
  184. package/dist/zod/create-zod-dto.d.ts.map +1 -0
  185. package/dist/zod/create-zod-dto.js +14 -0
  186. package/dist/zod/create-zod-dto.js.map +1 -0
  187. package/dist/zod/index.d.ts +3 -0
  188. package/dist/zod/index.d.ts.map +1 -0
  189. package/dist/zod/index.js +8 -0
  190. package/dist/zod/index.js.map +1 -0
  191. package/dist/zod/zod-validation-pipe.d.ts +5 -0
  192. package/dist/zod/zod-validation-pipe.d.ts.map +1 -0
  193. package/dist/zod/zod-validation-pipe.js +35 -0
  194. package/dist/zod/zod-validation-pipe.js.map +1 -0
  195. package/package.json +7 -6
  196. package/dist/interceptor/decorators/use-interceptor.d.ts +0 -3
  197. package/dist/interceptor/decorators/use-interceptor.d.ts.map +0 -1
  198. package/dist/interceptor/decorators/use-interceptor.js +0 -9
  199. package/dist/interceptor/decorators/use-interceptor.js.map +0 -1
@@ -1,25 +1,20 @@
1
- import { z } from 'zod';
2
1
  export type BodyMetadata = {
3
- propertyIndex: number;
4
- schema?: () => z.ZodSchema;
5
- };
6
- /**
7
- * Handler to validate the body of the request.
8
- *
9
- * @param target - The target object.
10
- * @param propertyKey - The property key.
11
- * @param args - The arguments.
12
- * @returns The parameter and parameter index.
13
- */
14
- export declare function bodyDecoratorHandler(target: object, propertyKey: string | symbol, args: any[]): Promise<{
15
- parameter: any;
16
2
  parameterIndex: number;
17
- } | null>;
3
+ };
4
+ export declare class BodyHandler {
5
+ private static bodyCache;
6
+ static getMetadata(target: object, propertyKey: string | symbol): BodyMetadata | undefined;
7
+ static handle(target: object, propertyKey: string | symbol, args: any[]): Promise<{
8
+ type: string;
9
+ parameter: any;
10
+ parameterIndex: number;
11
+ paramType: any;
12
+ } | null>;
13
+ }
18
14
  /**
19
15
  * Decorator to validate the body of the request.
20
16
  *
21
- * @param schema - The Zod schema to validate the body against.
22
17
  * @returns A decorator function that can be used to decorate a controller method.
23
18
  */
24
- export declare function Body(schema?: z.ZodSchema | (() => z.ZodSchema)): (target: object, propertyKey: string | symbol, propertyIndex: number) => void;
19
+ export declare function Body(): (target: object, propertyKey: string | symbol, propertyIndex: number) => void;
25
20
  //# sourceMappingURL=body-decorator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/body-decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE;;;UA8CZ;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,IAE3D,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,eAAe,MAAM,UAcxB"}
1
+ {"version":3,"file":"body-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/body-decorator.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG;IACzB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,qBAAa,WAAW;IAEtB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAE1D,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,YAAY,GAAG,SAAS;WAmBd,MAAM,CACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE;;;;;;CAqDd;AAED;;;;GAIG;AACH,wBAAgB,IAAI,KAEhB,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,eAAe,MAAM,UAWxB"}
@@ -1,65 +1,77 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bodyDecoratorHandler = bodyDecoratorHandler;
3
+ exports.BodyHandler = void 0;
4
4
  exports.Body = Body;
5
5
  const keys_1 = require("../../constants/keys");
6
6
  const get_next_arguments_1 = require("../../utils/nextjs/get-next-arguments");
7
7
  const api_exception_1 = require("../../exceptions/api-exception");
8
- /**
9
- * Handler to validate the body of the request.
10
- *
11
- * @param target - The target object.
12
- * @param propertyKey - The property key.
13
- * @param args - The arguments.
14
- * @returns The parameter and parameter index.
15
- */
16
- async function bodyDecoratorHandler(target, propertyKey, args) {
17
- const metadata = Reflect.getOwnMetadata(keys_1.BODY_KEY, target, propertyKey);
18
- // If the metadata is not found, return null.
19
- if (metadata) {
20
- const request = (0, get_next_arguments_1.getNextRequestArgument)(args);
21
- let body;
22
- try {
23
- body = await request.json();
8
+ const get_form_data_1 = require("../../utils/form-data/get-form-data");
9
+ class BodyHandler {
10
+ static getMetadata(target, propertyKey) {
11
+ let metadata = Reflect.getOwnMetadata(keys_1.BODY_KEY, target, propertyKey);
12
+ // If not found on instance, try constructor prototype
13
+ if (!metadata && target.constructor) {
14
+ metadata = Reflect.getOwnMetadata(keys_1.BODY_KEY, target.constructor.prototype, propertyKey);
24
15
  }
25
- catch (error) {
26
- // Handle missing or invalid body
27
- throw new api_exception_1.ValidationApiException('Missing or invalid request body');
28
- }
29
- // If the schema is not provided, return the body.
30
- if (!metadata.schema) {
16
+ return metadata;
17
+ }
18
+ static async handle(target, propertyKey, args) {
19
+ const metadata = this.getMetadata(target, propertyKey);
20
+ // If the metadata is not found, return null.
21
+ if (metadata) {
22
+ // Get the route metadata to access paramTypes (check both target and prototype)
23
+ let routeMetadata = Reflect.getOwnMetadata(keys_1.ROUTE_KEY, target, propertyKey);
24
+ if (!routeMetadata && target.constructor) {
25
+ routeMetadata = Reflect.getOwnMetadata(keys_1.ROUTE_KEY, target.constructor.prototype, propertyKey);
26
+ }
27
+ const paramTypes = routeMetadata?.paramTypes || [];
28
+ const request = (0, get_next_arguments_1.getNextRequestArgument)(args);
29
+ // Check if body is already cached
30
+ let body = this.bodyCache.get(request);
31
+ if (!body) {
32
+ const contentType = request.headers.get('Content-Type');
33
+ try {
34
+ if (contentType?.includes('multipart/form-data')) {
35
+ body = (0, get_form_data_1.getFormData)(await request.formData());
36
+ }
37
+ else if (contentType?.includes('application/json')) {
38
+ body = await request.json();
39
+ }
40
+ else {
41
+ body = await request.text();
42
+ }
43
+ // Cache the parsed body
44
+ this.bodyCache.set(request, body);
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
+ }
47
+ catch (error) {
48
+ // Handle missing or invalid body
49
+ throw new api_exception_1.ValidationApiException('Missing or invalid request body');
50
+ }
51
+ }
31
52
  return {
53
+ type: 'body',
32
54
  parameter: body,
33
- parameterIndex: metadata.propertyIndex
55
+ parameterIndex: metadata.parameterIndex,
56
+ paramType: paramTypes[metadata.parameterIndex]
34
57
  };
35
58
  }
36
- // Parse the body using the schema.
37
- const resolvedSchema = metadata.schema?.();
38
- const parsedBody = resolvedSchema?.safeParse(body);
39
- // If the body is not valid, throw a validation error.
40
- if (parsedBody && !parsedBody.success) {
41
- throw new api_exception_1.ValidationApiException(`Invalid body: ${JSON.stringify(parsedBody.error.flatten().fieldErrors)}`);
42
- }
43
- return {
44
- parameter: parsedBody?.data || body,
45
- parameterIndex: metadata.propertyIndex
46
- };
59
+ return null;
47
60
  }
48
- return null;
49
61
  }
62
+ exports.BodyHandler = BodyHandler;
63
+ // Cache to store parsed body to avoid reading it multiple times
64
+ BodyHandler.bodyCache = new WeakMap();
50
65
  /**
51
66
  * Decorator to validate the body of the request.
52
67
  *
53
- * @param schema - The Zod schema to validate the body against.
54
68
  * @returns A decorator function that can be used to decorate a controller method.
55
69
  */
56
- function Body(schema) {
70
+ function Body() {
57
71
  return function (target, propertyKey, propertyIndex) {
58
- // Wrap the schema in a function to prevent TypeScript from analyzing it during compilation
59
- const lazySchema = schema
60
- ? () => (typeof schema === 'function' ? schema() : schema)
61
- : undefined;
62
- Reflect.defineMetadata(keys_1.BODY_KEY, { propertyIndex, schema: lazySchema }, target, propertyKey);
72
+ Reflect.defineMetadata(keys_1.BODY_KEY, {
73
+ parameterIndex: propertyIndex
74
+ }, target, propertyKey);
63
75
  };
64
76
  }
65
77
  //# sourceMappingURL=body-decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/body-decorator.ts"],"names":[],"mappings":";;AAkBA,oDAiDC;AAQD,oBAkBC;AA5FD,2CAA2C;AAC3C,0EAA0E;AAC1E,8DAAmE;AAOnE;;;;;;;GAOG;AACI,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,WAA4B,EAC5B,IAAW;IAEX,MAAM,QAAQ,GAAiB,OAAO,CAAC,cAAc,CACnD,eAAQ,EACR,MAAM,EACN,WAAW,CACZ,CAAA;IAED,6CAA6C;IAC7C,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,IAAA,2CAAsB,EAAC,IAAI,CAAC,CAAA;QAE5C,IAAI,IAAI,CAAA;QACR,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,iCAAiC;YACjC,MAAM,IAAI,sCAAsB,CAAC,iCAAiC,CAAC,CAAA;QACrE,CAAC;QAED,kDAAkD;QAClD,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACrB,OAAO;gBACL,SAAS,EAAE,IAAI;gBACf,cAAc,EAAE,QAAQ,CAAC,aAAa;aACvC,CAAA;QACH,CAAC;QAED,mCAAmC;QACnC,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAA;QAC1C,MAAM,UAAU,GAAG,cAAc,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QAElD,sDAAsD;QACtD,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACtC,MAAM,IAAI,sCAAsB,CAC9B,iBAAiB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,CAC1E,CAAA;QACH,CAAC;QAED,OAAO;YACL,SAAS,EAAE,UAAU,EAAE,IAAI,IAAI,IAAI;YACnC,cAAc,EAAE,QAAQ,CAAC,aAAa;SACvC,CAAA;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAgB,IAAI,CAAC,MAA0C;IAC7D,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,aAAqB;QAErB,2FAA2F;QAC3F,MAAM,UAAU,GAAG,MAAM;YACvB,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAC1D,CAAC,CAAC,SAAS,CAAA;QAEb,OAAO,CAAC,cAAc,CACpB,eAAQ,EACR,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,EACrC,MAAM,EACN,WAAW,CACZ,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"body-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/body-decorator.ts"],"names":[],"mappings":";;;AAmGA,oBAeC;AAlHD,2CAAsD;AACtD,0EAA0E;AAC1E,8DAAmE;AAEnE,mEAA6D;AAM7D,MAAa,WAAW;IAItB,MAAM,CAAC,WAAW,CAChB,MAAc,EACd,WAA4B;QAE5B,IAAI,QAAQ,GAAiB,OAAO,CAAC,cAAc,CACjD,eAAQ,EACR,MAAM,EACN,WAAW,CACZ,CAAA;QAED,sDAAsD;QACtD,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,WAAW,EAA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BACrD,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;oBAC7B,CAAC;yBAAM,CAAC;wBACN,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;oBAC7B,CAAC;oBAED,wBAAwB;oBACxB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;oBACjC,6DAA6D;gBAC/D,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBACpB,iCAAiC;oBACjC,MAAM,IAAI,sCAAsB,CAAC,iCAAiC,CAAC,CAAA;gBACrE,CAAC;YACH,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,SAAS,EAAE,IAAI;gBACf,cAAc,EAAE,QAAQ,CAAC,cAAc;gBACvC,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC;aAC/C,CAAA;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;;AAjFH,kCAkFC;AAjFC,gEAAgE;AACjD,qBAAS,GAAG,IAAI,OAAO,EAAoB,CAAA;AAkF5D;;;;GAIG;AACH,SAAgB,IAAI;IAClB,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,aAAqB;QAErB,OAAO,CAAC,cAAc,CACpB,eAAQ,EACR;YACE,cAAc,EAAE,aAAa;SAC9B,EACD,MAAM,EACN,WAAW,CACZ,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -1,14 +1,11 @@
1
- import { HttpMethods } from '../../constants/http-methods';
2
- export type ErrorResponse = {
3
- message: string;
4
- status: number;
5
- };
1
+ import { RouteMetadata } from './route-decorator';
6
2
  export type ControllerMetadata = {
7
- methodName: string;
8
- method: HttpMethods;
9
3
  path: string;
10
4
  };
11
- export declare function controllerHandler(target: Function): ControllerMetadata[];
5
+ export declare class ControllerHandler {
6
+ static getMetadata(target: object): ControllerMetadata | undefined;
7
+ static getRoutes(target: Function): RouteMetadata[];
8
+ }
12
9
  /**
13
10
  * A class decorator that wraps all methods in the class with error handling.
14
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"controller-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/controller-decorator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAStD,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AA6BD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,wBA+BjD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CA+BvD"}
1
+ {"version":3,"file":"controller-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/controller-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAK/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIlE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,aAAa,EAAE;CAiCpD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAIvD"}
@@ -1,89 +1,53 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.controllerHandler = controllerHandler;
3
+ exports.ControllerHandler = void 0;
4
4
  exports.Controller = Controller;
5
5
  const inversify_1 = require("inversify");
6
- const api_exception_1 = require("../../exceptions/api-exception");
7
- const http_status_1 = require("../../constants/http-status");
8
- const server_1 = require("next/server");
9
6
  const keys_1 = require("../../constants/keys");
10
7
  const route_decorator_1 = require("./route-decorator");
11
8
  const apply_decorators_1 = require("../../utils/apply-decorators");
12
9
  const get_class_methods_1 = require("../../utils/class/get-class-methods");
13
10
  const url_join_1 = require("../../utils/url/url-join");
14
- async function apiErrorHandler(error, logger) {
15
- // const intl = await getIntl()
16
- const errorMetadata = {
17
- errorType: error.constructor.name,
18
- originalMessage: error.message
19
- };
20
- if (error instanceof api_exception_1.ApiException) {
21
- logger.error(`Api error`, errorMetadata);
22
- return { message: error.message, status: error.getStatus() };
11
+ class ControllerHandler {
12
+ static getMetadata(target) {
13
+ return Reflect.getOwnMetadata(keys_1.CONTROLLER_KEY, target);
23
14
  }
24
- logger.error(`Unknown error`, errorMetadata);
25
- return {
26
- message: 'Unknown error',
27
- // message: intl.formatMessage({
28
- // id: 'error.midaz.unknowError',
29
- // defaultMessage: 'Unknown error on Midaz.'
30
- // }),
31
- status: http_status_1.HttpStatus.INTERNAL_SERVER_ERROR
32
- };
33
- }
34
- function controllerHandler(target) {
35
- const routes = [];
36
- const prototype = target.prototype;
37
- const metadata = Reflect.getOwnMetadata(keys_1.CONTROLLER_KEY, target);
38
- if (!metadata) {
39
- console.warn(`Class ${target.name} does not have a Controller decorator`);
40
- return [];
41
- }
42
- const methodNames = (0, get_class_methods_1.getClassMethods)(target);
43
- // Compile all routes from the controller
44
- for (const methodName of methodNames) {
45
- const routeMetadata = (0, route_decorator_1.routeHandler)(prototype, methodName);
46
- if (routeMetadata) {
47
- // Join the controller path with the route path
48
- const url = (0, url_join_1.urlJoin)(metadata.path, routeMetadata.path);
49
- // Add the route to the routes array
50
- routes.push({
51
- methodName: methodName,
52
- method: routeMetadata.method,
53
- path: url
54
- });
15
+ static getRoutes(target) {
16
+ const routes = [];
17
+ const prototype = target.prototype;
18
+ const metadata = Reflect.getOwnMetadata(keys_1.CONTROLLER_KEY, target);
19
+ if (!metadata) {
20
+ console.warn(`Class ${target.name} does not have a Controller decorator`);
21
+ return [];
22
+ }
23
+ const methodNames = (0, get_class_methods_1.getClassMethods)(target);
24
+ // Compile all routes from the controller
25
+ for (const methodName of methodNames) {
26
+ const routeMetadata = route_decorator_1.RouteHandler.getMetadata(prototype, methodName);
27
+ if (routeMetadata) {
28
+ // Join the controller path with the route path
29
+ const url = (0, url_join_1.urlJoin)(metadata.path, routeMetadata.path);
30
+ // Add the route to the routes array
31
+ routes.push({
32
+ methodName: methodName,
33
+ method: routeMetadata.method,
34
+ path: url,
35
+ paramTypes: routeMetadata.paramTypes
36
+ });
37
+ }
55
38
  }
39
+ return routes;
56
40
  }
57
- return routes;
58
41
  }
42
+ exports.ControllerHandler = ControllerHandler;
59
43
  /**
60
44
  * A class decorator that wraps all methods in the class with error handling.
61
45
  *
62
46
  * @returns
63
47
  */
64
48
  function Controller(path) {
65
- return (0, apply_decorators_1.applyDecorators)((0, inversify_1.injectable)(), (0, inversify_1.injectFromBase)({
66
- extendProperties: true
67
- }), function (target) {
49
+ return (0, apply_decorators_1.applyDecorators)((0, inversify_1.injectable)(), function (target) {
68
50
  Reflect.defineMetadata(keys_1.CONTROLLER_KEY, { path }, target);
69
- // Get all method names from the prototype
70
- const prototype = target.prototype;
71
- const methodNames = (0, get_class_methods_1.getClassMethods)(target);
72
- // Replace each method with a wrapped version
73
- for (const methodName of methodNames) {
74
- const originalMethod = prototype[methodName];
75
- // Replace with wrapped method
76
- prototype[methodName] = async function (...args) {
77
- try {
78
- return await originalMethod.apply(this, args);
79
- }
80
- catch (error) {
81
- const logger = this.logger;
82
- const { message, status } = await apiErrorHandler(error, logger);
83
- return server_1.NextResponse.json({ message }, { status });
84
- }
85
- };
86
- }
87
51
  });
88
52
  }
89
53
  //# sourceMappingURL=controller-decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"controller-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/controller-decorator.ts"],"names":[],"mappings":";;AAkDA,8CA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,EAAE,MAAM,EAAE,GAAG,MAAM,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;oBAChE,OAAO,qBAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;gBACnD,CAAC;YACH,CAAC,CAAA;QACH,CAAC;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"controller-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/controller-decorator.ts"],"names":[],"mappings":";;;AAwDA,gCAIC;AA5DD,yCAAsC;AACtC,2CAAiD;AACjD,uDAA+D;AAC/D,+DAA0D;AAC1D,uEAAiE;AACjE,mDAA8C;AAM9C,MAAa,iBAAiB;IAC5B,MAAM,CAAC,WAAW,CAAC,MAAc;QAC/B,OAAO,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,MAAM,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAgB;QAC/B,MAAM,MAAM,GAAoB,EAAE,CAAA;QAClC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QAElC,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,MAAM,CAAC,CAAA;QAE/D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,IAAI,uCAAuC,CAAC,CAAA;YACzE,OAAO,EAAE,CAAA;QACX,CAAC;QAED,MAAM,WAAW,GAAG,IAAA,mCAAe,EAAC,MAAM,CAAC,CAAA;QAE3C,yCAAyC;QACzC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,MAAM,aAAa,GAAG,8BAAY,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;YAErE,IAAI,aAAa,EAAE,CAAC;gBAClB,+CAA+C;gBAC/C,MAAM,GAAG,GAAG,IAAA,kBAAO,EAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;gBAEtD,oCAAoC;gBACpC,MAAM,CAAC,IAAI,CAAC;oBACV,UAAU,EAAE,UAAU;oBACtB,MAAM,EAAE,aAAa,CAAC,MAAM;oBAC5B,IAAI,EAAE,GAAG;oBACT,UAAU,EAAE,aAAa,CAAC,UAAU;iBACrC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAtCD,8CAsCC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAA,kCAAe,EAAC,IAAA,sBAAU,GAAE,EAAE,UAAU,MAAgB;QAC7D,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,CAAA;IAC1D,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -2,15 +2,10 @@ export type ParamMetadata = {
2
2
  name: string;
3
3
  parameterIndex: number;
4
4
  };
5
- /**
6
- * Handler to validate the param of the request.
7
- *
8
- * @param target - The target object.
9
- * @param propertyKey - The property key.
10
- * @param args - The arguments.
11
- * @returns The parameter and parameter index.
12
- */
13
- export declare function paramDecoratorHandler(target: object, propertyKey: string | symbol, args: any[]): Promise<any>;
5
+ export declare class ParamHandler {
6
+ static getMetadata(target: object, propertyKey: string | symbol): ParamMetadata[] | undefined;
7
+ static handle(target: object, propertyKey: string | symbol, args: any[]): Promise<any>;
8
+ }
14
9
  /**
15
10
  * Decorator to validate the param of the request.
16
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"param-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/param-decorator.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE,GACV,OAAO,CAAC,GAAG,CAAC,CAqCd;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,IAE9B,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,gBAAgB,MAAM,UAYzB"}
1
+ {"version":3,"file":"param-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/param-decorator.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,qBAAa,YAAY;IACvB,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,aAAa,EAAE,GAAG,SAAS;WAmBjB,MAAM,CACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE,GACV,OAAO,CAAC,GAAG,CAAC;CAmChB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,IAE9B,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,gBAAgB,MAAM,UAYzB"}
@@ -1,42 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.paramDecoratorHandler = paramDecoratorHandler;
3
+ exports.ParamHandler = void 0;
4
4
  exports.Param = Param;
5
5
  const keys_1 = require("../../constants/keys");
6
6
  const api_exception_1 = require("../../exceptions/api-exception");
7
7
  const get_next_arguments_1 = require("../../utils/nextjs/get-next-arguments");
8
- /**
9
- * Handler to validate the param of the request.
10
- *
11
- * @param target - The target object.
12
- * @param propertyKey - The property key.
13
- * @param args - The arguments.
14
- * @returns The parameter and parameter index.
15
- */
16
- async function paramDecoratorHandler(target, propertyKey, args) {
17
- const metadatas = Reflect.getOwnMetadata(keys_1.PARAM_KEY, target, propertyKey);
18
- // If the metadata is found, validate the param.
19
- if (metadatas && metadatas.length > 0) {
20
- const params = await (0, get_next_arguments_1.getNextParamArgument)(args);
21
- // If params is undefined or null, all required params are missing
22
- if (!params) {
23
- throw new api_exception_1.ValidationApiException(`Invalid param: ${metadatas[0].name} is required`);
8
+ class ParamHandler {
9
+ static getMetadata(target, propertyKey) {
10
+ let metadatas = Reflect.getOwnMetadata(keys_1.PARAM_KEY, target, propertyKey);
11
+ // If not found on instance, try constructor prototype
12
+ if (!metadatas && target.constructor) {
13
+ metadatas = Reflect.getOwnMetadata(keys_1.PARAM_KEY, target.constructor.prototype, propertyKey);
24
14
  }
25
- // Validate the param.
26
- return metadatas.map((metadata) => {
27
- const value = params[metadata.name];
28
- // If the param is not found, throw a validation error.
29
- if (!value) {
30
- throw new api_exception_1.ValidationApiException(`Invalid param: ${metadata.name} is required`);
15
+ return metadatas;
16
+ }
17
+ static async handle(target, propertyKey, args) {
18
+ const metadatas = this.getMetadata(target, propertyKey);
19
+ // If the metadata is found, validate the param.
20
+ if (metadatas && metadatas.length > 0) {
21
+ const params = await (0, get_next_arguments_1.getNextParamArgument)(args);
22
+ // If params is undefined or null, all required params are missing
23
+ if (!params) {
24
+ throw new api_exception_1.ValidationApiException(`Invalid param: ${metadatas[0].name} is required`);
31
25
  }
32
- return {
33
- parameter: value,
34
- parameterIndex: metadata.parameterIndex
35
- };
36
- });
26
+ // Validate the param.
27
+ return metadatas.map((metadata) => {
28
+ const value = params[metadata.name];
29
+ // If the param is not found, throw a validation error.
30
+ if (!value) {
31
+ throw new api_exception_1.ValidationApiException(`Invalid param: ${metadata.name} is required`);
32
+ }
33
+ return {
34
+ type: 'param',
35
+ parameter: value,
36
+ parameterIndex: metadata.parameterIndex
37
+ };
38
+ });
39
+ }
40
+ return null;
37
41
  }
38
- return null;
39
42
  }
43
+ exports.ParamHandler = ParamHandler;
40
44
  /**
41
45
  * Decorator to validate the param of the request.
42
46
  *
@@ -1 +1 @@
1
- {"version":3,"file":"param-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/param-decorator.ts"],"names":[],"mappings":";;AAiBA,sDAyCC;AAQD,sBAgBC;AAlFD,2CAA4C;AAC5C,8DAAmE;AACnE,0EAAwE;AAOxE;;;;;;;GAOG;AACI,KAAK,UAAU,qBAAqB,CACzC,MAAc,EACd,WAA4B,EAC5B,IAAW;IAEX,MAAM,SAAS,GAAgC,OAAO,CAAC,cAAc,CACnE,gBAAS,EACT,MAAM,EACN,WAAW,CACZ,CAAA;IAED,gDAAgD;IAChD,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,MAAM,GAA2B,MAAM,IAAA,yCAAoB,EAAC,IAAI,CAAC,CAAA;QAEvE,kEAAkE;QAClE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,sCAAsB,CAC9B,kBAAkB,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAClD,CAAA;QACH,CAAC;QAED,sBAAsB;QACtB,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAEnC,uDAAuD;YACvD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,sCAAsB,CAC9B,kBAAkB,QAAQ,CAAC,IAAI,cAAc,CAC9C,CAAA;YACH,CAAC;YAED,OAAO;gBACL,SAAS,EAAE,KAAK;gBAChB,cAAc,EAAE,QAAQ,CAAC,cAAc;aACxC,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,IAAY;IAChC,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,cAAsB;QAEtB,MAAM,cAAc,GAClB,OAAO,CAAC,cAAc,CAAC,gBAAS,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAA;QAE9D,cAAc,CAAC,IAAI,CAAC;YAClB,IAAI;YACJ,cAAc;SACf,CAAC,CAAA;QAEF,OAAO,CAAC,cAAc,CAAC,gBAAS,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IACxE,CAAC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"param-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/param-decorator.ts"],"names":[],"mappings":";;;AA+EA,sBAgBC;AA/FD,2CAA4C;AAC5C,8DAAmE;AACnE,0EAAwE;AAOxE,MAAa,YAAY;IACvB,MAAM,CAAC,WAAW,CAChB,MAAc,EACd,WAA4B;QAE5B,IAAI,SAAS,GAAgC,OAAO,CAAC,cAAc,CACjE,gBAAS,EACT,MAAM,EACN,WAAW,CACZ,CAAA;QAED,sDAAsD;QACtD,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACrC,SAAS,GAAG,OAAO,CAAC,cAAc,CAChC,gBAAS,EACT,MAAM,CAAC,WAAW,CAAC,SAAS,EAC5B,WAAW,CACZ,CAAA;QACH,CAAC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,MAAc,EACd,WAA4B,EAC5B,IAAW;QAEX,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAEvD,gDAAgD;QAChD,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,MAAM,GAA2B,MAAM,IAAA,yCAAoB,EAAC,IAAI,CAAC,CAAA;YAEvE,kEAAkE;YAClE,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,sCAAsB,CAC9B,kBAAkB,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAClD,CAAA;YACH,CAAC;YAED,sBAAsB;YACtB,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAChC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;gBAEnC,uDAAuD;gBACvD,IAAI,CAAC,KAAK,EAAE,CAAC;oBACX,MAAM,IAAI,sCAAsB,CAC9B,kBAAkB,QAAQ,CAAC,IAAI,cAAc,CAC9C,CAAA;gBACH,CAAC;gBAED,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,SAAS,EAAE,KAAK;oBAChB,cAAc,EAAE,QAAQ,CAAC,cAAc;iBACxC,CAAA;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA9DD,oCA8DC;AAED;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,IAAY;IAChC,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,cAAsB;QAEtB,MAAM,cAAc,GAClB,OAAO,CAAC,cAAc,CAAC,gBAAS,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAA;QAE9D,cAAc,CAAC,IAAI,CAAC;YAClB,IAAI;YACJ,cAAc;SACf,CAAC,CAAA;QAEF,OAAO,CAAC,cAAc,CAAC,gBAAS,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IACxE,CAAC,CAAA;AACH,CAAC"}
@@ -1,26 +1,22 @@
1
- import z from 'zod';
2
1
  export type QueryMetadata = {
3
2
  propertyKey: string | symbol;
4
3
  parameterIndex: number;
5
- schema?: () => z.ZodSchema;
6
4
  };
7
- /**
8
- * Handler to validate the query of the request.
9
- *
10
- * @param target - The target object.
11
- * @param propertyKey - The property key.
12
- * @param args - The arguments.
13
- * @returns The parameter and parameter index.
14
- */
15
- export declare function queryDecoratorHandler(target: object, propertyKey: string | symbol, args: any[]): {
16
- parameter: {};
17
- parameterIndex: number;
18
- } | null;
5
+ export declare class QueryHandler {
6
+ static getMetadata(target: object, propertyKey: string | symbol): QueryMetadata | undefined;
7
+ static handle(target: object, propertyKey: string | symbol, args: any[]): {
8
+ type: string;
9
+ parameter: {
10
+ [k: string]: string;
11
+ };
12
+ parameterIndex: number;
13
+ } | null;
14
+ }
19
15
  /**
20
16
  * Decorator to validate the query of the request.
21
17
  *
22
18
  * @param schema - The Zod schema to validate the query against.
23
19
  * @returns A decorator function that can be used to decorate a controller method.
24
20
  */
25
- export declare function Query(schema?: z.ZodSchema | (() => z.ZodSchema)): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
21
+ export declare function Query(): (target: object, propertyKey: string | symbol, propertyIndex: number) => void;
26
22
  //# sourceMappingURL=query-decorator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/query-decorator.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAKnB,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE;;;SA0CZ;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,IAE5D,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,gBAAgB,MAAM,UAkBzB"}
1
+ {"version":3,"file":"query-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/query-decorator.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,qBAAa,YAAY;IACvB,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,aAAa,GAAG,SAAS;IAmB5B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE;;;;;;;CAmBxE;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,KAEjB,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,eAAe,MAAM,UAaxB"}
@@ -1,61 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queryDecoratorHandler = queryDecoratorHandler;
3
+ exports.QueryHandler = void 0;
4
4
  exports.Query = Query;
5
5
  const keys_1 = require("../../constants/keys");
6
- const api_exception_1 = require("../../exceptions/api-exception");
7
6
  const get_next_arguments_1 = require("../../utils/nextjs/get-next-arguments");
8
- /**
9
- * Handler to validate the query of the request.
10
- *
11
- * @param target - The target object.
12
- * @param propertyKey - The property key.
13
- * @param args - The arguments.
14
- * @returns The parameter and parameter index.
15
- */
16
- function queryDecoratorHandler(target, propertyKey, args) {
17
- const metadata = Reflect.getOwnMetadata(keys_1.QUERY_KEY, target, propertyKey);
18
- // If the metadata is found, validate the query.
19
- if (metadata) {
20
- const request = (0, get_next_arguments_1.getNextRequestArgument)(args);
21
- const { searchParams } = new URL(request.url);
22
- const query = Object.fromEntries(searchParams.entries());
23
- // If the schema is not provided, return the query.
24
- if (!metadata.schema) {
7
+ class QueryHandler {
8
+ static getMetadata(target, propertyKey) {
9
+ let metadata = Reflect.getOwnMetadata(keys_1.QUERY_KEY, target, propertyKey);
10
+ // If not found on instance, try constructor prototype
11
+ if (!metadata && target.constructor) {
12
+ metadata = Reflect.getOwnMetadata(keys_1.QUERY_KEY, target.constructor.prototype, propertyKey);
13
+ }
14
+ return metadata;
15
+ }
16
+ static handle(target, propertyKey, args) {
17
+ const metadata = this.getMetadata(target, propertyKey);
18
+ // If the metadata is found, validate the query.
19
+ if (metadata) {
20
+ const request = (0, get_next_arguments_1.getNextRequestArgument)(args);
21
+ const { searchParams } = new URL(request.url);
22
+ const query = Object.fromEntries(searchParams.entries());
25
23
  return {
24
+ type: 'query',
26
25
  parameter: query,
27
26
  parameterIndex: metadata.parameterIndex
28
27
  };
29
28
  }
30
- const resolvedSchema = metadata.schema?.();
31
- const parsedQuery = resolvedSchema?.safeParse(query);
32
- // If the query is not valid, throw a validation error.
33
- if (parsedQuery && !parsedQuery.success) {
34
- throw new api_exception_1.ValidationApiException(`Invalid query parameters: ${JSON.stringify(parsedQuery.error.flatten().fieldErrors)}`);
35
- }
36
- return {
37
- parameter: parsedQuery?.data || query,
38
- parameterIndex: metadata.parameterIndex
39
- };
29
+ return null;
40
30
  }
41
- return null;
42
31
  }
32
+ exports.QueryHandler = QueryHandler;
43
33
  /**
44
34
  * Decorator to validate the query of the request.
45
35
  *
46
36
  * @param schema - The Zod schema to validate the query against.
47
37
  * @returns A decorator function that can be used to decorate a controller method.
48
38
  */
49
- function Query(schema) {
50
- return function (target, propertyKey, parameterIndex) {
51
- // Wrap the schema in a function to prevent TypeScript from analyzing it during compilation
52
- const lazySchema = schema
53
- ? () => (typeof schema === 'function' ? schema() : schema)
54
- : undefined;
39
+ function Query() {
40
+ return function (target, propertyKey, propertyIndex) {
41
+ // Get the parameter type from design:paramtypes
55
42
  Reflect.defineMetadata(keys_1.QUERY_KEY, {
56
43
  propertyKey,
57
- parameterIndex,
58
- schema: lazySchema
44
+ parameterIndex: propertyIndex
59
45
  }, target, propertyKey);
60
46
  };
61
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"query-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/query-decorator.ts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,KAAK,CAAC,MAA0C;IAC9D,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,cAAsB;QAEtB,2FAA2F;QAC3F,MAAM,UAAU,GAAG,MAAM;YACvB,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAC1D,CAAC,CAAC,SAAS,CAAA;QAEb,OAAO,CAAC,cAAc,CACpB,gBAAS,EACT;YACE,WAAW;YACX,cAAc;YACd,MAAM,EAAE,UAAU;SACnB,EACD,MAAM,EACN,WAAW,CACZ,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"query-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/query-decorator.ts"],"names":[],"mappings":";;;AA0DA,sBAiBC;AA3ED,2CAA4C;AAC5C,0EAA0E;AAO1E,MAAa,YAAY;IACvB,MAAM,CAAC,WAAW,CAChB,MAAc,EACd,WAA4B;QAE5B,IAAI,QAAQ,GAAkB,OAAO,CAAC,cAAc,CAClD,gBAAS,EACT,MAAM,EACN,WAAW,CACZ,CAAA;QAED,sDAAsD;QACtD,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACpC,QAAQ,GAAG,OAAO,CAAC,cAAc,CAC/B,gBAAS,EACT,MAAM,CAAC,WAAW,CAAC,SAAS,EAC5B,WAAW,CACZ,CAAA;QACH,CAAC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,MAAc,EAAE,WAA4B,EAAE,IAAW;QACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAEtD,gDAAgD;QAChD,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,IAAA,2CAAsB,EAAC,IAAI,CAAC,CAAA;YAC5C,MAAM,EAAE,YAAY,E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