@hg-ts/http-controller 0.1.58

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 (106) hide show
  1. package/README.md +1 -0
  2. package/dist/decorators/decorators.d.ts +32 -0
  3. package/dist/decorators/decorators.d.ts.map +1 -0
  4. package/dist/decorators/decorators.js +168 -0
  5. package/dist/decorators/decorators.js.map +1 -0
  6. package/dist/decorators/index.d.ts +2 -0
  7. package/dist/decorators/index.d.ts.map +1 -0
  8. package/dist/decorators/index.js +5 -0
  9. package/dist/decorators/index.js.map +1 -0
  10. package/dist/example.d.ts +2 -0
  11. package/dist/example.d.ts.map +1 -0
  12. package/dist/example.js.map +1 -0
  13. package/dist/http-controller.module.d.ts +3 -0
  14. package/dist/http-controller.module.d.ts.map +1 -0
  15. package/dist/http-controller.module.js +15 -0
  16. package/dist/http-controller.module.js.map +1 -0
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/middlewares/exception-handler.d.ts +8 -0
  22. package/dist/middlewares/exception-handler.d.ts.map +1 -0
  23. package/dist/middlewares/exception-handler.js +45 -0
  24. package/dist/middlewares/exception-handler.js.map +1 -0
  25. package/dist/middlewares/index.d.ts +3 -0
  26. package/dist/middlewares/index.d.ts.map +1 -0
  27. package/dist/middlewares/index.js +6 -0
  28. package/dist/middlewares/index.js.map +1 -0
  29. package/dist/middlewares/validation.pipe.d.ts +10 -0
  30. package/dist/middlewares/validation.pipe.d.ts.map +1 -0
  31. package/dist/middlewares/validation.pipe.js +28 -0
  32. package/dist/middlewares/validation.pipe.js.map +1 -0
  33. package/dist/services/index.d.ts +2 -0
  34. package/dist/services/index.d.ts.map +1 -0
  35. package/dist/services/index.js +5 -0
  36. package/dist/services/index.js.map +1 -0
  37. package/dist/services/swagger.service.d.ts +6 -0
  38. package/dist/services/swagger.service.d.ts.map +1 -0
  39. package/dist/services/swagger.service.js +22 -0
  40. package/dist/services/swagger.service.js.map +1 -0
  41. package/dist/tests/abstracts/base-controller-suite.d.ts +13 -0
  42. package/dist/tests/abstracts/base-controller-suite.d.ts.map +1 -0
  43. package/dist/tests/abstracts/base-controller-suite.js +35 -0
  44. package/dist/tests/abstracts/base-controller-suite.js.map +1 -0
  45. package/dist/tests/abstracts/index.d.ts +2 -0
  46. package/dist/tests/abstracts/index.d.ts.map +1 -0
  47. package/dist/tests/abstracts/index.js +5 -0
  48. package/dist/tests/abstracts/index.js.map +1 -0
  49. package/dist/tests/echo/controllers/dto/echo-get-field.query.d.ts +3 -0
  50. package/dist/tests/echo/controllers/dto/echo-get-field.query.d.ts.map +1 -0
  51. package/dist/tests/echo/controllers/dto/echo-get-field.query.js +6 -0
  52. package/dist/tests/echo/controllers/dto/echo-get-field.query.js.map +1 -0
  53. package/dist/tests/echo/controllers/dto/echo-get.body.d.ts +7 -0
  54. package/dist/tests/echo/controllers/dto/echo-get.body.d.ts.map +1 -0
  55. package/dist/tests/echo/controllers/dto/echo-get.body.js +9 -0
  56. package/dist/tests/echo/controllers/dto/echo-get.body.js.map +1 -0
  57. package/dist/tests/echo/controllers/dto/echo-get.query.d.ts +7 -0
  58. package/dist/tests/echo/controllers/dto/echo-get.query.d.ts.map +1 -0
  59. package/dist/tests/echo/controllers/dto/echo-get.query.js +9 -0
  60. package/dist/tests/echo/controllers/dto/echo-get.query.js.map +1 -0
  61. package/dist/tests/echo/controllers/dto/echo-post.body.d.ts +7 -0
  62. package/dist/tests/echo/controllers/dto/echo-post.body.d.ts.map +1 -0
  63. package/dist/tests/echo/controllers/dto/echo-post.body.js +9 -0
  64. package/dist/tests/echo/controllers/dto/echo-post.body.js.map +1 -0
  65. package/dist/tests/echo/controllers/dto/index.d.ts +4 -0
  66. package/dist/tests/echo/controllers/dto/index.d.ts.map +1 -0
  67. package/dist/tests/echo/controllers/dto/index.js +7 -0
  68. package/dist/tests/echo/controllers/dto/index.js.map +1 -0
  69. package/dist/tests/echo/controllers/echo.controller.d.ts +10 -0
  70. package/dist/tests/echo/controllers/echo.controller.d.ts.map +1 -0
  71. package/dist/tests/echo/controllers/echo.controller.js +76 -0
  72. package/dist/tests/echo/controllers/echo.controller.js.map +1 -0
  73. package/dist/tests/echo/controllers/index.d.ts +2 -0
  74. package/dist/tests/echo/controllers/index.d.ts.map +1 -0
  75. package/dist/tests/echo/controllers/index.js +5 -0
  76. package/dist/tests/echo/controllers/index.js.map +1 -0
  77. package/dist/tests/echo/echo.test.d.ts +14 -0
  78. package/dist/tests/echo/echo.test.d.ts.map +1 -0
  79. package/dist/tests/echo/echo.test.js +116 -0
  80. package/dist/tests/echo/echo.test.js.map +1 -0
  81. package/dist/tests/echo/echo.test.module.d.ts +3 -0
  82. package/dist/tests/echo/echo.test.module.d.ts.map +1 -0
  83. package/dist/tests/echo/echo.test.module.js +17 -0
  84. package/dist/tests/echo/echo.test.module.js.map +1 -0
  85. package/dist/tests/http-methods/controllers/empty-response.controller.d.ts +11 -0
  86. package/dist/tests/http-methods/controllers/empty-response.controller.d.ts.map +1 -0
  87. package/dist/tests/http-methods/controllers/empty-response.controller.js +91 -0
  88. package/dist/tests/http-methods/controllers/empty-response.controller.js.map +1 -0
  89. package/dist/tests/http-methods/controllers/index.d.ts +2 -0
  90. package/dist/tests/http-methods/controllers/index.d.ts.map +1 -0
  91. package/dist/tests/http-methods/controllers/index.js +5 -0
  92. package/dist/tests/http-methods/controllers/index.js.map +1 -0
  93. package/dist/tests/http-methods/http-methods.test.d.ts +15 -0
  94. package/dist/tests/http-methods/http-methods.test.d.ts.map +1 -0
  95. package/dist/tests/http-methods/http-methods.test.js +104 -0
  96. package/dist/tests/http-methods/http-methods.test.js.map +1 -0
  97. package/dist/tests/http-methods/http-methods.test.module.d.ts +3 -0
  98. package/dist/tests/http-methods/http-methods.test.module.d.ts.map +1 -0
  99. package/dist/tests/http-methods/http-methods.test.module.js +17 -0
  100. package/dist/tests/http-methods/http-methods.test.module.js.map +1 -0
  101. package/dist/types.d.ts +10 -0
  102. package/dist/types.d.ts.map +1 -0
  103. package/dist/types.js +14 -0
  104. package/dist/types.js.map +1 -0
  105. package/package.json +55 -0
  106. package/tsconfig.json +9 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @hg/cqrs
@@ -0,0 +1,32 @@
1
+ import { Schema } from '@hg-ts/validation';
2
+ export type ControllerDecoratorOptions = {
3
+ path?: string | string[];
4
+ tags?: string | string[];
5
+ };
6
+ export type MethodDecoratorOptions = {
7
+ path?: string | string[];
8
+ tags?: string | string[];
9
+ };
10
+ export declare class Http {
11
+ private constructor();
12
+ static Controller<T extends Function>(options?: string | string[] | ControllerDecoratorOptions): TypedClassDecorator<T>;
13
+ static Get(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
14
+ static Post(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
15
+ static Put(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
16
+ static Patch(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
17
+ static Delete(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
18
+ static Options(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
19
+ static Search(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
20
+ static All(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
21
+ static Query(field?: string, schema?: Schema): ParameterDecorator;
22
+ static Body(field?: string, schema?: Schema): ParameterDecorator;
23
+ static Param(field?: string, schema?: Schema): ParameterDecorator;
24
+ private static getControllerOptions;
25
+ private static getMethodOptions;
26
+ private static getPathFromOptions;
27
+ private static getTagsFromOptions;
28
+ private static decorateMethod;
29
+ private static getInputDecoratorArgs;
30
+ private static getArgumentSchema;
31
+ }
32
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators/decorators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M,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,kBAAkB;WAc1D,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,kBAAkB;WAczD,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,kBAAkB;IAcxE,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAYnC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAY/B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAYjC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAUjC,OAAO,CAAC,MAAM,CAAC,cAAc;IAY7B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAoBpC,OAAO,CAAC,MAAM,CAAC,iBAAiB;CA4BhC"}
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Http = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const exception_1 = require("@hg-ts/exception");
6
+ const validation_1 = require("@hg-ts/validation");
7
+ const common_1 = require("@nestjs/common");
8
+ const swagger_1 = require("@nestjs/swagger");
9
+ const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
10
+ const middlewares_1 = require("../middlewares");
11
+ const PARAM_TYPES_METADATA = 'design:paramtypes';
12
+ class Http {
13
+ constructor() { }
14
+ static Controller(options = {}) {
15
+ const { path, tags } = this.getControllerOptions(options);
16
+ return target => {
17
+ (0, common_1.UseFilters)(middlewares_1.ExceptionHandler)(target);
18
+ (0, common_1.Controller)({ path })(target);
19
+ (0, swagger_1.ApiTags)(...tags)(target);
20
+ };
21
+ }
22
+ static Get(pathOrOptions = {}) {
23
+ const options = this.getMethodOptions(pathOrOptions);
24
+ return this.decorateMethod(common_1.Get, options);
25
+ }
26
+ static Post(pathOrOptions = {}) {
27
+ const options = this.getMethodOptions(pathOrOptions);
28
+ return this.decorateMethod(common_1.Post, options);
29
+ }
30
+ static Put(pathOrOptions = {}) {
31
+ const options = this.getMethodOptions(pathOrOptions);
32
+ return this.decorateMethod(common_1.Put, options);
33
+ }
34
+ static Patch(pathOrOptions = {}) {
35
+ const options = this.getMethodOptions(pathOrOptions);
36
+ return this.decorateMethod(common_1.Patch, options);
37
+ }
38
+ static Delete(pathOrOptions = {}) {
39
+ const options = this.getMethodOptions(pathOrOptions);
40
+ return this.decorateMethod(common_1.Delete, options);
41
+ }
42
+ static Options(pathOrOptions = {}) {
43
+ const options = this.getMethodOptions(pathOrOptions);
44
+ return this.decorateMethod(common_1.Options, options);
45
+ }
46
+ static Search(pathOrOptions = {}) {
47
+ const options = this.getMethodOptions(pathOrOptions);
48
+ return this.decorateMethod(common_1.Search, options);
49
+ }
50
+ static All(pathOrOptions = {}) {
51
+ const options = this.getMethodOptions(pathOrOptions);
52
+ return this.decorateMethod(common_1.All, options);
53
+ }
54
+ static Query(field, schema) {
55
+ return (target, propertyKey, parameterIndex) => {
56
+ const args = this.getInputDecoratorArgs({
57
+ target,
58
+ propertyKey,
59
+ parameterIndex,
60
+ primitiveSchema: schema ?? null,
61
+ field,
62
+ });
63
+ (0, common_1.Query)(...args)(target, propertyKey, parameterIndex);
64
+ };
65
+ }
66
+ static Body(field, schema) {
67
+ return (target, propertyKey, parameterIndex) => {
68
+ const args = this.getInputDecoratorArgs({
69
+ target,
70
+ propertyKey,
71
+ parameterIndex,
72
+ primitiveSchema: schema ?? null,
73
+ field,
74
+ });
75
+ (0, common_1.Body)(...args)(target, propertyKey, parameterIndex);
76
+ };
77
+ }
78
+ static Param(field, schema) {
79
+ return (target, propertyKey, parameterIndex) => {
80
+ const args = this.getInputDecoratorArgs({
81
+ target,
82
+ propertyKey,
83
+ parameterIndex,
84
+ primitiveSchema: schema ?? null,
85
+ field,
86
+ });
87
+ (0, common_1.Param)(...args)(target, propertyKey, parameterIndex);
88
+ };
89
+ }
90
+ static getControllerOptions(options) {
91
+ const path = this.getPathFromOptions(options);
92
+ const tags = this.getTagsFromOptions(options);
93
+ return {
94
+ path,
95
+ tags,
96
+ };
97
+ }
98
+ static getMethodOptions(options) {
99
+ const path = this.getPathFromOptions(options);
100
+ const tags = this.getTagsFromOptions(options);
101
+ return {
102
+ path,
103
+ tags,
104
+ };
105
+ }
106
+ static getPathFromOptions(optionsOrPath) {
107
+ if (typeof optionsOrPath === 'string') {
108
+ return [optionsOrPath];
109
+ }
110
+ if (Array.isArray(optionsOrPath)) {
111
+ return optionsOrPath;
112
+ }
113
+ return Array.isArray(optionsOrPath.path) ? optionsOrPath.path : [optionsOrPath.path ?? '/'];
114
+ }
115
+ static getTagsFromOptions(options) {
116
+ if (typeof options === 'string' || Array.isArray(options)) {
117
+ return [];
118
+ }
119
+ const { tags = [] } = options;
120
+ return Array.isArray(tags) ? tags : [tags];
121
+ }
122
+ static decorateMethod(decorator, options) {
123
+ const { path, tags } = options;
124
+ return (target, propertyKey, descriptor) => {
125
+ decorator(path)(target, propertyKey, descriptor);
126
+ (0, swagger_1.ApiTags)(...tags)(target, propertyKey, descriptor);
127
+ };
128
+ }
129
+ static getInputDecoratorArgs(params) {
130
+ const { target, propertyKey, parameterIndex, primitiveSchema, field } = params;
131
+ const { dto, autoResolved } = this.getArgumentSchema({
132
+ target,
133
+ propertyKey,
134
+ parameterIndex,
135
+ primitiveSchema,
136
+ });
137
+ const args = typeof field === 'string' ? [field] : [];
138
+ if (autoResolved) {
139
+ args.push(middlewares_1.ValidationPipe.getInstance());
140
+ }
141
+ else {
142
+ args.push(new middlewares_1.ValidationPipe(dto));
143
+ }
144
+ return args;
145
+ }
146
+ static getArgumentSchema(params) {
147
+ const { target, propertyKey, parameterIndex, primitiveSchema } = params;
148
+ const metatype = Reflect.getMetadata(PARAM_TYPES_METADATA, target, propertyKey);
149
+ strict_1.default.ok(Array.isArray(metatype));
150
+ const argMetaType = metatype[parameterIndex];
151
+ if (!argMetaType) {
152
+ throw new exception_1.WillNeverHappenedException('Argument metadata not found');
153
+ }
154
+ const isPrimitive = [String, Number, BigInt, Boolean].includes(argMetaType);
155
+ if (isPrimitive || primitiveSchema) {
156
+ if (!primitiveSchema) {
157
+ throw new exception_1.InvalidInputException('Schema not passed for primitive argument with decorator');
158
+ }
159
+ return { dto: primitiveSchema, autoResolved: false };
160
+ }
161
+ if (!(0, validation_1.isZodDto)(argMetaType)) {
162
+ throw new exception_1.InvalidInputException('Object argument for decorated method is not validation schema class');
163
+ }
164
+ return { dto: argMetaType.schema, autoResolved: true };
165
+ }
166
+ }
167
+ exports.Http = Http;
168
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators/decorators.ts"],"names":[],"mappings":";;;;AAAA,gDAG0B;AAC1B,kDAG2B;AAE3B,2CAewB;AACxB,6CAA0C;AAE1C,wEAAwC;AACxC,gDAGwB;AAqCxB,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD,MAAa,IAAI;IAChB,gBAAuB,CAAC;IAEjB,MAAM,CAAC,UAAU,CACvB,UAA0D,EAAE;QAE5D,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAG1D,OAAO,MAAM,CAAC,EAAE;YACf,IAAA,mBAAU,EAAC,8BAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;YACrC,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;YAC7B,IAAA,iBAAO,EAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,GAAG,CAAC,gBAA4D,EAAE;QAC/E,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAErD,OAAO,IAAI,CAAC,cAAc,CAAC,YAAG,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAEM,MAAM,CAAC,IAA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,WAAY,CAAC,CAAC;QAEjF,gBAAM,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEnC,MAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;QAE7C,IAAI,CAAC,WAAW,EAAE,CAAC;YAClB,MAAM,IAAI,sCAA0B,CAAC,6BAA6B,CAAC,CAAC;QACrE,CAAC;QAED,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAE5E,IAAI,WAAW,IAAI,eAAe,EAAE,CAAC;YACpC,IAAI,CAAC,eAAe,EAAE,CAAC;gBACtB,MAAM,IAAI,iCAAqB,CAAC,yDAAyD,CAAC,CAAC;YAC5F,CAAC;YAED,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QACtD,CAAC;QAED,IAAI,CAAC,IAAA,qBAAQ,EAAC,WAAW,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,iCAAqB,CAAC,qEAAqE,CAAC,CAAC;QACxG,CAAC;QAED,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;CACD;AApND,oBAoNC"}
@@ -0,0 +1,2 @@
1
+ export * from './decorators';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./decorators"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":";;;AAAA,gDAA8D;AAC9D,oCAGoB;AAEpB,8EAA2C;AAE3C,wEAAwC;AAExC,0DAA0D;AAC1D,kEAA2E;AAG3E,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,aAAa;IADlB,IAAA,YAAM,EAAC,EAAE,WAAW,EAAE,CAAC,4BAAc,EAAE,qCAAuB,CAAC,EAAE,CAAC;GAC7D,aAAa,CAAG;AAEtB,KAAK,UAAU,SAAS;IACvB,MAAM,SAAS,GAAG,MAAM,eAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAExD,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAA,yBAAY,GAAE,CAAC;IAExC,gBAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,sCAA0B,CAAC,6CAA6C,CAAC,CAAC,CAAC;IAEnG,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;IACvB,MAAM,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare class HttpControllerModule {
2
+ }
3
+ //# sourceMappingURL=http-controller.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-controller.module.d.ts","sourceRoot":"","sources":["../src/http-controller.module.ts"],"names":[],"mappings":"AASA,qBAEa,oBAAoB;CAAG"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpControllerModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ioc_1 = require("@hg-ts/ioc");
6
+ const services_1 = require("./services");
7
+ const services = [services_1.SwaggerService];
8
+ let HttpControllerModule = class HttpControllerModule {
9
+ };
10
+ exports.HttpControllerModule = HttpControllerModule;
11
+ exports.HttpControllerModule = HttpControllerModule = tslib_1.__decorate([
12
+ (0, ioc_1.Global)(),
13
+ (0, ioc_1.Module)({ providers: [...services] })
14
+ ], HttpControllerModule);
15
+ //# sourceMappingURL=http-controller.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-controller.module.js","sourceRoot":"","sources":["../src/http-controller.module.ts"],"names":[],"mappings":";;;;AAAA,oCAIoB;AACpB,yCAA4C;AAE5C,MAAM,QAAQ,GAAoB,CAAC,yBAAc,CAAC,CAAC;AAI5C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oDAAoB;+BAApB,oBAAoB;IAFhC,IAAA,YAAM,GAAE;IACR,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;GACxB,oBAAoB,CAAG"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
2
+ export declare class ExceptionHandler implements ExceptionFilter {
3
+ private readonly logger;
4
+ catch(exception: unknown, host: ArgumentsHost): void;
5
+ private handleHttpException;
6
+ private getException;
7
+ }
8
+ //# sourceMappingURL=exception-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception-handler.d.ts","sourceRoot":"","sources":["../../src/middlewares/exception-handler.ts"],"names":[],"mappings":"AAMA,OAAO,EACN,aAAa,EAEb,eAAe,EACf,MAAM,gBAAgB,CAAC;AAGxB,qBACa,gBAAiB,YAAW,eAAe;IAEvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEzB,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;IAY3D,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,YAAY;CAWpB"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExceptionHandler = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const exception_1 = require("@hg-ts/exception");
6
+ const ioc_1 = require("@hg-ts/ioc");
7
+ const logger_1 = require("@hg-ts/logger");
8
+ const common_1 = require("@nestjs/common");
9
+ let ExceptionHandler = class ExceptionHandler {
10
+ logger;
11
+ catch(exception, host) {
12
+ const formattedException = this.getException(exception);
13
+ switch (host.getType()) {
14
+ case 'http':
15
+ this.handleHttpException(formattedException, host);
16
+ break;
17
+ default:
18
+ this.logger.warning('Unknown transport');
19
+ throw exception;
20
+ }
21
+ }
22
+ handleHttpException(exception, host) {
23
+ const http = host.switchToHttp();
24
+ const response = http.getResponse();
25
+ response.status(500).send(exception.toJSON());
26
+ }
27
+ getException(exception) {
28
+ if (exception instanceof exception_1.BaseException) {
29
+ return exception;
30
+ }
31
+ if (exception instanceof Error) {
32
+ return new exception_1.ErrorException(exception);
33
+ }
34
+ return new exception_1.ErrorException(new Error(String(exception)));
35
+ }
36
+ };
37
+ exports.ExceptionHandler = ExceptionHandler;
38
+ tslib_1.__decorate([
39
+ (0, ioc_1.Dependency)(),
40
+ tslib_1.__metadata("design:type", logger_1.Logger)
41
+ ], ExceptionHandler.prototype, "logger", void 0);
42
+ exports.ExceptionHandler = ExceptionHandler = tslib_1.__decorate([
43
+ (0, common_1.Catch)()
44
+ ], ExceptionHandler);
45
+ //# sourceMappingURL=exception-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception-handler.js","sourceRoot":"","sources":["../../src/middlewares/exception-handler.ts"],"names":[],"mappings":";;;;AAAA,gDAG0B;AAC1B,oCAAwC;AACxC,0CAAuC;AACvC,2CAIwB;AAIjB,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEX,MAAM,CAAS;IAEzB,KAAK,CAAC,SAAkB,EAAE,IAAmB;QACnD,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACxD,QAAQ,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACzB,KAAK,MAAM;gBACV,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;gBACnD,MAAM;YACP;gBACC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;gBACzC,MAAM,SAAS,CAAC;QACjB,CAAC;IACF,CAAC;IAEO,mBAAmB,CAAC,SAAwB,EAAE,IAAmB;QACxE,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAgB,CAAC;QAElD,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAEO,YAAY,CAAC,SAAkB;QACtC,IAAI,SAAS,YAAY,yBAAa,EAAE,CAAC;YACxC,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YAChC,OAAO,IAAI,0BAAc,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,IAAI,0BAAc,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;CACD,CAAA;AAlCY,4CAAgB;AAEX;IADhB,IAAA,gBAAU,GAAE;sCACY,eAAM;gDAAC;2BAFpB,gBAAgB;IAD5B,IAAA,cAAK,GAAE;GACK,gBAAgB,CAkC5B"}
@@ -0,0 +1,3 @@
1
+ export * from './validation.pipe';
2
+ export * from './exception-handler';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./validation.pipe"), exports);
5
+ tslib_1.__exportStar(require("./exception-handler"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,8DAAoC"}
@@ -0,0 +1,10 @@
1
+ import { Schema } from '@hg-ts/validation';
2
+ import { ArgumentMetadata, PipeTransform } from '@nestjs/common';
3
+ export declare class ValidationPipe implements PipeTransform<unknown, unknown> {
4
+ private readonly dto;
5
+ constructor(dto?: Schema);
6
+ transform(value: unknown, { metatype }: ArgumentMetadata): unknown;
7
+ static getInstance(): ValidationPipe;
8
+ private getSchema;
9
+ }
10
+ //# sourceMappingURL=validation.pipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.pipe.d.ts","sourceRoot":"","sources":["../../src/middlewares/validation.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,MAAM,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,gBAAgB,EAChB,aAAa,EACb,MAAM,gBAAgB,CAAC;AAGxB,qBAAa,cAAe,YAAW,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC;IACrE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;gBAEjB,GAAG,CAAC,EAAE,MAAM;IAIxB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,gBAAgB,GAAG,OAAO;WAM3D,WAAW,IAAI,cAAc;IAI3C,OAAO,CAAC,SAAS;CASjB"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationPipe = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const validation_1 = require("@hg-ts/validation");
6
+ const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
7
+ class ValidationPipe {
8
+ dto;
9
+ constructor(dto) {
10
+ this.dto = dto ?? null;
11
+ }
12
+ transform(value, { metatype }) {
13
+ const schema = this.getSchema(metatype);
14
+ return schema.parse(value);
15
+ }
16
+ static getInstance() {
17
+ return new ValidationPipe();
18
+ }
19
+ getSchema(metatype) {
20
+ if (this.dto) {
21
+ return this.dto;
22
+ }
23
+ strict_1.default.ok((0, validation_1.isZodDto)(metatype));
24
+ return metatype.schema;
25
+ }
26
+ }
27
+ exports.ValidationPipe = ValidationPipe;
28
+ //# sourceMappingURL=validation.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.pipe.js","sourceRoot":"","sources":["../../src/middlewares/validation.pipe.ts"],"names":[],"mappings":";;;;AAAA,kDAG2B;AAK3B,wEAAwC;AAExC,MAAa,cAAc;IACT,GAAG,CAAgB;IAEpC,YAAmB,GAAY;QAC9B,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC;IACxB,CAAC;IAEM,SAAS,CAAC,KAAc,EAAE,EAAE,QAAQ,EAAoB;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAExC,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,WAAW;QACxB,OAAO,IAAI,cAAc,EAAE,CAAC;IAC7B,CAAC;IAEO,SAAS,CAAC,QAA4B;QAC7C,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,IAAI,CAAC,GAAG,CAAC;QACjB,CAAC;QAED,gBAAM,CAAC,EAAE,CAAC,IAAA,qBAAQ,EAAC,QAAQ,CAAC,CAAC,CAAC;QAE9B,OAAO,QAAQ,CAAC,MAAM,CAAC;IACxB,CAAC;CACD;AA1BD,wCA0BC"}
@@ -0,0 +1,2 @@
1
+ export * from './swagger.service';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./swagger.service"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC"}
@@ -0,0 +1,6 @@
1
+ import { INIT_HOOK } from '@hg-ts/ioc';
2
+ export declare class SwaggerService {
3
+ private readonly appProxy;
4
+ [INIT_HOOK](): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=swagger.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swagger.service.d.ts","sourceRoot":"","sources":["../../src/services/swagger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,SAAS,EACT,MAAM,YAAY,CAAC;AAOpB,qBAAa,cAAc;IAE1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IAEvB,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAUzC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwaggerService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ioc_1 = require("@hg-ts/ioc");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ class SwaggerService {
8
+ appProxy;
9
+ async [ioc_1.INIT_HOOK]() {
10
+ const { app } = this.appProxy;
11
+ const config = new swagger_1.DocumentBuilder()
12
+ .build();
13
+ const document = swagger_1.SwaggerModule.createDocument(app, config);
14
+ swagger_1.SwaggerModule.setup('/', app, document);
15
+ }
16
+ }
17
+ exports.SwaggerService = SwaggerService;
18
+ tslib_1.__decorate([
19
+ (0, ioc_1.Dependency)(),
20
+ tslib_1.__metadata("design:type", ioc_1.AppProxy)
21
+ ], SwaggerService.prototype, "appProxy", void 0);
22
+ //# sourceMappingURL=swagger.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swagger.service.js","sourceRoot":"","sources":["../../src/services/swagger.service.ts"],"names":[],"mappings":";;;;AAAA,oCAIoB;AAEpB,6CAGyB;AAEzB,MAAa,cAAc;IAET,QAAQ,CAAW;IAE7B,KAAK,CAAC,CAAC,eAAS,CAAC;QACvB,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE9B,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE;aAClC,KAAK,EAAE,CAAC;QAEV,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAE3D,uBAAa,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACzC,CAAC;CACD;AAdD,wCAcC;AAZiB;IADhB,IAAA,gBAAU,GAAE;sCACc,cAAQ;gDAAC"}
@@ -0,0 +1,13 @@
1
+ import { TestContainer } from '@hg-ts/ioc';
2
+ import { Suite } from '@hg-ts/tests';
3
+ import { AxiosInstance } from 'axios';
4
+ export declare abstract class BaseControllerSuite extends Suite {
5
+ protected container: TestContainer;
6
+ protected client: AxiosInstance;
7
+ private readonly moduleCtor;
8
+ constructor(moduleCtor: Class<any, any[]>);
9
+ setUp(): Promise<void>;
10
+ tearDown(): Promise<void>;
11
+ protected abstract getFreePortIndex(): number;
12
+ }
13
+ //# sourceMappingURL=base-controller-suite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-controller-suite.d.ts","sourceRoot":"","sources":["../../../src/tests/abstracts/base-controller-suite.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAK7C,8BAAsB,mBAAoB,SAAQ,KAAK;IACtD,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC;IACnC,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAE5B,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;IAM1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAetB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,IAAI,MAAM;CAC7C"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseControllerSuite = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const exception_1 = require("@hg-ts/exception");
6
+ const ioc_1 = require("@hg-ts/ioc");
7
+ const tests_1 = require("@hg-ts/tests");
8
+ const axios_1 = tslib_1.__importDefault(require("axios"));
9
+ const find_free_ports_1 = tslib_1.__importDefault(require("find-free-ports"));
10
+ const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
11
+ class BaseControllerSuite extends tests_1.Suite {
12
+ container;
13
+ client;
14
+ moduleCtor;
15
+ constructor(moduleCtor) {
16
+ super();
17
+ this.moduleCtor = moduleCtor;
18
+ }
19
+ async setUp() {
20
+ this.container = await ioc_1.TestContainer.create(this.moduleCtor);
21
+ const portIndex = this.getFreePortIndex();
22
+ const freePorts = await (0, find_free_ports_1.default)(portIndex + 1);
23
+ const freePort = freePorts.pop();
24
+ strict_1.default.ok(freePort, new exception_1.WillNeverHappenedException('No free port found for starting test server'));
25
+ await this.container.init();
26
+ await this.container.start(freePort, 'localhost');
27
+ this.client = axios_1.default.create({ baseURL: `http://localhost:${freePort}` });
28
+ }
29
+ async tearDown() {
30
+ await this.container.destroy();
31
+ await this.container.shutdown();
32
+ }
33
+ }
34
+ exports.BaseControllerSuite = BaseControllerSuite;
35
+ //# sourceMappingURL=base-controller-suite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-controller-suite.js","sourceRoot":"","sources":["../../../src/tests/abstracts/base-controller-suite.ts"],"names":[],"mappings":";;;;AAAA,gDAA8D;AAC9D,oCAA2C;AAC3C,wCAAqC;AAErC,0DAA6C;AAC7C,8EAA2C;AAE3C,wEAAwC;AAExC,MAAsB,mBAAoB,SAAQ,aAAK;IAC5C,SAAS,CAAgB;IACzB,MAAM,CAAgB;IACf,UAAU,CAAoB;IAE/C,YAAmB,UAA6B;QAC/C,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAEe,KAAK,CAAC,KAAK;QAC1B,IAAI,CAAC,SAAS,GAAG,MAAM,mBAAa,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE1C,MAAM,SAAS,GAAG,MAAM,IAAA,yBAAY,EAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;QAEjC,gBAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,sCAA0B,CAAC,6CAA6C,CAAC,CAAC,CAAC;QAEnG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAElD,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,oBAAoB,QAAQ,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAEe,KAAK,CAAC,QAAQ;QAC7B,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;CAGD;AAhCD,kDAgCC"}
@@ -0,0 +1,2 @@
1
+ export * from './base-controller-suite';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tests/abstracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./base-controller-suite"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tests/abstracts/index.ts"],"names":[],"mappings":";;;AAAA,kEAAwC"}
@@ -0,0 +1,3 @@
1
+ import { z } from '@hg-ts/validation';
2
+ export declare const echoGetQuerySchema: z.ZodNumber;
3
+ //# sourceMappingURL=echo-get-field.query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echo-get-field.query.d.ts","sourceRoot":"","sources":["../../../../../src/tests/echo/controllers/dto/echo-get-field.query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,eAAO,MAAM,kBAAkB,aAAoB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.echoGetQuerySchema = void 0;
4
+ const validation_1 = require("@hg-ts/validation");
5
+ exports.echoGetQuerySchema = validation_1.z.coerce.number();
6
+ //# sourceMappingURL=echo-get-field.query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echo-get-field.query.js","sourceRoot":"","sources":["../../../../../src/tests/echo/controllers/dto/echo-get-field.query.ts"],"names":[],"mappings":";;;AAAA,kDAAsC;AAEzB,QAAA,kBAAkB,GAAG,cAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ declare const EchoGetQuery_base: import("@hg-ts/validation").ZodDto<{
2
+ test: string;
3
+ }>;
4
+ export declare class EchoGetQuery extends EchoGetQuery_base {
5
+ }
6
+ export {};
7
+ //# sourceMappingURL=echo-get.body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echo-get.body.d.ts","sourceRoot":"","sources":["../../../../../src/tests/echo/controllers/dto/echo-get.body.ts"],"names":[],"mappings":";;;AAIA,qBAAa,YAAa,SAAQ,iBAA4B;CAAG"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EchoGetQuery = void 0;
4
+ const validation_1 = require("@hg-ts/validation");
5
+ const echoGetQuerySchema = validation_1.z.object({ test: validation_1.z.string() });
6
+ class EchoGetQuery extends echoGetQuerySchema.toClass() {
7
+ }
8
+ exports.EchoGetQuery = EchoGetQuery;
9
+ //# sourceMappingURL=echo-get.body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echo-get.body.js","sourceRoot":"","sources":["../../../../../src/tests/echo/controllers/dto/echo-get.body.ts"],"names":[],"mappings":";;;AAAA,kDAAsC;AAEtC,MAAM,kBAAkB,GAAG,cAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,cAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAE1D,MAAa,YAAa,SAAQ,kBAAkB,CAAC,OAAO,EAAE;CAAG;AAAjE,oCAAiE"}
@@ -0,0 +1,7 @@
1
+ declare const EchoGetQuery_base: import("@hg-ts/validation").ZodDto<{
2
+ test: string;
3
+ }>;
4
+ export declare class EchoGetQuery extends EchoGetQuery_base {
5
+ }
6
+ export {};
7
+ //# sourceMappingURL=echo-get.query.d.ts.map