@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
@@ -0,0 +1,26 @@
1
+ import z from 'zod';
2
+ export type QueryMetadata = {
3
+ propertyKey: string | symbol;
4
+ parameterIndex: number;
5
+ schema?: () => z.ZodSchema;
6
+ };
7
+ /**
8
+ * Handler to validate the query of the request.
9
+ *
10
+ * @param target - The target object.
11
+ * @param propertyKey - The property key.
12
+ * @param args - The arguments.
13
+ * @returns The parameter and parameter index.
14
+ */
15
+ export declare function queryDecoratorHandler(target: object, propertyKey: string | symbol, args: any[]): {
16
+ parameter: {};
17
+ parameterIndex: number;
18
+ } | null;
19
+ /**
20
+ * Decorator to validate the query of the request.
21
+ *
22
+ * @param schema - The Zod schema to validate the query against.
23
+ * @returns A decorator function that can be used to decorate a controller method.
24
+ */
25
+ export declare function Query(schema?: z.ZodSchema | (() => z.ZodSchema)): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
26
+ //# sourceMappingURL=query-decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-decorator.d.ts","sourceRoot":"","sources":["../../../src/controllers/decorators/query-decorator.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAKnB,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,IAAI,EAAE,GAAG,EAAE;;;SA0CZ;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,IAE5D,QAAQ,MAAM,EACd,aAAa,MAAM,GAAG,MAAM,EAC5B,gBAAgB,MAAM,UAkBzB"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queryDecoratorHandler = queryDecoratorHandler;
4
+ exports.Query = Query;
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 query of the request.
10
+ *
11
+ * @param target - The target object.
12
+ * @param propertyKey - The property key.
13
+ * @param args - The arguments.
14
+ * @returns The parameter and parameter index.
15
+ */
16
+ function queryDecoratorHandler(target, propertyKey, args) {
17
+ const metadata = Reflect.getOwnMetadata(keys_1.QUERY_KEY, target, propertyKey);
18
+ // If the metadata is found, validate the query.
19
+ if (metadata) {
20
+ const request = (0, get_next_arguments_1.getNextRequestArgument)(args);
21
+ const { searchParams } = new URL(request.url);
22
+ const query = Object.fromEntries(searchParams.entries());
23
+ // If the schema is not provided, return the query.
24
+ if (!metadata.schema) {
25
+ return {
26
+ parameter: query,
27
+ parameterIndex: metadata.parameterIndex
28
+ };
29
+ }
30
+ const resolvedSchema = metadata.schema?.();
31
+ const parsedQuery = resolvedSchema?.safeParse(query);
32
+ // If the query is not valid, throw a validation error.
33
+ if (parsedQuery && !parsedQuery.success) {
34
+ throw new api_exception_1.ValidationApiException(`Invalid query parameters: ${JSON.stringify(parsedQuery.error.flatten().fieldErrors)}`);
35
+ }
36
+ return {
37
+ parameter: parsedQuery?.data || query,
38
+ parameterIndex: metadata.parameterIndex
39
+ };
40
+ }
41
+ return null;
42
+ }
43
+ /**
44
+ * Decorator to validate the query of the request.
45
+ *
46
+ * @param schema - The Zod schema to validate the query against.
47
+ * @returns A decorator function that can be used to decorate a controller method.
48
+ */
49
+ function Query(schema) {
50
+ return function (target, propertyKey, parameterIndex) {
51
+ // Wrap the schema in a function to prevent TypeScript from analyzing it during compilation
52
+ const lazySchema = schema
53
+ ? () => (typeof schema === 'function' ? schema() : schema)
54
+ : undefined;
55
+ Reflect.defineMetadata(keys_1.QUERY_KEY, {
56
+ propertyKey,
57
+ parameterIndex,
58
+ schema: lazySchema
59
+ }, target, propertyKey);
60
+ };
61
+ }
62
+ //# sourceMappingURL=query-decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-decorator.js","sourceRoot":"","sources":["../../../src/controllers/decorators/query-decorator.ts"],"names":[],"mappings":";;AAmBA,sDA6CC;AAQD,sBAsBC;AA7FD,2CAA4C;AAC5C,8DAAmE;AACnE,0EAA0E;AAQ1E;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,MAAc,EACd,WAA4B,EAC5B,IAAW;IAEX,MAAM,QAAQ,GAAkB,OAAO,CAAC,cAAc,CACpD,gBAAS,EACT,MAAM,EACN,WAAW,CACZ,CAAA;IAED,gDAAgD;IAChD,IAAI,QAAQ,EAAE,CAAC;QACb,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EACT;YACE,WAAW;YACX,cAAc;YACd,MAAM,EAAE,UAAU;SACnB,EACD,MAAM,EACN,WAAW,CACZ,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ export type RequestMetadata = {
2
+ propertyKey: string | symbol;
3
+ parameterIndex: number;
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;
17
+ /**
18
+ * Decorator to fetch the request object.
19
+ *
20
+ * @returns A decorator function that can be used to decorate a controller method.
21
+ */
22
+ export declare function Request(): (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
23
+ export { Request as Req };
24
+ //# sourceMappingURL=request-decorator.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requestDecoratorHandler = requestDecoratorHandler;
4
+ exports.Request = Request;
5
+ exports.Req = Request;
6
+ const keys_1 = require("../../constants/keys");
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
+ };
23
+ }
24
+ return null;
25
+ }
26
+ /**
27
+ * Decorator to fetch the request object.
28
+ *
29
+ * @returns A decorator function that can be used to decorate a controller method.
30
+ */
31
+ function Request() {
32
+ return function (target, propertyKey, parameterIndex) {
33
+ Reflect.defineMetadata(keys_1.REQUEST_KEY, {
34
+ propertyKey,
35
+ parameterIndex
36
+ }, target, propertyKey);
37
+ };
38
+ }
39
+ //# sourceMappingURL=request-decorator.js.map
@@ -0,0 +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"}
@@ -0,0 +1,43 @@
1
+ import { HttpMethods } from '../../constants/http-methods';
2
+ export type RouteMetadata = {
3
+ method: HttpMethods;
4
+ path: string;
5
+ };
6
+ export declare function routeHandler(target: object, propertyKey: string | symbol): RouteMetadata | undefined;
7
+ export declare function Route(method: HttpMethods, path: string): MethodDecorator;
8
+ /**
9
+ * Decorator to define a GET route.
10
+ *
11
+ * @param path - The path of the route.
12
+ * @returns A decorator function that can be used to decorate a controller method.
13
+ */
14
+ export declare function Get(path?: string): MethodDecorator;
15
+ /**
16
+ * Decorator to define a POST route.
17
+ *
18
+ * @param path - The path of the route.
19
+ * @returns A decorator function that can be used to decorate a controller method.
20
+ */
21
+ export declare function Post(path?: string): MethodDecorator;
22
+ /**
23
+ * Decorator to define a PUT route.
24
+ *
25
+ * @param path - The path of the route.
26
+ * @returns A decorator function that can be used to decorate a controller method.
27
+ */
28
+ export declare function Put(path?: string): MethodDecorator;
29
+ /**
30
+ * Decorator to define a PATCH route.
31
+ *
32
+ * @param path - The path of the route.
33
+ * @returns A decorator function that can be used to decorate a controller method.
34
+ */
35
+ export declare function Patch(path?: string): MethodDecorator;
36
+ /**
37
+ * Decorator to define a DELETE route.
38
+ *
39
+ * @param path - The path of the route.
40
+ * @returns A decorator function that can be used to decorate a controller method.
41
+ */
42
+ export declare function Delete(path?: string): MethodDecorator;
43
+ //# sourceMappingURL=route-decorator.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.routeHandler = routeHandler;
4
+ exports.Route = Route;
5
+ exports.Get = Get;
6
+ exports.Post = Post;
7
+ exports.Put = Put;
8
+ exports.Patch = Patch;
9
+ exports.Delete = Delete;
10
+ const server_1 = require("next/server");
11
+ const keys_1 = require("../../constants/keys");
12
+ const http_methods_1 = require("../../constants/http-methods");
13
+ const body_decorator_1 = require("./body-decorator");
14
+ const param_decorator_1 = require("./param-decorator");
15
+ 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);
19
+ }
20
+ function Route(method, path) {
21
+ return function (target, propertyKey, descriptor) {
22
+ Reflect.defineMetadata(keys_1.ROUTE_KEY, {
23
+ method: method,
24
+ path
25
+ }, target, propertyKey);
26
+ 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);
38
+ const response = await originalMethod.apply(this, args);
39
+ if (response instanceof server_1.NextResponse) {
40
+ return response;
41
+ }
42
+ return server_1.NextResponse.json(response);
43
+ };
44
+ };
45
+ }
46
+ /**
47
+ * Decorator to define a GET route.
48
+ *
49
+ * @param path - The path of the route.
50
+ * @returns A decorator function that can be used to decorate a controller method.
51
+ */
52
+ function Get(path = '') {
53
+ return Route(http_methods_1.HttpMethods.GET, path);
54
+ }
55
+ /**
56
+ * Decorator to define a POST route.
57
+ *
58
+ * @param path - The path of the route.
59
+ * @returns A decorator function that can be used to decorate a controller method.
60
+ */
61
+ function Post(path = '') {
62
+ return Route(http_methods_1.HttpMethods.POST, path);
63
+ }
64
+ /**
65
+ * Decorator to define a PUT route.
66
+ *
67
+ * @param path - The path of the route.
68
+ * @returns A decorator function that can be used to decorate a controller method.
69
+ */
70
+ function Put(path = '') {
71
+ return Route(http_methods_1.HttpMethods.PUT, path);
72
+ }
73
+ /**
74
+ * Decorator to define a PATCH route.
75
+ *
76
+ * @param path - The path of the route.
77
+ * @returns A decorator function that can be used to decorate a controller method.
78
+ */
79
+ function Patch(path = '') {
80
+ return Route(http_methods_1.HttpMethods.PATCH, path);
81
+ }
82
+ /**
83
+ * Decorator to define a DELETE route.
84
+ *
85
+ * @param path - The path of the route.
86
+ * @returns A decorator function that can be used to decorate a controller method.
87
+ */
88
+ function Delete(path = '') {
89
+ return Route(http_methods_1.HttpMethods.DELETE, path);
90
+ }
91
+ //# sourceMappingURL=route-decorator.js.map
@@ -0,0 +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,CAAC,CAAA;AAC/D,CAAC;AAED,SAAgB,KAAK,CAAC,MAAmB,EAAE,IAAY;IACrD,OAAO,UACL,MAAc,EACd,WAA4B,EAC5B,UAA8B;QAE9B,OAAO,CAAC,cAAc,CACpB,gBAAS,EACT;YACE,MAAM,EAAE,MAAM;YACd,IAAI;SACL,EACD,MAAM,EACN,WAAW,CACZ,CAAA;QAED,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAA;QAEvC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAG,YAAmB;YACvD,MAAM,IAAI,GAAG;gBACX,MAAM,IAAA,2CAAuB,EAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC;gBAChE,MAAM,IAAA,uCAAqB,EAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC;gBAC9D,MAAM,IAAA,uCAAqB,EAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC;gBAC9D,MAAM,IAAA,qCAAoB,EAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC;aAC9D;iBACE,IAAI,EAAE;iBACN,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC;iBAC5C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc,CAAC;iBACnD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;YAE1B,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAEvD,IAAI,QAAQ,YAAY,qBAAY,EAAE,CAAC;gBACrC,OAAO,QAAQ,CAAA;YACjB,CAAC;YAED,OAAO,qBAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACpC,CAAC,CAAA;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"}
@@ -0,0 +1,3 @@
1
+ export * from './decorators';
2
+ export * from './base-controller';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/controllers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,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("./decorators"), exports);
18
+ __exportStar(require("./base-controller"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,oDAAiC"}
@@ -0,0 +1,33 @@
1
+ import { BindToFluentSyntax, Container as InversifyContainer, ServiceIdentifier } from 'inversify';
2
+ /**
3
+ * A Wrapper class for the Inversify Container.
4
+ * Allows the container into a N depth hierarchy module system.
5
+ */
6
+ export declare class Container {
7
+ container: InversifyContainer;
8
+ private loadedModules;
9
+ constructor();
10
+ /**
11
+ * Loads a module into the container.
12
+ * Internally calls the registry method of the module.
13
+ * All child modules are registered in the parent container.
14
+ * @param module ContainerModule
15
+ */
16
+ load(module: ContainerModule): void;
17
+ bind<T>(serviceIdentifier: ServiceIdentifier<T>): BindToFluentSyntax<T>;
18
+ get<T>(serviceIdentifier: ServiceIdentifier<T>): T;
19
+ getAsync<T>(serviceIdentifier: ServiceIdentifier<T>): Promise<T>;
20
+ isBound<T>(serviceIdentifier: ServiceIdentifier<T>): boolean;
21
+ unbind<T>(serviceIdentifier: ServiceIdentifier<T>): void;
22
+ }
23
+ export type ContainerModuleRegistry = (container: Container) => void;
24
+ /**
25
+ * Child module container.
26
+ * Receives a registry method to allow child bindings.
27
+ * @param registry ContainerModuleRegistry
28
+ */
29
+ export declare class ContainerModule {
30
+ registry: ContainerModuleRegistry;
31
+ constructor(registry: ContainerModuleRegistry);
32
+ }
33
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/dependency-injection/container.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,IAAI,kBAAkB,EAC/B,iBAAiB,EAClB,MAAM,WAAW,CAAA;AAElB;;;GAGG;AACH,qBAAa,SAAS;IACb,SAAS,EAAE,kBAAkB,CAAA;IACpC,OAAO,CAAC,aAAa,CAAkC;;IAMvD;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,eAAe;IAgB5B,IAAI,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC;IAIvE,GAAG,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC;IAIlD,QAAQ,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhE,OAAO,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO;IAI5D,MAAM,CAAC,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI;CAGzD;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAA;AAEpE;;;;GAIG;AACH,qBAAa,eAAe;IACnB,QAAQ,EAAE,uBAAuB,CAAA;gBAE5B,QAAQ,EAAE,uBAAuB;CAG9C"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContainerModule = exports.Container = void 0;
4
+ const inversify_1 = require("inversify");
5
+ /**
6
+ * A Wrapper class for the Inversify Container.
7
+ * Allows the container into a N depth hierarchy module system.
8
+ */
9
+ class Container {
10
+ constructor() {
11
+ this.loadedModules = new Set();
12
+ this.container = new inversify_1.Container();
13
+ }
14
+ /**
15
+ * Loads a module into the container.
16
+ * Internally calls the registry method of the module.
17
+ * All child modules are registered in the parent container.
18
+ * @param module ContainerModule
19
+ */
20
+ load(module) {
21
+ if (!module.hasOwnProperty('registry')) {
22
+ throw new Error(`Container: module ${module} does not have a registry method`);
23
+ }
24
+ // Prevent infinite recursion by tracking loaded modules
25
+ if (this.loadedModules.has(module)) {
26
+ return;
27
+ }
28
+ this.loadedModules.add(module);
29
+ module.registry(this);
30
+ }
31
+ bind(serviceIdentifier) {
32
+ return this.container.bind(serviceIdentifier);
33
+ }
34
+ get(serviceIdentifier) {
35
+ return this.container.get(serviceIdentifier);
36
+ }
37
+ getAsync(serviceIdentifier) {
38
+ return this.container.getAsync(serviceIdentifier);
39
+ }
40
+ isBound(serviceIdentifier) {
41
+ return this.container.isBound(serviceIdentifier);
42
+ }
43
+ unbind(serviceIdentifier) {
44
+ this.container.unbind(serviceIdentifier);
45
+ }
46
+ }
47
+ exports.Container = Container;
48
+ /**
49
+ * Child module container.
50
+ * Receives a registry method to allow child bindings.
51
+ * @param registry ContainerModuleRegistry
52
+ */
53
+ class ContainerModule {
54
+ constructor(registry) {
55
+ this.registry = registry;
56
+ }
57
+ }
58
+ exports.ContainerModule = ContainerModule;
59
+ //# sourceMappingURL=container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/dependency-inj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QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAND,0CAMC"}
@@ -0,0 +1,3 @@
1
+ export * from './container';
2
+ export { inject as Inject, injectable as Injectable } from 'inversify';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,22 @@
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
+ exports.Injectable = exports.Inject = void 0;
18
+ __exportStar(require("./container"), exports);
19
+ var inversify_1 = require("inversify");
20
+ 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
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,38 @@
1
+ import { HttpStatus } from '../constants/http-status';
2
+ import { HttpException } from './http-exception';
3
+ export declare class ApiException extends HttpException {
4
+ readonly code: string;
5
+ readonly title: string;
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
+ };
13
+ }
14
+ export declare class BadRequestApiException extends ApiException {
15
+ constructor(message: string);
16
+ }
17
+ export declare class ValidationApiException extends ApiException {
18
+ constructor(message: string);
19
+ }
20
+ export declare class UnauthorizedApiException extends ApiException {
21
+ constructor(message?: string);
22
+ }
23
+ export declare class ForbiddenApiException extends ApiException {
24
+ constructor(message: string);
25
+ }
26
+ export declare class NotFoundApiException extends ApiException {
27
+ constructor(message: string);
28
+ }
29
+ export declare class UnprocessableEntityApiException extends ApiException {
30
+ constructor(message: string);
31
+ }
32
+ export declare class InternalServerErrorApiException extends ApiException {
33
+ constructor(message: string);
34
+ }
35
+ export declare class ServiceUnavailableApiException extends ApiException {
36
+ constructor(message: string);
37
+ }
38
+ //# sourceMappingURL=api-exception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/api-exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,qBAAa,YAAa,SAAQ,aAAa;aAE3B,IAAI,EAAE,MAAM;aACZ,KAAK,EAAE,MAAM;aACb,OAAO,EAAE,MAAM;gBAFf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAC/B,MAAM,GAAE,UAA6C;IAKvD,WAAW;;;;;CAOZ;AAED,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,OAAO,EAAE,MAAM;CAG5B;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"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServiceUnavailableApiException = exports.InternalServerErrorApiException = exports.UnprocessableEntityApiException = exports.NotFoundApiException = exports.ForbiddenApiException = exports.UnauthorizedApiException = exports.ValidationApiException = exports.BadRequestApiException = exports.ApiException = void 0;
4
+ const http_status_1 = require("../constants/http-status");
5
+ const http_exception_1 = require("./http-exception");
6
+ class ApiException extends http_exception_1.HttpException {
7
+ constructor(code, title, message, status = http_status_1.HttpStatus.INTERNAL_SERVER_ERROR) {
8
+ super(message, status);
9
+ this.code = code;
10
+ this.title = title;
11
+ this.message = message;
12
+ }
13
+ getResponse() {
14
+ return {
15
+ code: this.code,
16
+ title: this.title,
17
+ message: this.message
18
+ };
19
+ }
20
+ }
21
+ exports.ApiException = ApiException;
22
+ class BadRequestApiException extends ApiException {
23
+ constructor(message) {
24
+ super('0000', 'Bad Request', message, http_status_1.HttpStatus.BAD_REQUEST);
25
+ }
26
+ }
27
+ exports.BadRequestApiException = BadRequestApiException;
28
+ class ValidationApiException extends ApiException {
29
+ constructor(message) {
30
+ super('0007', 'Validation Error', message, http_status_1.HttpStatus.BAD_REQUEST);
31
+ }
32
+ }
33
+ exports.ValidationApiException = ValidationApiException;
34
+ class UnauthorizedApiException extends ApiException {
35
+ constructor(message = 'Unauthorized') {
36
+ super('0001', 'Unauthorized', message, http_status_1.HttpStatus.UNAUTHORIZED);
37
+ }
38
+ }
39
+ exports.UnauthorizedApiException = UnauthorizedApiException;
40
+ class ForbiddenApiException extends ApiException {
41
+ constructor(message) {
42
+ super('0002', 'Forbidden', message, http_status_1.HttpStatus.FORBIDDEN);
43
+ }
44
+ }
45
+ exports.ForbiddenApiException = ForbiddenApiException;
46
+ class NotFoundApiException extends ApiException {
47
+ constructor(message) {
48
+ super('0003', 'Not Found', message, http_status_1.HttpStatus.NOT_FOUND);
49
+ }
50
+ }
51
+ exports.NotFoundApiException = NotFoundApiException;
52
+ class UnprocessableEntityApiException extends ApiException {
53
+ constructor(message) {
54
+ super('0006', 'Unprocessable Entity', message, http_status_1.HttpStatus.UNPROCESSABLE_ENTITY);
55
+ }
56
+ }
57
+ exports.UnprocessableEntityApiException = UnprocessableEntityApiException;
58
+ class InternalServerErrorApiException extends ApiException {
59
+ constructor(message) {
60
+ super('0004', 'Internal Server Error', message, http_status_1.HttpStatus.INTERNAL_SERVER_ERROR);
61
+ }
62
+ }
63
+ exports.InternalServerErrorApiException = InternalServerErrorApiException;
64
+ class ServiceUnavailableApiException extends ApiException {
65
+ constructor(message) {
66
+ super('0005', 'Service Unavailable', message, http_status_1.HttpStatus.SERVICE_UNAVAILABLE);
67
+ }
68
+ }
69
+ exports.ServiceUnavailableApiException = ServiceUnavailableApiException;
70
+ //# sourceMappingURL=api-exception.js.map
@@ -0,0 +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,EA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ACtB,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"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Defines the base HTTP exception, which is handled by the default
3
+ * Exceptions Handler.
4
+ *
5
+ * Inspired by NestJS:
6
+ * https://github.com/nestjs/nest/blob/master/packages/common/exceptions/http.exception.ts
7
+ */
8
+ export declare class HttpException extends Error {
9
+ private readonly status;
10
+ constructor(message: string, status?: number);
11
+ getStatus(): number;
12
+ getResponse(): {
13
+ message: string;
14
+ };
15
+ }
16
+ //# sourceMappingURL=http-exception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/http-exception.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAA;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAK5C,SAAS;IAIT,WAAW;;;CAKZ"}