@lerianstudio/sindarian-server 1.0.0-beta.1

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 (134) hide show
  1. package/README.md +0 -0
  2. package/dist/constants/http-methods.d.ts +8 -0
  3. package/dist/constants/http-methods.d.ts.map +1 -0
  4. package/dist/constants/http-methods.js +12 -0
  5. package/dist/constants/http-methods.js.map +1 -0
  6. package/dist/constants/http-status.d.ts +57 -0
  7. package/dist/constants/http-status.d.ts.map +1 -0
  8. package/dist/constants/http-status.js +61 -0
  9. package/dist/constants/http-status.js.map +1 -0
  10. package/dist/constants/index.d.ts +3 -0
  11. package/dist/constants/index.d.ts.map +1 -0
  12. package/dist/constants/index.js +19 -0
  13. package/dist/constants/index.js.map +1 -0
  14. package/dist/constants/keys.d.ts +17 -0
  15. package/dist/constants/keys.d.ts.map +1 -0
  16. package/dist/constants/keys.js +20 -0
  17. package/dist/constants/keys.js.map +1 -0
  18. package/dist/controllers/base-controller.d.ts +5 -0
  19. package/dist/controllers/base-controller.d.ts.map +1 -0
  20. package/dist/controllers/base-controller.js +22 -0
  21. package/dist/controllers/base-controller.js.map +1 -0
  22. package/dist/controllers/decorators/body-decorator.d.ts +25 -0
  23. package/dist/controllers/decorators/body-decorator.d.ts.map +1 -0
  24. package/dist/controllers/decorators/body-decorator.js +65 -0
  25. package/dist/controllers/decorators/body-decorator.js.map +1 -0
  26. package/dist/controllers/decorators/controller-decorator.d.ts +18 -0
  27. package/dist/controllers/decorators/controller-decorator.d.ts.map +1 -0
  28. package/dist/controllers/decorators/controller-decorator.js +89 -0
  29. package/dist/controllers/decorators/controller-decorator.js.map +1 -0
  30. package/dist/controllers/decorators/index.d.ts +7 -0
  31. package/dist/controllers/decorators/index.d.ts.map +1 -0
  32. package/dist/controllers/decorators/index.js +20 -0
  33. package/dist/controllers/decorators/index.js.map +1 -0
  34. package/dist/controllers/decorators/param-decorator.d.ts +21 -0
  35. package/dist/controllers/decorators/param-decorator.d.ts.map +1 -0
  36. package/dist/controllers/decorators/param-decorator.js +56 -0
  37. package/dist/controllers/decorators/param-decorator.js.map +1 -0
  38. package/dist/controllers/decorators/query-decorator.d.ts +26 -0
  39. package/dist/controllers/decorators/query-decorator.d.ts.map +1 -0
  40. package/dist/controllers/decorators/query-decorator.js +62 -0
  41. package/dist/controllers/decorators/query-decorator.js.map +1 -0
  42. package/dist/controllers/decorators/request-decorator.d.ts +24 -0
  43. package/dist/controllers/decorators/request-decorator.d.ts.map +1 -0
  44. package/dist/controllers/decorators/request-decorator.js +39 -0
  45. package/dist/controllers/decorators/request-decorator.js.map +1 -0
  46. package/dist/controllers/decorators/route-decorator.d.ts +43 -0
  47. package/dist/controllers/decorators/route-decorator.d.ts.map +1 -0
  48. package/dist/controllers/decorators/route-decorator.js +91 -0
  49. package/dist/controllers/decorators/route-decorator.js.map +1 -0
  50. package/dist/controllers/index.d.ts +3 -0
  51. package/dist/controllers/index.d.ts.map +1 -0
  52. package/dist/controllers/index.js +19 -0
  53. package/dist/controllers/index.js.map +1 -0
  54. package/dist/dependency-injection/container.d.ts +33 -0
  55. package/dist/dependency-injection/container.d.ts.map +1 -0
  56. package/dist/dependency-injection/container.js +59 -0
  57. package/dist/dependency-injection/container.js.map +1 -0
  58. package/dist/dependency-injection/index.d.ts +3 -0
  59. package/dist/dependency-injection/index.d.ts.map +1 -0
  60. package/dist/dependency-injection/index.js +22 -0
  61. package/dist/dependency-injection/index.js.map +1 -0
  62. package/dist/exceptions/api-exception.d.ts +38 -0
  63. package/dist/exceptions/api-exception.d.ts.map +1 -0
  64. package/dist/exceptions/api-exception.js +70 -0
  65. package/dist/exceptions/api-exception.js.map +1 -0
  66. package/dist/exceptions/http-exception.d.ts +16 -0
  67. package/dist/exceptions/http-exception.d.ts.map +1 -0
  68. package/dist/exceptions/http-exception.js +27 -0
  69. package/dist/exceptions/http-exception.js.map +1 -0
  70. package/dist/exceptions/index.d.ts +3 -0
  71. package/dist/exceptions/index.d.ts.map +1 -0
  72. package/dist/exceptions/index.js +19 -0
  73. package/dist/exceptions/index.js.map +1 -0
  74. package/dist/index.d.ts +9 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +30 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/interceptor/decorators/use-interceptor.d.ts +3 -0
  79. package/dist/interceptor/decorators/use-interceptor.d.ts.map +1 -0
  80. package/dist/interceptor/decorators/use-interceptor.js +9 -0
  81. package/dist/interceptor/decorators/use-interceptor.js.map +1 -0
  82. package/dist/interceptor/interceptor.d.ts +8 -0
  83. package/dist/interceptor/interceptor.d.ts.map +1 -0
  84. package/dist/interceptor/interceptor.js +7 -0
  85. package/dist/interceptor/interceptor.js.map +1 -0
  86. package/dist/modules/index.d.ts +2 -0
  87. package/dist/modules/index.d.ts.map +1 -0
  88. package/dist/modules/index.js +18 -0
  89. package/dist/modules/index.js.map +1 -0
  90. package/dist/modules/module-decorator.d.ts +22 -0
  91. package/dist/modules/module-decorator.d.ts.map +1 -0
  92. package/dist/modules/module-decorator.js +86 -0
  93. package/dist/modules/module-decorator.js.map +1 -0
  94. package/dist/server/index.d.ts +2 -0
  95. package/dist/server/index.d.ts.map +1 -0
  96. package/dist/server/index.js +18 -0
  97. package/dist/server/index.js.map +1 -0
  98. package/dist/server/server-factory.d.ts +47 -0
  99. package/dist/server/server-factory.d.ts.map +1 -0
  100. package/dist/server/server-factory.js +131 -0
  101. package/dist/server/server-factory.js.map +1 -0
  102. package/dist/services/request.d.ts +7 -0
  103. package/dist/services/request.d.ts.map +1 -0
  104. package/dist/services/request.js +32 -0
  105. package/dist/services/request.js.map +1 -0
  106. package/dist/types/class.d.ts +4 -0
  107. package/dist/types/class.d.ts.map +1 -0
  108. package/dist/types/class.js +3 -0
  109. package/dist/types/class.js.map +1 -0
  110. package/dist/utils/apply-decorators.d.ts +13 -0
  111. package/dist/utils/apply-decorators.d.ts.map +1 -0
  112. package/dist/utils/apply-decorators.js +28 -0
  113. package/dist/utils/apply-decorators.js.map +1 -0
  114. package/dist/utils/class/get-class-methods.d.ts +7 -0
  115. package/dist/utils/class/get-class-methods.d.ts.map +1 -0
  116. package/dist/utils/class/get-class-methods.js +14 -0
  117. package/dist/utils/class/get-class-methods.js.map +1 -0
  118. package/dist/utils/nextjs/get-next-arguments.d.ts +3 -0
  119. package/dist/utils/nextjs/get-next-arguments.d.ts.map +1 -0
  120. package/dist/utils/nextjs/get-next-arguments.js +21 -0
  121. package/dist/utils/nextjs/get-next-arguments.js.map +1 -0
  122. package/dist/utils/url/index.d.ts +1 -0
  123. package/dist/utils/url/index.d.ts.map +1 -0
  124. package/dist/utils/url/index.js +2 -0
  125. package/dist/utils/url/index.js.map +1 -0
  126. package/dist/utils/url/url-join.d.ts +7 -0
  127. package/dist/utils/url/url-join.d.ts.map +1 -0
  128. package/dist/utils/url/url-join.js +17 -0
  129. package/dist/utils/url/url-join.js.map +1 -0
  130. package/dist/utils/url/url-match.d.ts +8 -0
  131. package/dist/utils/url/url-match.d.ts.map +1 -0
  132. package/dist/utils/url/url-match.js +15 -0
  133. package/dist/utils/url/url-match.js.map +1 -0
  134. package/package.json +46 -0
package/README.md ADDED
File without changes
@@ -0,0 +1,8 @@
1
+ export declare enum HttpMethods {
2
+ GET = "GET",
3
+ POST = "POST",
4
+ PUT = "PUT",
5
+ DELETE = "DELETE",
6
+ PATCH = "PATCH"
7
+ }
8
+ //# sourceMappingURL=http-methods.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-methods.d.ts","sourceRoot":"","sources":["../../src/constants/http-methods.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpMethods = void 0;
4
+ var HttpMethods;
5
+ (function (HttpMethods) {
6
+ HttpMethods["GET"] = "GET";
7
+ HttpMethods["POST"] = "POST";
8
+ HttpMethods["PUT"] = "PUT";
9
+ HttpMethods["DELETE"] = "DELETE";
10
+ HttpMethods["PATCH"] = "PATCH";
11
+ })(HttpMethods || (exports.HttpMethods = HttpMethods = {}));
12
+ //# sourceMappingURL=http-methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-methods.js","sourceRoot":"","sources":["../../src/constants/http-methods.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,0BAAW,CAAA;IACX,4BAAa,CAAA;IACb,0BAAW,CAAA;IACX,gCAAiB,CAAA;IACjB,8BAAe,CAAA;AACjB,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Enum for HTTP status codes.
3
+ *
4
+ * From NestJS documentation:
5
+ * https://github.com/nestjs/nest/blob/master/packages/common/enums/http-status.enum.ts
6
+ */
7
+ export declare enum HttpStatus {
8
+ CONTINUE = 100,
9
+ SWITCHING_PROTOCOLS = 101,
10
+ PROCESSING = 102,
11
+ EARLYHINTS = 103,
12
+ OK = 200,
13
+ CREATED = 201,
14
+ ACCEPTED = 202,
15
+ NON_AUTHORITATIVE_INFORMATION = 203,
16
+ NO_CONTENT = 204,
17
+ RESET_CONTENT = 205,
18
+ PARTIAL_CONTENT = 206,
19
+ AMBIGUOUS = 300,
20
+ MOVED_PERMANENTLY = 301,
21
+ FOUND = 302,
22
+ SEE_OTHER = 303,
23
+ NOT_MODIFIED = 304,
24
+ TEMPORARY_REDIRECT = 307,
25
+ PERMANENT_REDIRECT = 308,
26
+ BAD_REQUEST = 400,
27
+ UNAUTHORIZED = 401,
28
+ PAYMENT_REQUIRED = 402,
29
+ FORBIDDEN = 403,
30
+ NOT_FOUND = 404,
31
+ METHOD_NOT_ALLOWED = 405,
32
+ NOT_ACCEPTABLE = 406,
33
+ PROXY_AUTHENTICATION_REQUIRED = 407,
34
+ REQUEST_TIMEOUT = 408,
35
+ CONFLICT = 409,
36
+ GONE = 410,
37
+ LENGTH_REQUIRED = 411,
38
+ PRECONDITION_FAILED = 412,
39
+ PAYLOAD_TOO_LARGE = 413,
40
+ URI_TOO_LONG = 414,
41
+ UNSUPPORTED_MEDIA_TYPE = 415,
42
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
43
+ EXPECTATION_FAILED = 417,
44
+ I_AM_A_TEAPOT = 418,
45
+ MISDIRECTED = 421,
46
+ UNPROCESSABLE_ENTITY = 422,
47
+ FAILED_DEPENDENCY = 424,
48
+ PRECONDITION_REQUIRED = 428,
49
+ TOO_MANY_REQUESTS = 429,
50
+ INTERNAL_SERVER_ERROR = 500,
51
+ NOT_IMPLEMENTED = 501,
52
+ BAD_GATEWAY = 502,
53
+ SERVICE_UNAVAILABLE = 503,
54
+ GATEWAY_TIMEOUT = 504,
55
+ HTTP_VERSION_NOT_SUPPORTED = 505
56
+ }
57
+ //# sourceMappingURL=http-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-status.d.ts","sourceRoot":"","sources":["../../src/constants/http-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,UAAU;IACpB,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,UAAU,MAAM;IAChB,UAAU,MAAM;IAChB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,QAAQ,MAAM;IACd,6BAA6B,MAAM;IACnC,UAAU,MAAM;IAChB,aAAa,MAAM;IACnB,eAAe,MAAM;IACrB,SAAS,MAAM;IACf,iBAAiB,MAAM;IACvB,KAAK,MAAM;IACX,SAAS,MAAM;IACf,YAAY,MAAM;IAClB,kBAAkB,MAAM;IACxB,kBAAkB,MAAM;IACxB,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,gBAAgB,MAAM;IACtB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,kBAAkB,MAAM;IACxB,cAAc,MAAM;IACpB,6BAA6B,MAAM;IACnC,eAAe,MAAM;IACrB,QAAQ,MAAM;IACd,IAAI,MAAM;IACV,eAAe,MAAM;IACrB,mBAAmB,MAAM;IACzB,iBAAiB,MAAM;IACvB,YAAY,MAAM;IAClB,sBAAsB,MAAM;IAC5B,+BAA+B,MAAM;IACrC,kBAAkB,MAAM;IACxB,aAAa,MAAM;IACnB,WAAW,MAAM;IACjB,oBAAoB,MAAM;IAC1B,iBAAiB,MAAM;IACvB,qBAAqB,MAAM;IAC3B,iBAAiB,MAAM;IACvB,qBAAqB,MAAM;IAC3B,eAAe,MAAM;IACrB,WAAW,MAAM;IACjB,mBAAmB,MAAM;IACzB,eAAe,MAAM;IACrB,0BAA0B,MAAM;CACjC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpStatus = void 0;
4
+ /**
5
+ * Enum for HTTP status codes.
6
+ *
7
+ * From NestJS documentation:
8
+ * https://github.com/nestjs/nest/blob/master/packages/common/enums/http-status.enum.ts
9
+ */
10
+ var HttpStatus;
11
+ (function (HttpStatus) {
12
+ HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
13
+ HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
14
+ HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
15
+ HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
16
+ HttpStatus[HttpStatus["OK"] = 200] = "OK";
17
+ HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
18
+ HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
19
+ HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
20
+ HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
21
+ HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
22
+ HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
23
+ HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
24
+ HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
25
+ HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
26
+ HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
27
+ HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
28
+ HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
29
+ HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
30
+ HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
31
+ HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
32
+ HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
33
+ HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
34
+ HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
35
+ HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
36
+ HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
37
+ HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
38
+ HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
39
+ HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
40
+ HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
41
+ HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
42
+ HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
43
+ HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
44
+ HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
45
+ HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
46
+ HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
47
+ HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
48
+ HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
49
+ HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
50
+ HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
51
+ HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
52
+ HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
53
+ HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
54
+ HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
55
+ HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
56
+ HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
57
+ HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
58
+ HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
59
+ HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
60
+ })(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
61
+ //# sourceMappingURL=http-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-status.js","sourceRoot":"","sources":["../../src/constants/http-status.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,IAAY,UAiDX;AAjDD,WAAY,UAAU;IACpB,qDAAc,CAAA;IACd,2EAAyB,CAAA;IACzB,yDAAgB,CAAA;IAChB,yDAAgB,CAAA;IAChB,yCAAQ,CAAA;IACR,mDAAa,CAAA;IACb,qDAAc,CAAA;IACd,+FAAmC,CAAA;IACnC,yDAAgB,CAAA;IAChB,+DAAmB,CAAA;IACnB,mEAAqB,CAAA;IACrB,uDAAe,CAAA;IACf,uEAAuB,CAAA;IACvB,+CAAW,CAAA;IACX,uDAAe,CAAA;IACf,6DAAkB,CAAA;IAClB,yEAAwB,CAAA;IACxB,yEAAwB,CAAA;IACxB,2DAAiB,CAAA;IACjB,6DAAkB,CAAA;IAClB,qEAAsB,CAAA;IACtB,uDAAe,CAAA;IACf,uDAAe,CAAA;IACf,yEAAwB,CAAA;IACxB,iEAAoB,CAAA;IACpB,+FAAmC,CAAA;IACnC,mEAAqB,CAAA;IACrB,qDAAc,CAAA;IACd,6CAAU,CAAA;IACV,mEAAqB,CAAA;IACrB,2EAAyB,CAAA;IACzB,uEAAuB,CAAA;IACvB,6DAAkB,CAAA;IAClB,iFAA4B,CAAA;IAC5B,mGAAqC,CAAA;IACrC,yEAAwB,CAAA;IACxB,+DAAmB,CAAA;IACnB,2DAAiB,CAAA;IACjB,6EAA0B,CAAA;IAC1B,uEAAuB,CAAA;IACvB,+EAA2B,CAAA;IAC3B,uEAAuB,CAAA;IACvB,+EAA2B,CAAA;IAC3B,mEAAqB,CAAA;IACrB,2DAAiB,CAAA;IACjB,2EAAyB,CAAA;IACzB,mEAAqB,CAAA;IACrB,yFAAgC,CAAA;AAClC,CAAC,EAjDW,UAAU,0BAAV,UAAU,QAiDrB"}
@@ -0,0 +1,3 @@
1
+ export * from './http-status';
2
+ export * from './http-methods';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./http-status"), exports);
18
+ __exportStar(require("./http-methods"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,iDAA8B"}
@@ -0,0 +1,17 @@
1
+ export declare const MODULE_KEY: unique symbol;
2
+ export declare const CONTROLLER_KEY: unique symbol;
3
+ export declare const ROUTE_KEY: unique symbol;
4
+ export declare const GET_KEY: unique symbol;
5
+ export declare const POST_KEY: unique symbol;
6
+ export declare const PUT_KEY: unique symbol;
7
+ export declare const PATCH_KEY: unique symbol;
8
+ export declare const DELETE_KEY: unique symbol;
9
+ export declare const BODY_KEY: unique symbol;
10
+ export declare const REQUEST_KEY: unique symbol;
11
+ export declare const PARAM_KEY: unique symbol;
12
+ export declare const QUERY_KEY: unique symbol;
13
+ export declare const IMPORTS_PROPERTY = "__imports__";
14
+ export declare const MODULE_PROPERTY = "__module__";
15
+ export declare const PROVIDERS_PROPERTY = "__providers__";
16
+ export declare const CONTROLLERS_PROPERTY = "__controllers__";
17
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/constants/keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,eAAmB,CAAA;AAC1C,eAAO,MAAM,cAAc,eAAuB,CAAA;AAElD,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,OAAO,eAAgB,CAAA;AACpC,eAAO,MAAM,QAAQ,eAAiB,CAAA;AACtC,eAAO,MAAM,OAAO,eAAgB,CAAA;AACpC,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,UAAU,eAAmB,CAAA;AAE1C,eAAO,MAAM,QAAQ,eAAiB,CAAA;AACtC,eAAO,MAAM,WAAW,eAAoB,CAAA;AAC5C,eAAO,MAAM,SAAS,eAAkB,CAAA;AACxC,eAAO,MAAM,SAAS,eAAkB,CAAA;AAExC,eAAO,MAAM,gBAAgB,gBAAgB,CAAA;AAC7C,eAAO,MAAM,eAAe,eAAe,CAAA;AAC3C,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AACjD,eAAO,MAAM,oBAAoB,oBAAoB,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONTROLLERS_PROPERTY = exports.PROVIDERS_PROPERTY = exports.MODULE_PROPERTY = exports.IMPORTS_PROPERTY = exports.QUERY_KEY = exports.PARAM_KEY = exports.REQUEST_KEY = exports.BODY_KEY = exports.DELETE_KEY = exports.PATCH_KEY = exports.PUT_KEY = exports.POST_KEY = exports.GET_KEY = exports.ROUTE_KEY = exports.CONTROLLER_KEY = exports.MODULE_KEY = void 0;
4
+ exports.MODULE_KEY = Symbol('module');
5
+ exports.CONTROLLER_KEY = Symbol('controller');
6
+ exports.ROUTE_KEY = Symbol('route');
7
+ exports.GET_KEY = Symbol('get');
8
+ exports.POST_KEY = Symbol('post');
9
+ exports.PUT_KEY = Symbol('put');
10
+ exports.PATCH_KEY = Symbol('patch');
11
+ exports.DELETE_KEY = Symbol('delete');
12
+ exports.BODY_KEY = Symbol('body');
13
+ exports.REQUEST_KEY = Symbol('request');
14
+ exports.PARAM_KEY = Symbol('param');
15
+ exports.QUERY_KEY = Symbol('query');
16
+ exports.IMPORTS_PROPERTY = '__imports__';
17
+ exports.MODULE_PROPERTY = '__module__';
18
+ exports.PROVIDERS_PROPERTY = '__providers__';
19
+ exports.CONTROLLERS_PROPERTY = '__controllers__';
20
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/constants/keys.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC7B,QAAA,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;AAErC,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3B,QAAA,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;AACvB,QAAA,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;AACzB,QAAA,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;AACvB,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3B,QAAA,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAE7B,QAAA,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;AACzB,QAAA,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AAC/B,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3B,QAAA,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;AAE3B,QAAA,gBAAgB,GAAG,aAAa,CAAA;AAChC,QAAA,eAAe,GAAG,YAAY,CAAA;AAC9B,QAAA,kBAAkB,GAAG,eAAe,CAAA;AACpC,QAAA,oBAAoB,GAAG,iBAAiB,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { LoggerAggregator } from '@lerianstudio/lib-logs';
2
+ export declare abstract class BaseController {
3
+ protected readonly logger: LoggerAggregator;
4
+ }
5
+ //# sourceMappingURL=base-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-controller.d.ts","sourceRoot":"","sources":["../../src/controllers/base-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,8BAAsB,cAAc;IAElC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAG,gBAAgB,CAAA;CAC7C"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BaseController = void 0;
13
+ const lib_logs_1 = require("@lerianstudio/lib-logs");
14
+ const inversify_1 = require("inversify");
15
+ class BaseController {
16
+ }
17
+ exports.BaseController = BaseController;
18
+ __decorate([
19
+ (0, inversify_1.inject)(lib_logs_1.LoggerAggregator),
20
+ __metadata("design:type", lib_logs_1.LoggerAggregator)
21
+ ], BaseController.prototype, "logger", void 0);
22
+ //# sourceMappingURL=base-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-controller.js","sourceRoot":"","sources":["../../src/controllers/base-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAyD;AACzD,yCAAkC;AAElC,MAAsB,cAAc;CAGnC;AAHD,wCAGC;AADoB;IADlB,IAAA,kBAAM,EAAC,2BAAgB,CAAC;8BACG,2BAAgB;8CAAA"}
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ 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
+ parameterIndex: number;
17
+ } | null>;
18
+ /**
19
+ * Decorator to validate the body of the request.
20
+ *
21
+ * @param schema - The Zod schema to validate the body against.
22
+ * @returns A decorator function that can be used to decorate a controller method.
23
+ */
24
+ export declare function Body(schema?: z.ZodSchema | (() => z.ZodSchema)): (target: object, propertyKey: string | symbol, propertyIndex: number) => void;
25
+ //# sourceMappingURL=body-decorator.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bodyDecoratorHandler = bodyDecoratorHandler;
4
+ exports.Body = Body;
5
+ const keys_1 = require("../../constants/keys");
6
+ const get_next_arguments_1 = require("../../utils/nextjs/get-next-arguments");
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();
24
+ }
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) {
31
+ return {
32
+ parameter: body,
33
+ parameterIndex: metadata.propertyIndex
34
+ };
35
+ }
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
+ };
47
+ }
48
+ return null;
49
+ }
50
+ /**
51
+ * Decorator to validate the body of the request.
52
+ *
53
+ * @param schema - The Zod schema to validate the body against.
54
+ * @returns A decorator function that can be used to decorate a controller method.
55
+ */
56
+ function Body(schema) {
57
+ 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);
63
+ };
64
+ }
65
+ //# sourceMappingURL=body-decorator.js.map
@@ -0,0 +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"}
@@ -0,0 +1,18 @@
1
+ import { HttpMethods } from '../../constants/http-methods';
2
+ export type ErrorResponse = {
3
+ message: string;
4
+ status: number;
5
+ };
6
+ export type ControllerMetadata = {
7
+ methodName: string;
8
+ method: HttpMethods;
9
+ path: string;
10
+ };
11
+ export declare function controllerHandler(target: Function): ControllerMetadata[];
12
+ /**
13
+ * A class decorator that wraps all methods in the class with error handling.
14
+ *
15
+ * @returns
16
+ */
17
+ export declare function Controller(path: string): ClassDecorator;
18
+ //# sourceMappingURL=controller-decorator.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.controllerHandler = controllerHandler;
4
+ exports.Controller = Controller;
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
+ const keys_1 = require("../../constants/keys");
10
+ const route_decorator_1 = require("./route-decorator");
11
+ const apply_decorators_1 = require("../../utils/apply-decorators");
12
+ const get_class_methods_1 = require("../../utils/class/get-class-methods");
13
+ 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
+ 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
+ });
55
+ }
56
+ }
57
+ return routes;
58
+ }
59
+ /**
60
+ * A class decorator that wraps all methods in the class with error handling.
61
+ *
62
+ * @returns
63
+ */
64
+ function Controller(path) {
65
+ return (0, apply_decorators_1.applyDecorators)((0, inversify_1.injectable)(), (0, inversify_1.injectFromBase)({
66
+ extendProperties: true
67
+ }), function (target) {
68
+ 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
+ });
88
+ }
89
+ //# sourceMappingURL=controller-decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/controller-decorator.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ export { Controller } from './controller-decorator';
2
+ export { Param } from './param-decorator';
3
+ export { Query } from './query-decorator';
4
+ export { Request } from './request-decorator';
5
+ export { Body } from './body-decorator';
6
+ export { Get, Post, Put, Patch, Delete } from './route-decorator';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.Body = exports.Request = exports.Query = exports.Param = exports.Controller = void 0;
4
+ var controller_decorator_1 = require("./controller-decorator");
5
+ Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return controller_decorator_1.Controller; } });
6
+ var param_decorator_1 = require("./param-decorator");
7
+ Object.defineProperty(exports, "Param", { enumerable: true, get: function () { return param_decorator_1.Param; } });
8
+ var query_decorator_1 = require("./query-decorator");
9
+ Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return query_decorator_1.Query; } });
10
+ var request_decorator_1 = require("./request-decorator");
11
+ Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return request_decorator_1.Request; } });
12
+ var body_decorator_1 = require("./body-decorator");
13
+ Object.defineProperty(exports, "Body", { enumerable: true, get: function () { return body_decorator_1.Body; } });
14
+ var route_decorator_1 = require("./route-decorator");
15
+ Object.defineProperty(exports, "Get", { enumerable: true, get: function () { return route_decorator_1.Get; } });
16
+ Object.defineProperty(exports, "Post", { enumerable: true, get: function () { return route_decorator_1.Post; } });
17
+ Object.defineProperty(exports, "Put", { enumerable: true, get: function () { return route_decorator_1.Put; } });
18
+ Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return route_decorator_1.Patch; } });
19
+ Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return route_decorator_1.Delete; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controllers/decorators/index.ts"],"names":[],"mappings":";;;AAAA,+DAAmD;AAA1C,kHAAA,UAAU,OAAA;AACnB,qDAAyC;AAAhC,wGAAA,KAAK,OAAA;AACd,qDAAyC;AAAhC,wGAAA,KAAK,OAAA;AACd,yDAA6C;AAApC,4GAAA,OAAO,OAAA;AAChB,mDAAuC;AAA9B,sGAAA,IAAI,OAAA;AACb,qDAAiE;AAAxD,sGAAA,GAAG,OAAA;AAAE,uGAAA,IAAI,OAAA;AAAE,sGAAA,GAAG,OAAA;AAAE,wGAAA,KAAK,OAAA;AAAE,yGAAA,MAAM,OAAA"}
@@ -0,0 +1,21 @@
1
+ export type ParamMetadata = {
2
+ name: string;
3
+ parameterIndex: number;
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>;
14
+ /**
15
+ * Decorator to validate the param of the request.
16
+ *
17
+ * @param name - The name of the param.
18
+ * @returns A decorator function that can be used to decorate a controller method.
19
+ */
20
+ export declare function Param(name: string): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
21
+ //# sourceMappingURL=param-decorator.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paramDecoratorHandler = paramDecoratorHandler;
4
+ exports.Param = Param;
5
+ const keys_1 = require("../../constants/keys");
6
+ const api_exception_1 = require("../../exceptions/api-exception");
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`);
24
+ }
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`);
31
+ }
32
+ return {
33
+ parameter: value,
34
+ parameterIndex: metadata.parameterIndex
35
+ };
36
+ });
37
+ }
38
+ return null;
39
+ }
40
+ /**
41
+ * Decorator to validate the param of the request.
42
+ *
43
+ * @param name - The name of the param.
44
+ * @returns A decorator function that can be used to decorate a controller method.
45
+ */
46
+ function Param(name) {
47
+ return function (target, propertyKey, parameterIndex) {
48
+ const existingParams = Reflect.getOwnMetadata(keys_1.PARAM_KEY, target, propertyKey) || [];
49
+ existingParams.push({
50
+ name,
51
+ parameterIndex
52
+ });
53
+ Reflect.defineMetadata(keys_1.PARAM_KEY, existingParams, target, propertyKey);
54
+ };
55
+ }
56
+ //# sourceMappingURL=param-decorator.js.map
@@ -0,0 +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"}