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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) 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 +4 -0
  7. package/dist/constants/keys.d.ts.map +1 -1
  8. package/dist/constants/keys.js +5 -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 +2 -3
  35. package/dist/controllers/decorators/body-decorator.d.ts.map +1 -1
  36. package/dist/controllers/decorators/body-decorator.js +31 -13
  37. package/dist/controllers/decorators/body-decorator.js.map +1 -1
  38. package/dist/controllers/decorators/controller-decorator.d.ts +0 -4
  39. package/dist/controllers/decorators/controller-decorator.d.ts.map +1 -1
  40. package/dist/controllers/decorators/controller-decorator.js +1 -44
  41. package/dist/controllers/decorators/controller-decorator.js.map +1 -1
  42. package/dist/dependency-injection/container.js +1 -1
  43. package/dist/dependency-injection/container.js.map +1 -1
  44. package/dist/dependency-injection/index.d.ts +2 -1
  45. package/dist/dependency-injection/index.d.ts.map +1 -1
  46. package/dist/dependency-injection/index.js +3 -2
  47. package/dist/dependency-injection/index.js.map +1 -1
  48. package/dist/dependency-injection/injectable-decorator.d.ts +7 -0
  49. package/dist/dependency-injection/injectable-decorator.d.ts.map +1 -0
  50. package/dist/dependency-injection/injectable-decorator.js +21 -0
  51. package/dist/dependency-injection/injectable-decorator.js.map +1 -0
  52. package/dist/exceptions/base-exception-filter.d.ts +8 -0
  53. package/dist/exceptions/base-exception-filter.d.ts.map +1 -0
  54. package/dist/exceptions/base-exception-filter.js +14 -0
  55. package/dist/exceptions/base-exception-filter.js.map +1 -0
  56. package/dist/exceptions/decorators/catch-decorator.d.ts +8 -0
  57. package/dist/exceptions/decorators/catch-decorator.d.ts.map +1 -0
  58. package/dist/exceptions/decorators/catch-decorator.js +14 -0
  59. package/dist/exceptions/decorators/catch-decorator.js.map +1 -0
  60. package/dist/exceptions/decorators/index.d.ts +3 -0
  61. package/dist/exceptions/decorators/index.d.ts.map +1 -0
  62. package/dist/exceptions/decorators/index.js +8 -0
  63. package/dist/exceptions/decorators/index.js.map +1 -0
  64. package/dist/exceptions/decorators/use-filters-decorator.d.ts +4 -0
  65. package/dist/exceptions/decorators/use-filters-decorator.d.ts.map +1 -0
  66. package/dist/exceptions/decorators/use-filters-decorator.js +16 -0
  67. package/dist/exceptions/decorators/use-filters-decorator.js.map +1 -0
  68. package/dist/exceptions/exception-filter.d.ts +6 -0
  69. package/dist/exceptions/exception-filter.d.ts.map +1 -0
  70. package/dist/exceptions/exception-filter.js +7 -0
  71. package/dist/exceptions/exception-filter.js.map +1 -0
  72. package/dist/exceptions/index.d.ts +3 -0
  73. package/dist/exceptions/index.d.ts.map +1 -1
  74. package/dist/exceptions/index.js +3 -0
  75. package/dist/exceptions/index.js.map +1 -1
  76. package/dist/index.d.ts +7 -0
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +11 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/interceptor/call-handler.d.ts +4 -0
  81. package/dist/interceptor/call-handler.d.ts.map +1 -0
  82. package/dist/interceptor/call-handler.js +3 -0
  83. package/dist/interceptor/call-handler.js.map +1 -0
  84. package/dist/interceptor/decorators/index.d.ts +2 -0
  85. package/dist/interceptor/decorators/index.d.ts.map +1 -0
  86. package/dist/interceptor/decorators/index.js +6 -0
  87. package/dist/interceptor/decorators/index.js.map +1 -0
  88. package/dist/interceptor/decorators/use-interceptor-decorator.d.ts +8 -0
  89. package/dist/interceptor/decorators/use-interceptor-decorator.d.ts.map +1 -0
  90. package/dist/interceptor/decorators/use-interceptor-decorator.js +38 -0
  91. package/dist/interceptor/decorators/use-interceptor-decorator.js.map +1 -0
  92. package/dist/interceptor/index.d.ts +4 -0
  93. package/dist/interceptor/index.d.ts.map +1 -0
  94. package/dist/interceptor/index.js +20 -0
  95. package/dist/interceptor/index.js.map +1 -0
  96. package/dist/interceptor/interceptor.d.ts +3 -5
  97. package/dist/interceptor/interceptor.d.ts.map +1 -1
  98. package/dist/interceptor/interceptor.js.map +1 -1
  99. package/dist/logger/console-logger.d.ts +24 -0
  100. package/dist/logger/console-logger.d.ts.map +1 -0
  101. package/dist/logger/console-logger.js +78 -0
  102. package/dist/logger/console-logger.js.map +1 -0
  103. package/dist/logger/index.d.ts +4 -0
  104. package/dist/logger/index.d.ts.map +1 -0
  105. package/dist/logger/index.js +8 -0
  106. package/dist/logger/index.js.map +1 -0
  107. package/dist/logger/logger-service.d.ts +34 -0
  108. package/dist/logger/logger-service.d.ts.map +1 -0
  109. package/dist/logger/logger-service.js +12 -0
  110. package/dist/logger/logger-service.js.map +1 -0
  111. package/dist/logger/logger.d.ts +21 -0
  112. package/dist/logger/logger.d.ts.map +1 -0
  113. package/dist/logger/logger.js +86 -0
  114. package/dist/logger/logger.js.map +1 -0
  115. package/dist/modules/module-decorator.d.ts +3 -1
  116. package/dist/modules/module-decorator.d.ts.map +1 -1
  117. package/dist/modules/module-decorator.js +83 -23
  118. package/dist/modules/module-decorator.js.map +1 -1
  119. package/dist/server/server-factory.d.ts +15 -8
  120. package/dist/server/server-factory.d.ts.map +1 -1
  121. package/dist/server/server-factory.js +95 -49
  122. package/dist/server/server-factory.js.map +1 -1
  123. package/dist/services/filters.d.ts +2 -0
  124. package/dist/services/filters.d.ts.map +1 -0
  125. package/dist/services/filters.js +5 -0
  126. package/dist/services/filters.js.map +1 -0
  127. package/dist/services/http-service.d.ts +68 -0
  128. package/dist/services/http-service.d.ts.map +1 -0
  129. package/dist/services/http-service.js +233 -0
  130. package/dist/services/http-service.js.map +1 -0
  131. package/dist/services/interceptor.d.ts +2 -0
  132. package/dist/services/interceptor.d.ts.map +1 -0
  133. package/dist/services/interceptor.js +5 -0
  134. package/dist/services/interceptor.js.map +1 -0
  135. package/dist/utils/form-data/get-form-data.d.ts +2 -0
  136. package/dist/utils/form-data/get-form-data.d.ts.map +1 -0
  137. package/dist/utils/form-data/get-form-data.js +11 -0
  138. package/dist/utils/form-data/get-form-data.js.map +1 -0
  139. package/dist/utils/search/create-query-string.d.ts +9 -0
  140. package/dist/utils/search/create-query-string.d.ts.map +1 -0
  141. package/dist/utils/search/create-query-string.js +26 -0
  142. package/dist/utils/search/create-query-string.js.map +1 -0
  143. package/package.json +2 -5
  144. package/dist/interceptor/decorators/use-interceptor.d.ts +0 -3
  145. package/dist/interceptor/decorators/use-interceptor.d.ts.map +0 -1
  146. package/dist/interceptor/decorators/use-interceptor.js +0 -9
  147. package/dist/interceptor/decorators/use-interceptor.js.map +0 -1
@@ -1,7 +1,6 @@
1
- import { z } from 'zod';
2
1
  export type BodyMetadata = {
3
2
  propertyIndex: number;
4
- schema?: () => z.ZodSchema;
3
+ schema?: () => any;
5
4
  };
6
5
  /**
7
6
  * Handler to validate the body of the request.
@@ -21,5 +20,5 @@ export declare function bodyDecoratorHandler(target: object, propertyKey: string
21
20
  * @param schema - The Zod schema to validate the body against.
22
21
  * @returns A decorator function that can be used to decorate a controller method.
23
22
  */
24
- export declare function Body(schema?: z.ZodSchema | (() => z.ZodSchema)): (target: object, propertyKey: string | symbol, propertyIndex: number) => void;
23
+ export declare function Body(schema?: any): (target: object, propertyKey: string | symbol, propertyIndex: number) => void;
25
24
  //# 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,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,CAAA;CACnB,CAAA;AAKD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE;;;UA6DZ;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,IAE7B,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,eAAe,MAAM,UAQxB"}
@@ -5,6 +5,9 @@ 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
+ const get_form_data_1 = require("../../utils/form-data/get-form-data");
9
+ // Cache to store parsed body to avoid reading it multiple times
10
+ const bodyCache = new WeakMap();
8
11
  /**
9
12
  * Handler to validate the body of the request.
10
13
  *
@@ -18,13 +21,28 @@ async function bodyDecoratorHandler(target, propertyKey, args) {
18
21
  // If the metadata is not found, return null.
19
22
  if (metadata) {
20
23
  const request = (0, get_next_arguments_1.getNextRequestArgument)(args);
21
- let body;
22
- try {
23
- body = await request.json();
24
- }
25
- catch (error) {
26
- // Handle missing or invalid body
27
- throw new api_exception_1.ValidationApiException('Missing or invalid request body');
24
+ // Check if body is already cached
25
+ let body = bodyCache.get(request);
26
+ if (!body) {
27
+ const contentType = request.headers.get('Content-Type');
28
+ try {
29
+ if (contentType?.includes('multipart/form-data')) {
30
+ body = (0, get_form_data_1.getFormData)(await request.formData());
31
+ }
32
+ else if (contentType?.includes('application/json')) {
33
+ body = await request.json();
34
+ }
35
+ else {
36
+ body = await request.text();
37
+ }
38
+ // Cache the parsed body
39
+ bodyCache.set(request, body);
40
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
+ }
42
+ catch (error) {
43
+ // Handle missing or invalid body
44
+ throw new api_exception_1.ValidationApiException('Missing or invalid request body');
45
+ }
28
46
  }
29
47
  // If the schema is not provided, return the body.
30
48
  if (!metadata.schema) {
@@ -41,7 +59,7 @@ async function bodyDecoratorHandler(target, propertyKey, args) {
41
59
  throw new api_exception_1.ValidationApiException(`Invalid body: ${JSON.stringify(parsedBody.error.flatten().fieldErrors)}`);
42
60
  }
43
61
  return {
44
- parameter: parsedBody?.data || body,
62
+ parameter: body,
45
63
  parameterIndex: metadata.propertyIndex
46
64
  };
47
65
  }
@@ -55,11 +73,11 @@ async function bodyDecoratorHandler(target, propertyKey, args) {
55
73
  */
56
74
  function Body(schema) {
57
75
  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);
76
+ const metadata = {
77
+ propertyIndex,
78
+ schema: schema ? () => schema : undefined
79
+ };
80
+ Reflect.defineMetadata(keys_1.BODY_KEY, metadata, target, propertyKey);
63
81
  };
64
82
  }
65
83
  //# 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;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AAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,iCAAiC;gBACjC,MAAM,IAAI,sCAAsB,CAAC,iCAAiC,CAAC,CAAA;YACrE,CAAC;QACH,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,IAAI;YACf,cAAc,EAAE,QAAQ,CAAC,aAAa;SACvC,CAAA;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAgB,IAAI,CAAC,MAAY;IAC/B,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,aAAqB;QAErB,MAAM,QAAQ,GAAiB;YAC7B,aAAa;YACb,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SAC1C,CAAA;QACD,OAAO,CAAC,cAAc,CAAC,eAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IACjE,CAAC,CAAA;AACH,CAAC"}
@@ -1,8 +1,4 @@
1
1
  import { HttpMethods } from '../../constants/http-methods';
2
- export type ErrorResponse = {
3
- message: string;
4
- status: number;
5
- };
6
2
  export type ControllerMetadata = {
7
3
  methodName: string;
8
4
  method: HttpMethods;
@@ -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":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAOtD,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,CAIvD"}
@@ -3,34 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.controllerHandler = controllerHandler;
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() };
23
- }
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
11
  function controllerHandler(target) {
35
12
  const routes = [];
36
13
  const prototype = target.prototype;
@@ -62,28 +39,8 @@ function controllerHandler(target) {
62
39
  * @returns
63
40
  */
64
41
  function Controller(path) {
65
- return (0, apply_decorators_1.applyDecorators)((0, inversify_1.injectable)(), (0, inversify_1.injectFromBase)({
66
- extendProperties: true
67
- }), function (target) {
42
+ return (0, apply_decorators_1.applyDecorators)((0, inversify_1.injectable)(), function (target) {
68
43
  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
44
  });
88
45
  }
89
46
  //# sourceMappingURL=controller-decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"controller-decor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oBACpB,MAAM,MAAM,GAAI,IAAY,CAAC,MAAM,CAAA;oBAEnC,MAAM,EAAE,OAAO,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":";;AAcA,8CA+BC;AAOD,gCAIC;AAxDD,yCAAsC;AAEtC,2CAAiD;AACjD,uDAAgD;AAChD,+DAA0D;AAC1D,uEAAiE;AACjE,mDAA8C;AAQ9C,SAAgB,iBAAiB,CAAC,MAAgB;IAChD,MAAM,MAAM,GAAyB,EAAE,CAAA;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;IAElC,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,MAAM,CAAC,CAAA;IAE/D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,IAAI,uCAAuC,CAAC,CAAA;QACzE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,mCAAe,EAAC,MAAM,CAAC,CAAA;IAE3C,yCAAyC;IACzC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,aAAa,GAAG,IAAA,8BAAY,EAAC,SAAS,EAAE,UAAU,CAAC,CAAA;QAEzD,IAAI,aAAa,EAAE,CAAC;YAClB,+CAA+C;YAC/C,MAAM,GAAG,GAAG,IAAA,kBAAO,EAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;YAEtD,oCAAoC;YACpC,MAAM,CAAC,IAAI,CAAC;gBACV,UAAU,EAAE,UAAU;gBACtB,MAAM,EAAE,aAAa,CAAC,MAAM;gBAC5B,IAAI,EAAE,GAAG;aACV,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;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"}
@@ -18,7 +18,7 @@ class Container {
18
18
  * @param module ContainerModule
19
19
  */
20
20
  load(module) {
21
- if (!module.hasOwnProperty('registry')) {
21
+ if (!Object.prototype.hasOwnProperty.call(module, 'registry')) {
22
22
  throw new Error(`Container: module ${module} does not have a registry method`);
23
23
  }
24
24
  // Prevent infinite recursion by tracking loaded modules
@@ -1 +1 @@
1
- {"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/dependency-injection/container.ts"],"names":[],"mappings":";;;AAAA,yCAIkB;AAElB;;;GAGG;AACH,MAAa,SAAS;IAIpB;QAFQ,kBAAa,GAAyB,IAAI,GAAG,EAAE,CAAA;QAGrD,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAkB,EAAE,CAAA;IAC3C,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,MAAuB;QAC1B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CACb,qBAAqB,MAAM,kCAAkC,CAC9D,CAAA;QACH,CAAC;QAED,wDAAwD;QACxD,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,OAAM;QACR,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MA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AAwD;QACxD,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,OAAM;QACR,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAE9B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAED,IAAI,CAAI,iBAAuC;QAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAC/C,CAAC;IAED,GAAG,CAAI,iBAAuC;QAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;IAC9C,CAAC;IAED,QAAQ,CAAI,iBAAuC;QACjD,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IACnD,CAAC;IAED,OAAO,CAAI,iBAAuC;QAChD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,CAAI,iBAAuC;QAC/C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;IAC1C,CAAC;CACF;AAjDD,8BAiDC;AAID;;;;GAIG;AACH,MAAa,eAAe;IAG1B,YAAY,QAAiC;QAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAND,0CAMC"}
@@ -1,3 +1,4 @@
1
1
  export * from './container';
2
- export { inject as Inject, injectable as Injectable } from 'inversify';
2
+ export * from './injectable-decorator';
3
+ export { inject as Inject, optional as Optional } from 'inversify';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,wBAAwB,CAAA;AACtC,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,QAAQ,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAA"}
@@ -14,9 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Injectable = exports.Inject = void 0;
17
+ exports.Optional = exports.Inject = void 0;
18
18
  __exportStar(require("./container"), exports);
19
+ __exportStar(require("./injectable-decorator"), exports);
19
20
  var inversify_1 = require("inversify");
20
21
  Object.defineProperty(exports, "Inject", { enumerable: true, get: function () { return inversify_1.inject; } });
21
- Object.defineProperty(exports, "Injectable", { enumerable: true, get: function () { return inversify_1.injectable; } });
22
+ Object.defineProperty(exports, "Optional", { enumerable: true, get: function () { return inversify_1.optional; } });
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dependency-injection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,uCAAsE;AAA7D,mGAAA,MAAM,OAAU;AAAE,uGAAA,UAAU,OAAc"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dependency-injection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,yDAAsC;AACtC,uCAAkE;AAAzD,mGAAA,MAAM,OAAU;AAAE,qGAAA,QAAQ,OAAY"}
@@ -0,0 +1,7 @@
1
+ import { Scope } from '../constants/scopes';
2
+ export declare function injectableHandler(target: Function): any;
3
+ export type InjectableOptions = {
4
+ scope?: Scope;
5
+ };
6
+ export declare function Injectable(options?: InjectableOptions): ClassDecorator;
7
+ //# sourceMappingURL=injectable-decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectable-decorator.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/injectable-decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,OAEjD;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CAW1E"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.injectableHandler = injectableHandler;
4
+ exports.Injectable = Injectable;
5
+ const inversify_1 = require("inversify");
6
+ const keys_1 = require("../constants/keys");
7
+ const scopes_1 = require("../constants/scopes");
8
+ function injectableHandler(target) {
9
+ return Reflect.getOwnMetadata(keys_1.INJECTABLE_KEY, target);
10
+ }
11
+ function Injectable(options = {}) {
12
+ const { scope = scopes_1.Scope.DEFAULT } = options;
13
+ return (target) => {
14
+ Reflect.defineMetadata(keys_1.INJECTABLE_KEY, { scope }, target);
15
+ if (options?.scope) {
16
+ console.warn('Injectable: Scope option is not implemented.');
17
+ }
18
+ (0, inversify_1.injectable)()(target);
19
+ };
20
+ }
21
+ //# sourceMappingURL=injectable-decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectable-decorator.js","sourceRoot":"","sources":["../../src/dependency-injection/injectable-decorator.ts"],"names":[],"mappings":";;AAIA,8CAEC;AAMD,gCAWC;AAvBD,yCAAsC;AACtC,2CAAiD;AACjD,+CAA0C;AAE1C,SAAgB,iBAAiB,CAAC,MAAgB;IAChD,OAAO,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,MAAM,CAAC,CAAA;AACvD,CAAC;AAMD,SAAgB,UAAU,CAAC,UAA6B,EAAE;IACxD,MAAM,EAAE,KAAK,GAAG,cAAK,CAAC,OAAO,EAAE,GAAG,OAAO,CAAA;IACzC,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,OAAO,CAAC,cAAc,CAAC,qBAAc,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC,CAAA;QAEzD,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAA;QAC9D,CAAC;QAED,IAAA,sBAAU,GAAE,CAAC,MAAM,CAAC,CAAA;IACtB,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ExceptionFilter } from './exception-filter';
2
+ import { NextResponse } from 'next/server';
3
+ export declare class BaseExceptionFilter implements ExceptionFilter {
4
+ catch(exception: any): Promise<NextResponse<{
5
+ message: any;
6
+ }>>;
7
+ }
8
+ //# sourceMappingURL=base-exception-filter.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseExceptionFilter = void 0;
4
+ const server_1 = require("next/server");
5
+ class BaseExceptionFilter {
6
+ async catch(exception) {
7
+ const status = exception.getStatus ? exception.getStatus() : 500;
8
+ return server_1.NextResponse.json({
9
+ message: exception.message || 'Internal server error'
10
+ }, { status });
11
+ }
12
+ }
13
+ exports.BaseExceptionFilter = BaseExceptionFilter;
14
+ //# sourceMappingURL=base-exception-filter.js.map
@@ -0,0 +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"}
@@ -0,0 +1,8 @@
1
+ import { Class } from '../../types/class';
2
+ type CatchMetadata = {
3
+ type: Class;
4
+ };
5
+ export declare function catchHandler(target: object): CatchMetadata;
6
+ export declare function Catch(errorType?: Class): ClassDecorator;
7
+ export {};
8
+ //# sourceMappingURL=catch-decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catch-decorator.d.ts","sourceRoot":"","sources":["../../../src/exceptions/decorators/catch-decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAErC,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,KAAK,CAAA;CACZ,CAAA;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE1D;AAED,wBAAgB,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,cAAc,CAIvD"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.catchHandler = catchHandler;
4
+ exports.Catch = Catch;
5
+ const keys_1 = require("../../constants/keys");
6
+ function catchHandler(target) {
7
+ return Reflect.getOwnMetadata(keys_1.CATCH_KEY, target);
8
+ }
9
+ function Catch(errorType) {
10
+ return (target) => {
11
+ Reflect.defineMetadata(keys_1.CATCH_KEY, { type: errorType }, target);
12
+ };
13
+ }
14
+ //# sourceMappingURL=catch-decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catch-decorator.js","sourceRoot":"","sources":["../../../src/exceptions/decorators/catch-decorator.ts"],"names":[],"mappings":";;AAOA,oCAEC;AAED,sBAIC;AAfD,2CAA4C;AAO5C,SAAgB,YAAY,CAAC,MAAc;IACzC,OAAO,OAAO,CAAC,cAAc,CAAC,gBAAS,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC;AAED,SAAgB,KAAK,CAAC,SAAiB;IACrC,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,cAAc,CAAC,gBAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAA;IAChE,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Catch } from './catch-decorator';
2
+ export { UseFilters } from './use-filters-decorator';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exceptions/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UseFilters = exports.Catch = void 0;
4
+ var catch_decorator_1 = require("./catch-decorator");
5
+ Object.defineProperty(exports, "Catch", { enumerable: true, get: function () { return catch_decorator_1.Catch; } });
6
+ var use_filters_decorator_1 = require("./use-filters-decorator");
7
+ Object.defineProperty(exports, "UseFilters", { enumerable: true, get: function () { return use_filters_decorator_1.UseFilters; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exceptions/decorators/index.ts"],"names":[],"mappings":";;;AAAA,qDAAyC;AAAhC,wGAAA,KAAK,OAAA;AACd,iEAAoD;AAA3C,mHAAA,UAAU,OAAA"}
@@ -0,0 +1,4 @@
1
+ import { Class } from '../../types/class';
2
+ export declare function filterHandler(target: object): any;
3
+ export declare function UseFilters(filters: Class[]): ClassDecorator;
4
+ //# sourceMappingURL=use-filters-decorator.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterHandler = filterHandler;
4
+ exports.UseFilters = UseFilters;
5
+ const keys_1 = require("../../constants/keys");
6
+ function filterHandler(target) {
7
+ return Reflect.getOwnMetadata(keys_1.FILTER_KEY, target) || [];
8
+ }
9
+ function UseFilters(filters) {
10
+ return (target) => {
11
+ const existingFilters = Reflect.getOwnMetadata(keys_1.FILTER_KEY, target) || [];
12
+ const updatedFilters = [...existingFilters, ...filters];
13
+ Reflect.defineMetadata(keys_1.FILTER_KEY, updatedFilters, target);
14
+ };
15
+ }
16
+ //# sourceMappingURL=use-filters-decorator.js.map
@@ -0,0 +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"}
@@ -0,0 +1,6 @@
1
+ import { ArgumentsHost } from '../context/arguments-host';
2
+ import { HttpException } from './http-exception';
3
+ export declare abstract class ExceptionFilter {
4
+ abstract catch(exception: HttpException, host: ArgumentsHost): Promise<any>;
5
+ }
6
+ //# sourceMappingURL=exception-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception-filter.d.ts","sourceRoot":"","sources":["../../src/exceptions/exception-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,8BAAsB,eAAe;IACnC,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC;CAC5E"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExceptionFilter = void 0;
4
+ class ExceptionFilter {
5
+ }
6
+ exports.ExceptionFilter = ExceptionFilter;
7
+ //# sourceMappingURL=exception-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception-filter.js","sourceRoot":"","sources":["../../src/exceptions/exception-filter.ts"],"names":[],"mappings":";;;AAGA,MAAsB,eAAe;CAEpC;AAFD,0CAEC"}
@@ -1,3 +1,6 @@
1
1
  export * from './http-exception';
2
2
  export * from './api-exception';
3
+ export * from './exception-filter';
4
+ export * from './base-exception-filter';
5
+ export * from './decorators';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA"}
@@ -16,4 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./http-exception"), exports);
18
18
  __exportStar(require("./api-exception"), exports);
19
+ __exportStar(require("./exception-filter"), exports);
20
+ __exportStar(require("./base-exception-filter"), exports);
21
+ __exportStar(require("./decorators"), exports);
19
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,kDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,kDAA+B;AAC/B,qDAAkC;AAClC,0DAAuC;AACvC,+CAA4B"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  import 'reflect-metadata';
2
+ export * from './constants';
2
3
  export * from './utils/apply-decorators';
4
+ export * from './context';
3
5
  export * from './exceptions';
6
+ export * from './interceptor';
7
+ export * from './logger';
4
8
  export * from './controllers';
5
9
  export * from './dependency-injection';
6
10
  export * from './modules';
7
11
  export * from './server';
8
12
  export { REQUEST } from './services/request';
13
+ export { APP_INTERCEPTOR } from './services/interceptor';
14
+ export { APP_FILTER } from './services/filters';
15
+ export { FetchModuleOptions, HttpService } from './services/http-service';
9
16
  //# 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,0BAA0B,CAAA;AACxC,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,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,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"}
package/dist/index.js CHANGED
@@ -16,10 +16,14 @@ 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.REQUEST = void 0;
19
+ exports.HttpService = exports.APP_FILTER = exports.APP_INTERCEPTOR = exports.REQUEST = void 0;
20
20
  require("reflect-metadata");
21
+ __exportStar(require("./constants"), exports);
21
22
  __exportStar(require("./utils/apply-decorators"), exports);
23
+ __exportStar(require("./context"), exports);
22
24
  __exportStar(require("./exceptions"), exports);
25
+ __exportStar(require("./interceptor"), exports);
26
+ __exportStar(require("./logger"), exports);
23
27
  __exportStar(require("./controllers"), exports);
24
28
  __exportStar(require("./dependency-injection"), exports);
25
29
  __exportStar(require("./modules"), exports);
@@ -27,4 +31,10 @@ __exportStar(require("./server"), exports);
27
31
  // Services
28
32
  var request_1 = require("./services/request");
29
33
  Object.defineProperty(exports, "REQUEST", { enumerable: true, get: function () { return request_1.REQUEST; } });
34
+ var interceptor_1 = require("./services/interceptor");
35
+ Object.defineProperty(exports, "APP_INTERCEPTOR", { enumerable: true, get: function () { return interceptor_1.APP_INTERCEPTOR; } });
36
+ var filters_1 = require("./services/filters");
37
+ Object.defineProperty(exports, "APP_FILTER", { enumerable: true, get: function () { return filters_1.APP_FILTER; } });
38
+ var http_service_1 = require("./services/http-service");
39
+ Object.defineProperty(exports, "HttpService", { enumerable: true, get: function () { return http_service_1.HttpService; } });
30
40
  //# 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,2DAAwC;AACxC,+CAA4B;AAC5B,gDAA6B;AAC7B,yDAAsC;AACtC,4CAAyB;AACzB,2CAAwB;AAExB,WAAW;AACX,8CAA4C;AAAnC,kGAAA,OAAO,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,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"}
@@ -0,0 +1,4 @@
1
+ export type CallHandler = {
2
+ handle: () => Promise<any>;
3
+ };
4
+ //# sourceMappingURL=call-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-handler.d.ts","sourceRoot":"","sources":["../../src/interceptor/call-handler.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;CAC3B,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=call-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-handler.js","sourceRoot":"","sources":["../../src/interceptor/call-handler.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { UseInterceptors } from './use-interceptor-decorator';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interceptor/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UseInterceptors = void 0;
4
+ var use_interceptor_decorator_1 = require("./use-interceptor-decorator");
5
+ Object.defineProperty(exports, "UseInterceptors", { enumerable: true, get: function () { return use_interceptor_decorator_1.UseInterceptors; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interceptor/decorators/index.ts"],"names":[],"mappings":";;;AAAA,yEAA6D;AAApD,4HAAA,eAAe,OAAA"}
@@ -0,0 +1,8 @@
1
+ import { Interceptor } from '../interceptor';
2
+ import { ExecutionContext } from '../../context/execution-context';
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[];
7
+ export declare function UseInterceptors(...interceptors: (Interceptor | Class<Interceptor>)[]): ClassDecorator;
8
+ //# sourceMappingURL=use-interceptor-decorator.d.ts.map
@@ -0,0 +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"}