@lerianstudio/sindarian-server 1.0.0-beta.8 → 1.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 (91) hide show
  1. package/dist/constants/keys.d.ts +1 -0
  2. package/dist/constants/keys.d.ts.map +1 -1
  3. package/dist/constants/keys.js +2 -1
  4. package/dist/constants/keys.js.map +1 -1
  5. package/dist/controllers/decorators/body-decorator.d.ts +12 -16
  6. package/dist/controllers/decorators/body-decorator.d.ts.map +1 -1
  7. package/dist/controllers/decorators/body-decorator.js +52 -58
  8. package/dist/controllers/decorators/body-decorator.js.map +1 -1
  9. package/dist/controllers/decorators/controller-decorator.d.ts +5 -4
  10. package/dist/controllers/decorators/controller-decorator.d.ts.map +1 -1
  11. package/dist/controllers/decorators/controller-decorator.js +29 -22
  12. package/dist/controllers/decorators/controller-decorator.js.map +1 -1
  13. package/dist/controllers/decorators/param-decorator.d.ts +4 -9
  14. package/dist/controllers/decorators/param-decorator.d.ts.map +1 -1
  15. package/dist/controllers/decorators/param-decorator.js +33 -29
  16. package/dist/controllers/decorators/param-decorator.js.map +1 -1
  17. package/dist/controllers/decorators/query-decorator.d.ts +11 -15
  18. package/dist/controllers/decorators/query-decorator.d.ts.map +1 -1
  19. package/dist/controllers/decorators/query-decorator.js +24 -38
  20. package/dist/controllers/decorators/query-decorator.js.map +1 -1
  21. package/dist/controllers/decorators/request-decorator.d.ts +8 -12
  22. package/dist/controllers/decorators/request-decorator.d.ts.map +1 -1
  23. package/dist/controllers/decorators/request-decorator.js +21 -17
  24. package/dist/controllers/decorators/request-decorator.js.map +1 -1
  25. package/dist/controllers/decorators/route-decorator.d.ts +12 -1
  26. package/dist/controllers/decorators/route-decorator.d.ts.map +1 -1
  27. package/dist/controllers/decorators/route-decorator.js +24 -16
  28. package/dist/controllers/decorators/route-decorator.js.map +1 -1
  29. package/dist/exceptions/api-exception.d.ts +4 -7
  30. package/dist/exceptions/api-exception.d.ts.map +1 -1
  31. package/dist/exceptions/api-exception.js +8 -4
  32. package/dist/exceptions/api-exception.js.map +1 -1
  33. package/dist/exceptions/base-exception-filter.d.ts.map +1 -1
  34. package/dist/exceptions/base-exception-filter.js +10 -3
  35. package/dist/exceptions/base-exception-filter.js.map +1 -1
  36. package/dist/exceptions/decorators/use-filters-decorator.d.ts +12 -1
  37. package/dist/exceptions/decorators/use-filters-decorator.d.ts.map +1 -1
  38. package/dist/exceptions/decorators/use-filters-decorator.js +34 -3
  39. package/dist/exceptions/decorators/use-filters-decorator.js.map +1 -1
  40. package/dist/index.d.ts +3 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +5 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/interceptor/decorators/use-interceptor-decorator.d.ts +10 -3
  45. package/dist/interceptor/decorators/use-interceptor-decorator.d.ts.map +1 -1
  46. package/dist/interceptor/decorators/use-interceptor-decorator.js +60 -22
  47. package/dist/interceptor/decorators/use-interceptor-decorator.js.map +1 -1
  48. package/dist/modules/module-decorator.d.ts +2 -2
  49. package/dist/modules/module-decorator.d.ts.map +1 -1
  50. package/dist/modules/module-decorator.js +7 -13
  51. package/dist/modules/module-decorator.js.map +1 -1
  52. package/dist/pipes/decorators/index.d.ts +2 -0
  53. package/dist/pipes/decorators/index.d.ts.map +1 -0
  54. package/dist/pipes/decorators/index.js +6 -0
  55. package/dist/pipes/decorators/index.js.map +1 -0
  56. package/dist/pipes/decorators/use-pipes.d.ts +19 -0
  57. package/dist/pipes/decorators/use-pipes.d.ts.map +1 -0
  58. package/dist/pipes/decorators/use-pipes.js +118 -0
  59. package/dist/pipes/decorators/use-pipes.js.map +1 -0
  60. package/dist/pipes/index.d.ts +3 -0
  61. package/dist/pipes/index.d.ts.map +1 -0
  62. package/dist/pipes/index.js +18 -0
  63. package/dist/pipes/index.js.map +1 -0
  64. package/dist/pipes/pipe-transform.d.ts +46 -0
  65. package/dist/pipes/pipe-transform.d.ts.map +1 -0
  66. package/dist/pipes/pipe-transform.js +3 -0
  67. package/dist/pipes/pipe-transform.js.map +1 -0
  68. package/dist/server/server-factory.d.ts +10 -0
  69. package/dist/server/server-factory.d.ts.map +1 -1
  70. package/dist/server/server-factory.js +43 -23
  71. package/dist/server/server-factory.js.map +1 -1
  72. package/dist/services/http-service.d.ts +2 -2
  73. package/dist/services/http-service.d.ts.map +1 -1
  74. package/dist/services/http-service.js.map +1 -1
  75. package/dist/services/pipes.d.ts +2 -0
  76. package/dist/services/pipes.d.ts.map +1 -0
  77. package/dist/services/pipes.js +5 -0
  78. package/dist/services/pipes.js.map +1 -0
  79. package/dist/zod/create-zod-dto.d.ts +16 -0
  80. package/dist/zod/create-zod-dto.d.ts.map +1 -0
  81. package/dist/zod/create-zod-dto.js +14 -0
  82. package/dist/zod/create-zod-dto.js.map +1 -0
  83. package/dist/zod/index.d.ts +3 -0
  84. package/dist/zod/index.d.ts.map +1 -0
  85. package/dist/zod/index.js +8 -0
  86. package/dist/zod/index.js.map +1 -0
  87. package/dist/zod/zod-validation-pipe.d.ts +5 -0
  88. package/dist/zod/zod-validation-pipe.d.ts.map +1 -0
  89. package/dist/zod/zod-validation-pipe.js +35 -0
  90. package/dist/zod/zod-validation-pipe.js.map +1 -0
  91. package/package.json +6 -2
@@ -2,18 +2,14 @@ export type RequestMetadata = {
2
2
  propertyKey: string | symbol;
3
3
  parameterIndex: number;
4
4
  };
5
- /**
6
- * Handler to fetch the request object.
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 requestDecoratorHandler(target: object, propertyKey: string | symbol, args: any[]): {
14
- parameter: any;
15
- parameterIndex: number;
16
- } | null;
5
+ export declare class RequestHandler {
6
+ static getMetadata(target: object, propertyKey: string | symbol): RequestMetadata | undefined;
7
+ static handle(target: object, propertyKey: string | symbol, args: any[]): {
8
+ type: string;
9
+ parameter: any;
10
+ parameterIndex: number;
11
+ } | null;
12
+ }
17
13
  /**
18
14
  * Decorator to fetch the request object.
19
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"request-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/request-decorator.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE;;;SAcZ;AAED;;;;GAIG;AACH,wBAAgB,OAAO,KAEnB,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,gBAAgB,MAAM,UAYzB;AAED,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,CAAA"}
1
+ {"version":3,"file":"request-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/request-decorator.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,qBAAa,cAAc;IACzB,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,eAAe,GAAG,SAAS;IAmB9B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE;;;;;CAYxE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,KAEnB,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,gBAAgB,MAAM,UAYzB;AAED,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,CAAA"}
@@ -1,28 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requestDecoratorHandler = requestDecoratorHandler;
3
+ exports.RequestHandler = void 0;
4
4
  exports.Request = Request;
5
5
  exports.Req = Request;
6
6
  const keys_1 = require("../../constants/keys");
7
7
  const get_next_arguments_1 = require("../../utils/nextjs/get-next-arguments");
8
- /**
9
- * Handler to fetch the request object.
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 requestDecoratorHandler(target, propertyKey, args) {
17
- const metadata = Reflect.getOwnMetadata(keys_1.REQUEST_KEY, target, propertyKey);
18
- if (metadata) {
19
- return {
20
- parameter: (0, get_next_arguments_1.getNextRequestArgument)(args),
21
- parameterIndex: metadata.parameterIndex
22
- };
8
+ class RequestHandler {
9
+ static getMetadata(target, propertyKey) {
10
+ let metadata = Reflect.getOwnMetadata(keys_1.REQUEST_KEY, target, propertyKey);
11
+ // If not found on instance, try constructor prototype
12
+ if (!metadata && target.constructor) {
13
+ metadata = Reflect.getOwnMetadata(keys_1.REQUEST_KEY, target.constructor.prototype, propertyKey);
14
+ }
15
+ return metadata;
16
+ }
17
+ static handle(target, propertyKey, args) {
18
+ const metadata = this.getMetadata(target, propertyKey);
19
+ if (metadata) {
20
+ return {
21
+ type: 'custom',
22
+ parameter: (0, get_next_arguments_1.getNextRequestArgument)(args),
23
+ parameterIndex: metadata.parameterIndex
24
+ };
25
+ }
26
+ return null;
23
27
  }
24
- return null;
25
28
  }
29
+ exports.RequestHandler = RequestHandler;
26
30
  /**
27
31
  * Decorator to fetch the request object.
28
32
  *
@@ -1 +1 @@
1
- {"version":3,"file":"request-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/request-decorator.ts"],"names":[],"mappings":";;AAgBA,0DAiBC;AAOD,0BAgBC;AAEmB,sBAAG;AA1DvB,2CAA8C;AAC9C,0EAA0E;AAO1E;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CACrC,MAAc,EACd,WAA4B,EAC5B,IAAW;IAEX,MAAM,QAAQ,GAAoB,OAAO,CAAC,cAAc,CACtD,kBAAW,EACX,MAAM,EACN,WAAW,CACZ,CAAA;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,SAAS,EAAE,IAAA,2CAAsB,EAAC,IAAI,CAAC;YACvC,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;GAIG;AACH,SAAgB,OAAO;IACrB,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,cAAsB;QAEtB,OAAO,CAAC,cAAc,CACpB,kBAAW,EACX;YACE,WAAW;YACX,cAAc;SACf,EACD,MAAM,EACN,WAAW,CACZ,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"request-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/request-decorator.ts"],"names":[],"mappings":";;;AAkDA,0BAgBC;AAEmB,sBAAG;AApEvB,2CAA8C;AAC9C,0EAA0E;AAO1E,MAAa,cAAc;IACzB,MAAM,CAAC,WAAW,CAChB,MAAc,EACd,WAA4B;QAE5B,IAAI,QAAQ,GAAoB,OAAO,CAAC,cAAc,CACpD,kBAAW,EACX,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,kBAAW,EACX,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,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,SAAS,EAAE,IAAA,2CAAsB,EAAC,IAAI,CAAC;gBACvC,cAAc,EAAE,QAAQ,CAAC,cAAc;aACxC,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAnCD,wCAmCC;AAED;;;;GAIG;AACH,SAAgB,OAAO;IACrB,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,cAAsB;QAEtB,OAAO,CAAC,cAAc,CACpB,kBAAW,EACX;YACE,WAAW;YACX,cAAc;SACf,EACD,MAAM,EACN,WAAW,CACZ,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -1,9 +1,20 @@
1
1
  import { HttpMethods } from '../../constants/http-methods';
2
2
  export type RouteMetadata = {
3
+ methodName: string;
3
4
  method: HttpMethods;
4
5
  path: string;
6
+ paramTypes: any[];
5
7
  };
6
- export declare function routeHandler(target: object, propertyKey: string | symbol): RouteMetadata | undefined;
8
+ export type RouteContext = {
9
+ type?: 'body' | 'param' | 'query' | 'custom';
10
+ parameter: any;
11
+ parameterIndex: number;
12
+ paramType?: any;
13
+ };
14
+ export declare class RouteHandler {
15
+ static getMetadata(target: object, propertyKey: string | symbol): RouteMetadata;
16
+ static getArgs(target: object, propertyKey: string | symbol, originalArgs: any[]): Promise<RouteContext[]>;
17
+ }
7
18
  export declare function Route(method: HttpMethods, path: string): MethodDecorator;
8
19
  /**
9
20
  * Decorator to define a GET route.
@@ -1 +1 @@
1
- {"version":3,"file":"route-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/route-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAMtD,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,aAAa,GAAG,SAAS,CAE3B;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAuCxE;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,mBAEpC;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,MAAW,mBAErC;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,mBAEpC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,GAAE,MAAW,mBAEtC;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,GAAE,MAAW,mBAEvC"}
1
+ {"version":3,"file":"route-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/route-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAMtD,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,GAAG,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC5C,SAAS,EAAE,GAAG,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,GAAG,CAAA;CAChB,CAAA;AAED,qBAAa,YAAY;IACvB,MAAM,CAAC,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,aAAa;WAIH,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,YAAY,EAAE,GAAG,EAAE,GAClB,OAAO,CAAC,YAAY,EAAE,CAAC;CAa3B;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAgCxE;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,mBAEpC;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,MAAW,mBAErC;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,GAAE,MAAW,mBAEpC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,GAAE,MAAW,mBAEtC;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,GAAE,MAAW,mBAEvC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.routeHandler = routeHandler;
3
+ exports.RouteHandler = void 0;
4
4
  exports.Route = Route;
5
5
  exports.Get = Get;
6
6
  exports.Post = Post;
@@ -10,31 +10,39 @@ exports.Delete = Delete;
10
10
  const server_1 = require("next/server");
11
11
  const keys_1 = require("../../constants/keys");
12
12
  const http_methods_1 = require("../../constants/http-methods");
13
+ const request_decorator_1 = require("./request-decorator");
13
14
  const body_decorator_1 = require("./body-decorator");
14
15
  const param_decorator_1 = require("./param-decorator");
15
16
  const query_decorator_1 = require("./query-decorator");
16
- const request_decorator_1 = require("./request-decorator");
17
- function routeHandler(target, propertyKey) {
18
- return Reflect.getOwnMetadata(keys_1.ROUTE_KEY, target, propertyKey);
17
+ class RouteHandler {
18
+ static getMetadata(target, propertyKey) {
19
+ return Reflect.getOwnMetadata(keys_1.ROUTE_KEY, target, propertyKey);
20
+ }
21
+ static async getArgs(target, propertyKey, originalArgs) {
22
+ const args = [
23
+ await request_decorator_1.RequestHandler.handle(target, propertyKey, originalArgs),
24
+ await query_decorator_1.QueryHandler.handle(target, propertyKey, originalArgs),
25
+ await param_decorator_1.ParamHandler.handle(target, propertyKey, originalArgs),
26
+ await body_decorator_1.BodyHandler.handle(target, propertyKey, originalArgs)
27
+ ]
28
+ .flat()
29
+ .filter((a) => a !== null && a !== undefined)
30
+ .sort((a, b) => a.parameterIndex - b.parameterIndex);
31
+ return args;
32
+ }
19
33
  }
34
+ exports.RouteHandler = RouteHandler;
20
35
  function Route(method, path) {
21
36
  return function (target, propertyKey, descriptor) {
37
+ const paramTypes = Reflect.getMetadata('design:paramtypes', target, propertyKey) || [];
22
38
  Reflect.defineMetadata(keys_1.ROUTE_KEY, {
39
+ methodName: propertyKey,
23
40
  method: method,
24
- path
41
+ path,
42
+ paramTypes
25
43
  }, target, propertyKey);
26
44
  const originalMethod = descriptor.value;
27
- descriptor.value = async function (...originalArgs) {
28
- const args = [
29
- await (0, request_decorator_1.requestDecoratorHandler)(target, propertyKey, originalArgs),
30
- await (0, query_decorator_1.queryDecoratorHandler)(target, propertyKey, originalArgs),
31
- await (0, param_decorator_1.paramDecoratorHandler)(target, propertyKey, originalArgs),
32
- await (0, body_decorator_1.bodyDecoratorHandler)(target, propertyKey, originalArgs)
33
- ]
34
- .flat()
35
- .filter((a) => a !== null && a !== undefined)
36
- .sort((a, b) => a.parameterIndex - b.parameterIndex)
37
- .map((a) => a.parameter);
45
+ descriptor.value = async function (...args) {
38
46
  const response = await originalMethod.apply(this, args);
39
47
  if (response instanceof server_1.NextResponse) {
40
48
  return response;
@@ -1 +1 @@
1
- {"version":3,"file":"route-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/route-decorator.ts"],"names":[],"mappings":";;AAaA,oCAKC;AAED,sBAuCC;AAQD,kBAEC;AAQD,oBAEC;AAQD,kBAEC;AAQD,sBAEC;AAQD,wBAEC;AA7GD,wCAA0C;AAC1C,2CAA4C;AAC5C,2DAAsD;AACtD,qDAAuD;AACvD,uDAAyD;AACzD,uDAAyD;AACzD,2DAA6D;AAO7D,SAAgB,YAAY,CAC1B,MAAc,EACd,WAA4B;IAE5B,OAAO,OAAO,CAAC,cAAc,CAAC,gBAAS,EAAE,MAAM,EAAE,WAAW,C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;GAKG;AACH,SAAgB,GAAG,CAAC,OAAe,EAAE;IACnC,OAAO,KAAK,CAAC,0BAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,IAAI,CAAC,OAAe,EAAE;IACpC,OAAO,KAAK,CAAC,0BAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACtC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,GAAG,CAAC,OAAe,EAAE;IACnC,OAAO,KAAK,CAAC,0BAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,OAAe,EAAE;IACrC,OAAO,KAAK,CAAC,0BAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACvC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,OAAe,EAAE;IACtC,OAAO,KAAK,CAAC,0BAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AACxC,CAAC"}
1
+ {"version":3,"file":"route-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/route-decorator.ts"],"names":[],"mappings":";;;AAiDA,sBAgCC;AAQD,kBAEC;AAQD,oBAEC;AAQD,kBAEC;AAQD,sBAEC;AAQD,wBAEC;AAnID,wCAA0C;AAC1C,2CAA4C;AAC5C,2DAAsD;AACtD,2DAAoD;AACpD,qDAA8C;AAC9C,uDAAgD;AAChD,uDAAgD;AAgBhD,MAAa,YAAY;IACvB,MAAM,CAAC,WAAW,CAChB,MAAc,EACd,WAA4B;QAE5B,OAAO,OAAO,CAAC,cAAc,CAAC,gBAAS,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IAC/D,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,MAAc,EACd,WAA4B,EAC5B,YAAmB;QAEnB,MAAM,IAAI,GAAG;YACX,MAAM,kCAAc,CAAC,MAAM,CAAC,MAAM,EAAE,W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IACH,CAAC,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,GAAG,CAAC,OAAe,EAAE;IACnC,OAAO,KAAK,CAAC,0BAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,IAAI,CAAC,OAAe,EAAE;IACpC,OAAO,KAAK,CAAC,0BAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACtC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,GAAG,CAAC,OAAe,EAAE;IACnC,OAAO,KAAK,CAAC,0BAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,OAAe,EAAE;IACrC,OAAO,KAAK,CAAC,0BAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACvC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,OAAe,EAAE;IACtC,OAAO,KAAK,CAAC,0BAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AACxC,CAAC"}
@@ -4,18 +4,15 @@ export declare class ApiException extends HttpException {
4
4
  readonly code: string;
5
5
  readonly title: string;
6
6
  readonly message: string;
7
- constructor(code: string, title: string, message: string, status?: HttpStatus);
8
- getResponse(): {
9
- code: string;
10
- title: string;
11
- message: string;
12
- };
7
+ private readonly metadata;
8
+ constructor(code: string, title: string, message: string, status?: HttpStatus, metadata?: any);
9
+ getResponse(): any;
13
10
  }
14
11
  export declare class BadRequestApiException extends ApiException {
15
12
  constructor(message: string);
16
13
  }
17
14
  export declare class ValidationApiException extends ApiException {
18
- constructor(message: string);
15
+ constructor(message: string, errors?: any);
19
16
  }
20
17
  export declare class UnauthorizedApiException extends ApiException {
21
18
  constructor(message?: string);
@@ -1 +1 @@
1
- {"version":3,"file":"api-exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/api-exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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M,EACb,OAAO,EAAE,MAAM,EAC/B,MAAM,GAAE,UAA6C,EACrD,QAAQ,GAAE,GAAQ;IAMpB,WAAW;CAQZ;AAED,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG;CAK1C;AAED,qBAAa,wBAAyB,SAAQ,YAAY;gBAC5C,OAAO,GAAE,MAAuB;CAG7C;AAED,qBAAa,qBAAsB,SAAQ,YAAY;gBACzC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,oBAAqB,SAAQ,YAAY;gBACxC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,+BAAgC,SAAQ,YAAY;gBACnD,OAAO,EAAE,MAAM;CAQ5B;AAED,qBAAa,+BAAgC,SAAQ,YAAY;gBACnD,OAAO,EAAE,MAAM;CAQ5B;AAED,qBAAa,8BAA+B,SAAQ,YAAY;gBAClD,OAAO,EAAE,MAAM;CAQ5B"}
@@ -4,17 +4,19 @@ exports.ServiceUnavailableApiException = exports.InternalServerErrorApiException
4
4
  const http_status_1 = require("../constants/http-status");
5
5
  const http_exception_1 = require("./http-exception");
6
6
  class ApiException extends http_exception_1.HttpException {
7
- constructor(code, title, message, status = http_status_1.HttpStatus.INTERNAL_SERVER_ERROR) {
7
+ constructor(code, title, message, status = http_status_1.HttpStatus.INTERNAL_SERVER_ERROR, metadata = {}) {
8
8
  super(message, status);
9
9
  this.code = code;
10
10
  this.title = title;
11
11
  this.message = message;
12
+ this.metadata = metadata;
12
13
  }
13
14
  getResponse() {
14
15
  return {
15
16
  code: this.code,
16
17
  title: this.title,
17
- message: this.message
18
+ message: this.message,
19
+ ...this.metadata
18
20
  };
19
21
  }
20
22
  }
@@ -26,8 +28,10 @@ class BadRequestApiException extends ApiException {
26
28
  }
27
29
  exports.BadRequestApiException = BadRequestApiException;
28
30
  class ValidationApiException extends ApiException {
29
- constructor(message) {
30
- super('0007', 'Validation Error', message, http_status_1.HttpStatus.BAD_REQUEST);
31
+ constructor(message, errors) {
32
+ super('0007', 'Validation Error', message, http_status_1.HttpStatus.BAD_REQUEST, {
33
+ errors
34
+ });
31
35
  }
32
36
  }
33
37
  exports.ValidationApiException = ValidationApiException;
@@ -1 +1 @@
1
- {"version":3,"file":"api-exception.js","sourceRoot":"","sources":["../../src/exceptions/api-exception.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AACpD,qDAAgD;AAEhD,MAAa,YAAa,SAAQ,8BAAa;IAC7C,YACkB,IAAY,EACZ,KAAa,EACb,OAAe,EAC/B,SAAqB,wBAAU,CAAC,qBAAqB;QAErD,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QALN,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;QACb,YAAO,GAAP,OAAO,CAAQ;IAIjC,CAAC;IAED,WAAW;QACT,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;IACH,CAAC;CACF;AAjBD,oCAiBC;AAED,MAAa,sBAAuB,SAAQ,YAAY;IACtD,YAAY,OAAe;QACzB,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,wBAAU,CAAC,WAAW,CAAC,CAAA;IAC/D,CAAC;CACF;AAJD,wDAIC;AAED,MAAa,sBAAuB,SAAQ,YAAY;IACtD,YAAY,OAAe;QACzB,KAAK,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,wBAAU,CAAC,WAAW,CAAC,CAAA;IACpE,CAAC;CACF;AAJD,wDAIC;AAED,MAAa,wBAAyB,SAAQ,YAAY;IACxD,YAAY,UAAkB,cAAc;QAC1C,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,wBAAU,CAAC,YAAY,CAAC,CAAA;IACjE,CAAC;CACF;AAJD,4DAIC;AAED,MAAa,qBAAsB,SAAQ,YAAY;IACrD,YAAY,OAAe;QACzB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAU,CAAC,SAAS,CAAC,CAAA;IAC3D,CAAC;CACF;AAJD,sDAIC;AAED,MAAa,oBAAqB,SAAQ,YAAY;IACpD,YAAY,OAAe;QACzB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAU,CAAC,SAAS,CAAC,CAAA;IAC3D,CAAC;CACF;AAJD,oDAIC;AAED,MAAa,+BAAgC,SAAQ,YAAY;IAC/D,YAAY,OAAe;QACzB,KAAK,CACH,MAAM,EACN,sBAAsB,EACtB,OAAO,EACP,wBAAU,CAAC,oBAAoB,CAChC,CAAA;IACH,CAAC;CACF;AATD,0EASC;AAED,MAAa,+BAAgC,SAAQ,YAAY;IAC/D,YAAY,OAAe;QACzB,KAAK,CACH,MAAM,EACN,uBAAuB,EACvB,OAAO,EACP,wBAAU,CAAC,qBAAqB,CACjC,CAAA;IACH,CAAC;CACF;AATD,0EASC;AAED,MAAa,8BAA+B,SAAQ,YAAY;IAC9D,YAAY,OAAe;QACzB,KAAK,CACH,MAAM,EACN,qBAAqB,EACrB,OAAO,EACP,wBAAU,CAAC,mBAAmB,CAC/B,CAAA;IACH,CAAC;CACF;AATD,wEASC"}
1
+ {"version":3,"file":"api-exception.js","sourceRoot":"","sources":["../../src/exceptions/api-exception.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AACpD,qDAAgD;AAEhD,MAAa,YAAa,SAAQ,8BAAa;IAG7C,YACkB,IAAY,EACZ,KAAa,EACb,OAAe,EAC/B,SAAqB,wBAAU,CAAC,qBAAqB,EACrD,WAAgB,EAAE;QAElB,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QANN,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;QACb,YAA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AM,EACN,sBAAsB,EACtB,OAAO,EACP,wBAAU,CAAC,oBAAoB,CAChC,CAAA;IACH,CAAC;CACF;AATD,0EASC;AAED,MAAa,+BAAgC,SAAQ,YAAY;IAC/D,YAAY,OAAe;QACzB,KAAK,CACH,MAAM,EACN,uBAAuB,EACvB,OAAO,EACP,wBAAU,CAAC,qBAAqB,CACjC,CAAA;IACH,CAAC;CACF;AATD,0EASC;AAED,MAAa,8BAA+B,SAAQ,YAAY;IAC9D,YAAY,OAAe;QACzB,KAAK,CACH,MAAM,EACN,qBAAqB,EACrB,OAAO,EACP,wBAAU,CAAC,mBAAmB,CAC/B,CAAA;IACH,CAAC;CACF;AATD,wEASC"}
@@ -1 +1 @@
1
- {"version":3,"file":"base-exception-filter.d.ts","sourceRoot":"","sources":["../../src/exceptions/base-exception-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,qBAAa,mBAAoB,YAAW,eAAe;IACnD,KAAK,CAAC,SAAS,EAAE,GAAG;;;CAU3B"}
1
+ {"version":3,"file":"base-exception-filter.d.ts","sourceRoot":"","sources":["../../src/exceptions/base-exception-filter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,qBAAa,mBAAoB,YAAW,eAAe;IACnD,KAAK,CAAC,SAAS,EAAE,GAAG;;;CAmB3B"}
@@ -1,13 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseExceptionFilter = void 0;
4
+ const constants_1 = require("../constants");
5
+ const api_exception_1 = require("./api-exception");
4
6
  const server_1 = require("next/server");
5
7
  class BaseExceptionFilter {
6
8
  async catch(exception) {
7
- const status = exception.getStatus ? exception.getStatus() : 500;
9
+ if (exception instanceof api_exception_1.ApiException) {
10
+ const status = exception.getStatus ? exception.getStatus() : 500;
11
+ return server_1.NextResponse.json({
12
+ message: exception.message || 'Internal server error'
13
+ }, { status });
14
+ }
8
15
  return server_1.NextResponse.json({
9
- message: exception.message || 'Internal server error'
10
- }, { status });
16
+ message: exception.message
17
+ }, { status: constants_1.HttpStatus.INTERNAL_SERVER_ERROR });
11
18
  }
12
19
  }
13
20
  exports.BaseExceptionFilter = BaseExceptionFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"base-exception-filter.js","sourceRoot":"","sources":["../../src/exceptions/base-exception-filter.ts"],"names":[],"mappings":";;;AACA,wCAA0C;AAE1C,MAAa,mBAAmB;IAC9B,KAAK,CAAC,KAAK,CAAC,SAAc;QACxB,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;QAEhE,OAAO,qBAAY,CAAC,IAAI,CACtB;YACE,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,uBAAuB;SACtD,EACD,EAAE,MAAM,EAAE,CACX,CAAA;IACH,CAAC;CACF;AAXD,kDAWC"}
1
+ {"version":3,"file":"base-exception-filter.js","sourceRoot":"","sources":["../../src/exceptions/base-exception-filter.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,mDAA8C;AAE9C,wCAA0C;AAE1C,MAAa,mBAAmB;IAC9B,KAAK,CAAC,KAAK,CAAC,SAAc;QACxB,IAAI,SAAS,YAAY,4BAAY,EAAE,CAAC;YACtC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;YAEhE,OAAO,qBAAY,CAAC,IAAI,CACtB;gBACE,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,uBAAuB;aACtD,EACD,EAAE,MAAM,EAAE,CACX,CAAA;QACH,CAAC;QAED,OAAO,qBAAY,CAAC,IAAI,CACtB;YACE,OAAO,EAAE,SAAS,CAAC,OAAO;SAC3B,EACD,EAAE,MAAM,EAAE,sBAAU,CAAC,qBAAqB,EAAE,CAC7C,CAAA;IACH,CAAC;CACF;AApBD,kDAoBC"}
@@ -1,4 +1,15 @@
1
+ import { Container } from '../../dependency-injection';
1
2
  import { Class } from '../../types/class';
2
- export declare function filterHandler(target: object): any;
3
+ import { ExceptionFilter } from '../exception-filter';
4
+ export type FilterMetadata = {
5
+ filters: Class[];
6
+ };
7
+ export declare class FilterHandler {
8
+ static getMetadata(target: object): FilterMetadata;
9
+ static register(container: Container, target: object): Promise<void>;
10
+ static fetch(container: Container, target: object): Promise<ExceptionFilter[]>;
11
+ static _fetch(container: Container, filter: ExceptionFilter | Class<ExceptionFilter>): Promise<ExceptionFilter>;
12
+ static _register(container: Container, filter: ExceptionFilter | Class<ExceptionFilter>): Promise<void>;
13
+ }
3
14
  export declare function UseFilters(filters: Class[]): ClassDecorator;
4
15
  //# sourceMappingURL=use-filters-decorator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-filters-decorator.d.ts","sourceRoot":"","sources":["../../../src/exceptions/decorators/use-filters-decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,OAE3C;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,cAAc,CAS3D"}
1
+ {"version":3,"file":"use-filters-decorator.d.ts","sourceRoot":"","sources":["../../../src/exceptions/decorators/use-filters-decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,KAAK,EAAE,CAAA;CACjB,CAAA;AAED,qBAAa,aAAa;IACxB,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc;WAQrC,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;WAQ7C,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;WAQ1C,MAAM,CACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;WAUrC,SAAS,CACpB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;CAQnD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,cAAc,CAS3D"}
@@ -1,11 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterHandler = filterHandler;
3
+ exports.FilterHandler = void 0;
4
4
  exports.UseFilters = UseFilters;
5
5
  const keys_1 = require("../../constants/keys");
6
- function filterHandler(target) {
7
- return Reflect.getOwnMetadata(keys_1.FILTER_KEY, target) || [];
6
+ class FilterHandler {
7
+ static getMetadata(target) {
8
+ const metadata = Reflect.getOwnMetadata(keys_1.FILTER_KEY, target);
9
+ if (metadata) {
10
+ return { filters: metadata };
11
+ }
12
+ return { filters: [] };
13
+ }
14
+ static async register(container, target) {
15
+ const { filters } = this.getMetadata(target);
16
+ await Promise.all(filters.map((filter) => FilterHandler._register(container, filter)));
17
+ }
18
+ static async fetch(container, target) {
19
+ const { filters } = this.getMetadata(target);
20
+ return Promise.all(filters.map((filter) => this._fetch(container, filter)));
21
+ }
22
+ static async _fetch(container, filter) {
23
+ // If it's a class constructor (function), resolve from container
24
+ if (typeof filter === 'function') {
25
+ return container.getAsync(filter);
26
+ }
27
+ // If it's an instance, resolve from container using its constructor
28
+ return container.getAsync(filter.constructor);
29
+ }
30
+ static async _register(container, filter) {
31
+ if (typeof filter === 'function') {
32
+ container.bind(filter).to(filter).inSingletonScope();
33
+ }
34
+ else {
35
+ container.bind(filter.constructor).toConstantValue(filter);
36
+ }
37
+ }
8
38
  }
39
+ exports.FilterHandler = FilterHandler;
9
40
  function UseFilters(filters) {
10
41
  return (target) => {
11
42
  const existingFilters = Reflect.getOwnMetadata(keys_1.FILTER_KEY, target) || [];
@@ -1 +1 @@
1
- {"version":3,"file":"use-filters-decorator.js","sourceRoot":"","sources":["../../../src/exceptions/decorators/use-filters-decorator.ts"],"names":[],"mappings":";;AAGA,sCAEC;AAED,gCASC;AAhBD,2CAA6C;AAG7C,SAAgB,aAAa,CAAC,MAAc;IAC1C,OAAO,OAAO,CAAC,cAAc,CAAC,iBAAU,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;AACzD,CAAC;AAED,SAAgB,UAAU,CAAC,OAAgB;IACzC,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,MAAM,eAAe,GACnB,OAAO,CAAC,cAAc,CAAC,iBAAU,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;QAElD,MAAM,cAAc,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC,CAAA;QAEvD,OAAO,CAAC,cAAc,CAAC,iBAAU,EAAE,cAAc,EAAE,MAAM,CAAC,CAAA;IAC5D,CAAC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"use-filters-decorator.js","sourceRoot":"","sources":["../../../src/exceptions/decorators/use-filters-decorator.ts"],"names":[],"mappings":";;;AA0DA,gCASC;AAnED,2CAA6C;AAS7C,MAAa,aAAa;IACxB,MAAM,CAAC,WAAW,CAAC,MAAc;QAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,iBAAU,EAAE,MAAM,CAAC,CAAA;QAC3D,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;QAC9B,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;IAC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AAA;QAC5D,CAAC;IACH,CAAC;CACF;AA/CD,sCA+CC;AAED,SAAgB,UAAU,CAAC,OAAgB;IACzC,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,MAAM,eAAe,GACnB,OAAO,CAAC,cAAc,CAAC,iBAAU,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;QAElD,MAAM,cAAc,GAAG,CAAC,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC,CAAA;QAEvD,OAAO,CAAC,cAAc,CAAC,iBAAU,EAAE,cAAc,EAAE,MAAM,CAAC,CAAA;IAC5D,CAAC,CAAA;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,9 +8,12 @@ export * from './logger';
8
8
  export * from './controllers';
9
9
  export * from './dependency-injection';
10
10
  export * from './modules';
11
+ export * from './pipes';
11
12
  export * from './server';
13
+ export * from './zod';
12
14
  export { REQUEST } from './services/request';
13
15
  export { APP_INTERCEPTOR } from './services/interceptor';
14
16
  export { APP_FILTER } from './services/filters';
17
+ export { APP_PIPE } from './services/pipes';
15
18
  export { FetchModuleOptions, HttpService } from './services/http-service';
16
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAA;AAEzB,cAAc,aAAa,CAAA;AAC3B,cAAc,0BAA0B,CAAA;AACxC,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAA;AAEzB,cAAc,aAAa,CAAA;AAC3B,cAAc,0BAA0B,CAAA;AACxC,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AAGrB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA"}
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.HttpService = exports.APP_FILTER = exports.APP_INTERCEPTOR = exports.REQUEST = void 0;
19
+ exports.HttpService = exports.APP_PIPE = exports.APP_FILTER = exports.APP_INTERCEPTOR = exports.REQUEST = void 0;
20
20
  require("reflect-metadata");
21
21
  __exportStar(require("./constants"), exports);
22
22
  __exportStar(require("./utils/apply-decorators"), exports);
@@ -27,7 +27,9 @@ __exportStar(require("./logger"), exports);
27
27
  __exportStar(require("./controllers"), exports);
28
28
  __exportStar(require("./dependency-injection"), exports);
29
29
  __exportStar(require("./modules"), exports);
30
+ __exportStar(require("./pipes"), exports);
30
31
  __exportStar(require("./server"), exports);
32
+ __exportStar(require("./zod"), exports);
31
33
  // Services
32
34
  var request_1 = require("./services/request");
33
35
  Object.defineProperty(exports, "REQUEST", { enumerable: true, get: function () { return request_1.REQUEST; } });
@@ -35,6 +37,8 @@ var interceptor_1 = require("./services/interceptor");
35
37
  Object.defineProperty(exports, "APP_INTERCEPTOR", { enumerable: true, get: function () { return interceptor_1.APP_INTERCEPTOR; } });
36
38
  var filters_1 = require("./services/filters");
37
39
  Object.defineProperty(exports, "APP_FILTER", { enumerable: true, get: function () { return filters_1.APP_FILTER; } });
40
+ var pipes_1 = require("./services/pipes");
41
+ Object.defineProperty(exports, "APP_PIPE", { enumerable: true, get: function () { return pipes_1.APP_PIPE; } });
38
42
  var http_service_1 = require("./services/http-service");
39
43
  Object.defineProperty(exports, "HttpService", { enumerable: true, get: function () { return http_service_1.HttpService; } });
40
44
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,sEAAsE;;;;;;;;;;;;;;;;;AAEtE,4BAAyB;AAEzB,8CAA2B;AAC3B,2DAAwC;AACxC,4CAAyB;AACzB,+CAA4B;AAC5B,gDAA6B;AAC7B,2CAAwB;AACxB,gDAA6B;AAC7B,yDAAsC;AACtC,4CAAyB;AACzB,2CAAwB;AAExB,WAAW;AACX,8CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,sDAAwD;AAA/C,8GAAA,eAAe,OAAA;AACxB,8CAA+C;AAAtC,qGAAA,UAAU,OAAA;AACnB,wDAAyE;AAA5C,2GAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,sEAAsE;;;;;;;;;;;;;;;;;AAEtE,4BAAyB;AAEzB,8CAA2B;AAC3B,2DAAwC;AACxC,4CAAyB;AACzB,+CAA4B;AAC5B,gDAA6B;AAC7B,2CAAwB;AACxB,gDAA6B;AAC7B,yDAAsC;AACtC,4CAAyB;AACzB,0CAAuB;AACvB,2CAAwB;AACxB,wCAAqB;AAErB,WAAW;AACX,8CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,sDAAwD;AAA/C,8GAAA,eAAe,OAAA;AACxB,8CAA+C;AAAtC,qGAAA,UAAU,OAAA;AACnB,0CAA2C;AAAlC,iGAAA,QAAQ,OAAA;AACjB,wDAAyE;AAA5C,2GAAA,WAAW,OAAA"}
@@ -1,8 +1,15 @@
1
1
  import { Interceptor } from '../interceptor';
2
2
  import { ExecutionContext } from '../../context/execution-context';
3
3
  import { Class } from '../../types/class';
4
- export declare function interceptorExecute(executionContext: ExecutionContext, middlewares: Interceptor[], action: () => Promise<any>): Promise<any>;
5
- export type InterceptorMetadata = Interceptor | Class<Interceptor>;
6
- export declare function interceptorHandler(target: object): InterceptorMetadata[];
4
+ import type { Container } from '../../dependency-injection';
5
+ export type InterceptorMetadata = {
6
+ interceptors: (Interceptor | Class<Interceptor>)[];
7
+ };
8
+ export declare class InterceptorHandler {
9
+ static getMetadata(target: object): InterceptorMetadata;
10
+ static register(container: Container, target: object): Promise<void>;
11
+ static fetch(container: Container, target: object): Promise<Interceptor[]>;
12
+ static execute(executionContext: ExecutionContext, middlewares: Interceptor[], action: () => Promise<any>): Promise<any>;
13
+ }
7
14
  export declare function UseInterceptors(...interceptors: (Interceptor | Class<Interceptor>)[]): ClassDecorator;
8
15
  //# sourceMappingURL=use-interceptor-decorator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-interceptor-decorator.d.ts","sourceRoot":"","sources":["../../../src/interceptor/decorators/use-interceptor-decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC,wBAAsB,kBAAkB,CACtC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EAAE,EAC1B,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,gBA0B3B;AAED,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAA;AAElE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAExE;AAED,wBAAgB,eAAe,CAC7B,GAAG,YAAY,EAAE,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,GACpD,cAAc,CAUhB"}
1
+ {"version":3,"file":"use-interceptor-decorator.d.ts","sourceRoot":"","sources":["../../../src/interceptor/decorators/use-interceptor-decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAA;CACnD,CAAA;AAED,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB;WAQ1C,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;WAoB7C,KAAK,CAChB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,EAAE,CAAC;WAmBZ,OAAO,CAClB,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EAAE,EAC1B,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;CA2B7B;AAED,wBAAgB,eAAe,CAC7B,GAAG,YAAY,EAAE,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,GACpD,cAAc,CAUhB"}
@@ -1,34 +1,72 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.interceptorExecute = interceptorExecute;
4
- exports.interceptorHandler = interceptorHandler;
3
+ exports.InterceptorHandler = void 0;
5
4
  exports.UseInterceptors = UseInterceptors;
6
5
  const keys_1 = require("../../constants/keys");
7
- async function interceptorExecute(executionContext, middlewares, action) {
8
- if (middlewares.length === 0) {
9
- return await action();
6
+ class InterceptorHandler {
7
+ static getMetadata(target) {
8
+ const metadata = Reflect.getOwnMetadata(keys_1.INTERCEPTOR_KEY, target);
9
+ if (metadata) {
10
+ return { interceptors: metadata };
11
+ }
12
+ return { interceptors: [] };
10
13
  }
11
- let i = 0;
12
- const next = {
13
- handle: async () => {
14
- if (i >= middlewares.length) {
15
- return await action();
16
- }
17
- const layer = middlewares[i++];
18
- try {
19
- return await layer.intercept(executionContext, next);
20
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
+ static async register(container, target) {
15
+ const metadata = InterceptorHandler.getMetadata(target);
16
+ if (!metadata || metadata.interceptors.length === 0) {
17
+ return;
18
+ }
19
+ metadata.interceptors.forEach((interceptor) => {
20
+ // If it's a class constructor (function), register it in the container
21
+ if (typeof interceptor === 'function') {
22
+ if (!container.isBound(interceptor)) {
23
+ container.bind(interceptor).toSelf().inSingletonScope();
24
+ }
21
25
  }
22
- catch (error) {
23
- return await next.handle();
26
+ else {
27
+ // If it's an instance, bind it to its constructor class as a constant value
28
+ container.bind(interceptor.constructor).toConstantValue(interceptor);
24
29
  }
30
+ });
31
+ }
32
+ static async fetch(container, target) {
33
+ const metadata = InterceptorHandler.getMetadata(target);
34
+ if (metadata && metadata.interceptors.length > 0) {
35
+ return await Promise.all(metadata.interceptors.map((interceptor) => {
36
+ // If it's a class constructor (function), resolve from container
37
+ if (typeof interceptor === 'function') {
38
+ return container.getAsync(interceptor);
39
+ }
40
+ // If it's an instance, resolve from container using its constructor
41
+ return container.getAsync(interceptor.constructor);
42
+ }));
25
43
  }
26
- };
27
- return await next.handle();
28
- }
29
- function interceptorHandler(target) {
30
- return Reflect.getOwnMetadata(keys_1.INTERCEPTOR_KEY, target) || [];
44
+ return [];
45
+ }
46
+ static async execute(executionContext, middlewares, action) {
47
+ if (middlewares.length === 0) {
48
+ return await action();
49
+ }
50
+ let i = 0;
51
+ const next = {
52
+ handle: async () => {
53
+ if (i >= middlewares.length) {
54
+ return await action();
55
+ }
56
+ const layer = middlewares[i++];
57
+ try {
58
+ return await layer.intercept(executionContext, next);
59
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
60
+ }
61
+ catch (error) {
62
+ return await next.handle();
63
+ }
64
+ }
65
+ };
66
+ return await next.handle();
67
+ }
31
68
  }
69
+ exports.InterceptorHandler = InterceptorHandler;
32
70
  function UseInterceptors(...interceptors) {
33
71
  return (target) => {
34
72
  const existingInterceptors = Reflect.getOwnMetadata(keys_1.INTERCEPTOR_KEY, target) || [];
@@ -1 +1 @@
1
- {"version":3,"file":"use-interceptor-decorator.js","sourceRoot":"","sources":["../../../src/interceptor/decorators/use-interceptor-decorator.ts"],"names":[],"mappings":";;AAMA,gDA6BC;AAID,gDAEC;AAED,0CAYC;AAvDD,2CAAkD;AAM3C,KAAK,UAAU,kBAAkB,CACtC,gBAAkC,EAClC,WAA0B,EAC1B,MAA0B;IAE1B,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,MAAM,MAAM,EAAE,CAAA;IACvB,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,CAAA;IAET,MAAM,IAAI,GAAgB;QACxB,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;gBAC5B,OAAO,MAAM,MAAM,EAAE,CAAA;YACvB,CAAC;YAED,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAA;YAE9B,IAAI,CAAC;gBACH,OAAO,MAAM,KAAK,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;gBACpD,6DAA6D;YAC/D,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,OAAO,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;YAC5B,CAAC;QACH,CAAC;KACF,CAAA;IAED,OAAO,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;AAC5B,CAAC;AAID,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,OAAO,OAAO,CAAC,cAAc,CAAC,sBAAe,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;AAC9D,CAAC;AAED,SAAgB,eAAe,CAC7B,GAAG,YAAkD;IAErD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,MAAM,oBAAoB,GACxB,OAAO,CAAC,cAAc,CAAC,sBAAe,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;QACvD,OAAO,CAAC,cAAc,CACpB,sBAAe,EACf,CAAC,GAAG,oBAAoB,EAAE,GAAG,YAAY,CAAC,EAC1C,MAAM,CACP,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"use-interceptor-decorator.js","sourceRoot":"","sources":["../../../src/interceptor/decorators/use-interceptor-decorator.ts"],"names":[],"mappings":";;;AA8FA,0CAYC;AA1GD,2CAAkD;AAWlD,MAAa,kBAAkB;IAC7B,MAAM,CAAC,WAAW,CAAC,MAAc;QAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,sBAAe,EAAE,MAAM,CAAC,CAAA;QAChE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAA;QACnC,CAAC;QACD,OAAO,EAAE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
1
1
  import { ResolutionContext } from 'inversify';
2
2
  import { Class, Constructor } from '../types/class';
3
3
  import { Scope } from '../constants/scopes';
4
- import { ControllerMetadata } from '../controllers/decorators/controller-decorator';
4
+ import { RouteMetadata } from '../controllers/decorators/route-decorator';
5
5
  export type InjectionToken<T = any> = symbol | string | Constructor<T>;
6
6
  type Provider = {
7
7
  provide: InjectionToken;
@@ -15,7 +15,7 @@ export type ModuleOptions = {
15
15
  controllers?: Class[];
16
16
  providers?: Provider[];
17
17
  };
18
- export type ModuleMetadata = ControllerMetadata & {
18
+ export type ModuleMetadata = RouteMetadata & {
19
19
  controller: Class;
20
20
  };
21
21
  export declare function moduleHandler(target: Function, visited?: Set<Function>): ModuleMetadata[];