@hg-ts/http-controller 0.1.116 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decorators/decorators.d.ts +0 -29
- package/dist/decorators/decorators.d.ts.map +1 -1
- package/dist/decorators/decorators.js +0 -174
- package/dist/decorators/decorators.js.map +1 -1
- package/dist/http-controller.module.d.ts.map +1 -1
- package/dist/http-controller.module.js +20 -4
- package/dist/http-controller.module.js.map +1 -1
- package/dist/middlewares/database.interceptor.d.ts.map +1 -1
- package/dist/middlewares/database.interceptor.js +5 -5
- package/dist/middlewares/database.interceptor.js.map +1 -1
- package/dist/middlewares/exception-mapper.interceptor.d.ts +1 -0
- package/dist/middlewares/exception-mapper.interceptor.d.ts.map +1 -1
- package/dist/middlewares/exception-mapper.interceptor.js +12 -6
- package/dist/middlewares/exception-mapper.interceptor.js.map +1 -1
- package/dist/middlewares/index.d.ts +0 -1
- package/dist/middlewares/index.d.ts.map +1 -1
- package/dist/middlewares/index.js +0 -1
- package/dist/middlewares/index.js.map +1 -1
- package/dist/services/swagger.service.d.ts +2 -3
- package/dist/services/swagger.service.d.ts.map +1 -1
- package/dist/services/swagger.service.js +1 -9
- package/dist/services/swagger.service.js.map +1 -1
- package/dist/tests/abstracts/base-controller-suite.d.ts +4 -2
- package/dist/tests/abstracts/base-controller-suite.d.ts.map +1 -1
- package/dist/tests/abstracts/base-controller-suite.js +11 -5
- package/dist/tests/abstracts/base-controller-suite.js.map +1 -1
- package/dist/tests/echo/controllers/dto/index.d.ts +0 -1
- package/dist/tests/echo/controllers/dto/index.d.ts.map +1 -1
- package/dist/tests/echo/controllers/dto/index.js +0 -1
- package/dist/tests/echo/controllers/dto/index.js.map +1 -1
- package/dist/tests/echo/controllers/echo.controller.d.ts +0 -2
- package/dist/tests/echo/controllers/echo.controller.d.ts.map +1 -1
- package/dist/tests/echo/controllers/echo.controller.js +12 -33
- package/dist/tests/echo/controllers/echo.controller.js.map +1 -1
- package/dist/tests/echo/echo.test.d.ts +0 -2
- package/dist/tests/echo/echo.test.d.ts.map +1 -1
- package/dist/tests/echo/echo.test.js +0 -23
- package/dist/tests/echo/echo.test.js.map +1 -1
- package/dist/tests/echo/echo.test.module.d.ts.map +1 -1
- package/dist/tests/echo/echo.test.module.js +2 -6
- package/dist/tests/echo/echo.test.module.js.map +1 -1
- package/dist/tests/exception/controllers/dtos/common-exception.dto.d.ts +1 -1
- package/dist/tests/exception/controllers/exception.controller.d.ts.map +1 -1
- package/dist/tests/exception/controllers/exception.controller.js +5 -5
- package/dist/tests/exception/controllers/exception.controller.js.map +1 -1
- package/dist/tests/exception/exception.test.module.d.ts.map +1 -1
- package/dist/tests/exception/exception.test.module.js +2 -6
- package/dist/tests/exception/exception.test.module.js.map +1 -1
- package/dist/tests/http-methods/controllers/empty-response.controller.d.ts.map +1 -1
- package/dist/tests/http-methods/controllers/empty-response.controller.js +13 -16
- package/dist/tests/http-methods/controllers/empty-response.controller.js.map +1 -1
- package/dist/tests/http-methods/http-methods.test.module.d.ts.map +1 -1
- package/dist/tests/http-methods/http-methods.test.module.js +2 -6
- package/dist/tests/http-methods/http-methods.test.module.js.map +1 -1
- package/package.json +16 -15
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -2
- package/dist/constants.js.map +0 -1
- package/dist/middlewares/exception-handler.d.ts +0 -7
- package/dist/middlewares/exception-handler.d.ts.map +0 -1
- package/dist/middlewares/exception-handler.js +0 -28
- package/dist/middlewares/exception-handler.js.map +0 -1
- package/dist/tests/echo/controllers/dto/echo-get-field.query.d.ts +0 -3
- package/dist/tests/echo/controllers/dto/echo-get-field.query.d.ts.map +0 -1
- package/dist/tests/echo/controllers/dto/echo-get-field.query.js +0 -6
- package/dist/tests/echo/controllers/dto/echo-get-field.query.js.map +0 -1
|
@@ -1,37 +1,8 @@
|
|
|
1
1
|
import { BaseException } from '@hg-ts/exception';
|
|
2
|
-
import { ZodDto, ZodType } from '@hg-ts/validation';
|
|
3
|
-
export type ControllerDecoratorOptions = {
|
|
4
|
-
path?: string | string[];
|
|
5
|
-
tags?: string | string[];
|
|
6
|
-
};
|
|
7
|
-
export type MethodDecoratorOptions = {
|
|
8
|
-
path?: string | string[];
|
|
9
|
-
tags?: string | string[];
|
|
10
|
-
};
|
|
11
2
|
export type ExceptionMap = Map<Class<BaseException, any[]>, number>;
|
|
12
3
|
export declare const EXCEPTION_METADATA_KEY: unique symbol;
|
|
13
4
|
export declare class Http {
|
|
14
5
|
private constructor();
|
|
15
|
-
static Controller<T extends Function>(options?: string | string[] | ControllerDecoratorOptions): TypedClassDecorator<T>;
|
|
16
|
-
static Response(dto: Nullable<ZodDto>, statusCode?: number): MethodDecorator;
|
|
17
6
|
static ExceptionStatus(exception: Class<BaseException, any[]>, statusCode: number): MethodDecorator;
|
|
18
|
-
static Get(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
|
|
19
|
-
static Post(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
|
|
20
|
-
static Put(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
|
|
21
|
-
static Patch(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
|
|
22
|
-
static Delete(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
|
|
23
|
-
static Options(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
|
|
24
|
-
static Search(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
|
|
25
|
-
static All(pathOrOptions?: string | string[] | MethodDecoratorOptions): MethodDecorator;
|
|
26
|
-
static Query(field?: string, schema?: ZodType): ParameterDecorator;
|
|
27
|
-
static Body(field?: string, schema?: ZodType): ParameterDecorator;
|
|
28
|
-
static Param(field?: string, schema?: ZodType): ParameterDecorator;
|
|
29
|
-
private static getControllerOptions;
|
|
30
|
-
private static getMethodOptions;
|
|
31
|
-
private static getPathFromOptions;
|
|
32
|
-
private static getTagsFromOptions;
|
|
33
|
-
private static decorateMethod;
|
|
34
|
-
private static getInputDecoratorArgs;
|
|
35
|
-
private static getArgumentSchema;
|
|
36
7
|
}
|
|
37
8
|
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQjD,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAEpE,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AAEvE,qBAAa,IAAI;IAChB,OAAO;WAEO,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,eAAe;CA2B1G"}
|
|
@@ -1,43 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Http = exports.EXCEPTION_METADATA_KEY = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const exception_1 = require("@hg-ts/exception");
|
|
6
4
|
const validation_1 = require("@hg-ts/validation");
|
|
7
|
-
const common_1 = require("@nestjs/common");
|
|
8
5
|
const swagger_1 = require("@nestjs/swagger");
|
|
9
|
-
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
10
6
|
const exceptions_1 = require("../exceptions");
|
|
11
|
-
const middlewares_1 = require("../middlewares");
|
|
12
7
|
const services_1 = require("../services");
|
|
13
|
-
const PARAM_TYPES_METADATA = 'design:paramtypes';
|
|
14
8
|
exports.EXCEPTION_METADATA_KEY = Symbol('EXCEPTION_METADATA_KEY');
|
|
15
9
|
class Http {
|
|
16
10
|
constructor() { }
|
|
17
|
-
static Controller(options = {}) {
|
|
18
|
-
const { path, tags } = this.getControllerOptions(options);
|
|
19
|
-
return target => {
|
|
20
|
-
(0, common_1.UseFilters)(middlewares_1.ExceptionHandler)(target);
|
|
21
|
-
(0, common_1.UseInterceptors)(middlewares_1.ExceptionMapperInterceptor)(target);
|
|
22
|
-
(0, common_1.UseInterceptors)(middlewares_1.DatabaseInterceptor)(target);
|
|
23
|
-
(0, common_1.Controller)({ path })(target);
|
|
24
|
-
(0, swagger_1.ApiTags)(...tags)(target);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
static Response(dto, statusCode = 200) {
|
|
28
|
-
return (target, propertyKey, descriptor) => {
|
|
29
|
-
if (dto) {
|
|
30
|
-
(0, swagger_1.ApiResponse)({
|
|
31
|
-
type: dto,
|
|
32
|
-
status: statusCode,
|
|
33
|
-
})(target, propertyKey, descriptor);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
(0, swagger_1.ApiResponse)({ status: statusCode })(target, propertyKey, descriptor);
|
|
37
|
-
}
|
|
38
|
-
(0, common_1.HttpCode)(statusCode)(target, propertyKey, descriptor);
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
11
|
static ExceptionStatus(exception, statusCode) {
|
|
42
12
|
return (target, propertyKey, descriptor) => {
|
|
43
13
|
const statusMap = Reflect.getMetadata(exports.EXCEPTION_METADATA_KEY, target, propertyKey) ?? new Map();
|
|
@@ -59,150 +29,6 @@ class Http {
|
|
|
59
29
|
})(target, propertyKey, descriptor);
|
|
60
30
|
};
|
|
61
31
|
}
|
|
62
|
-
static Get(pathOrOptions = {}) {
|
|
63
|
-
const options = this.getMethodOptions(pathOrOptions);
|
|
64
|
-
return this.decorateMethod(common_1.Get, options);
|
|
65
|
-
}
|
|
66
|
-
static Post(pathOrOptions = {}) {
|
|
67
|
-
const options = this.getMethodOptions(pathOrOptions);
|
|
68
|
-
return this.decorateMethod(common_1.Post, options);
|
|
69
|
-
}
|
|
70
|
-
static Put(pathOrOptions = {}) {
|
|
71
|
-
const options = this.getMethodOptions(pathOrOptions);
|
|
72
|
-
return this.decorateMethod(common_1.Put, options);
|
|
73
|
-
}
|
|
74
|
-
static Patch(pathOrOptions = {}) {
|
|
75
|
-
const options = this.getMethodOptions(pathOrOptions);
|
|
76
|
-
return this.decorateMethod(common_1.Patch, options);
|
|
77
|
-
}
|
|
78
|
-
static Delete(pathOrOptions = {}) {
|
|
79
|
-
const options = this.getMethodOptions(pathOrOptions);
|
|
80
|
-
return this.decorateMethod(common_1.Delete, options);
|
|
81
|
-
}
|
|
82
|
-
static Options(pathOrOptions = {}) {
|
|
83
|
-
const options = this.getMethodOptions(pathOrOptions);
|
|
84
|
-
return this.decorateMethod(common_1.Options, options);
|
|
85
|
-
}
|
|
86
|
-
static Search(pathOrOptions = {}) {
|
|
87
|
-
const options = this.getMethodOptions(pathOrOptions);
|
|
88
|
-
return this.decorateMethod(common_1.Search, options);
|
|
89
|
-
}
|
|
90
|
-
static All(pathOrOptions = {}) {
|
|
91
|
-
const options = this.getMethodOptions(pathOrOptions);
|
|
92
|
-
return this.decorateMethod(common_1.All, options);
|
|
93
|
-
}
|
|
94
|
-
static Query(field, schema) {
|
|
95
|
-
return (target, propertyKey, parameterIndex) => {
|
|
96
|
-
const args = this.getInputDecoratorArgs({
|
|
97
|
-
target,
|
|
98
|
-
propertyKey,
|
|
99
|
-
parameterIndex,
|
|
100
|
-
primitiveSchema: schema ?? null,
|
|
101
|
-
field,
|
|
102
|
-
});
|
|
103
|
-
(0, common_1.Query)(...args)(target, propertyKey, parameterIndex);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
static Body(field, schema) {
|
|
107
|
-
return (target, propertyKey, parameterIndex) => {
|
|
108
|
-
const args = this.getInputDecoratorArgs({
|
|
109
|
-
target,
|
|
110
|
-
propertyKey,
|
|
111
|
-
parameterIndex,
|
|
112
|
-
primitiveSchema: schema ?? null,
|
|
113
|
-
field,
|
|
114
|
-
});
|
|
115
|
-
(0, common_1.Body)(...args)(target, propertyKey, parameterIndex);
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
static Param(field, schema) {
|
|
119
|
-
return (target, propertyKey, parameterIndex) => {
|
|
120
|
-
const args = this.getInputDecoratorArgs({
|
|
121
|
-
target,
|
|
122
|
-
propertyKey,
|
|
123
|
-
parameterIndex,
|
|
124
|
-
primitiveSchema: schema ?? null,
|
|
125
|
-
field,
|
|
126
|
-
});
|
|
127
|
-
(0, common_1.Param)(...args)(target, propertyKey, parameterIndex);
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
static getControllerOptions(options) {
|
|
131
|
-
const path = this.getPathFromOptions(options);
|
|
132
|
-
const tags = this.getTagsFromOptions(options);
|
|
133
|
-
return {
|
|
134
|
-
path,
|
|
135
|
-
tags,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
static getMethodOptions(options) {
|
|
139
|
-
const path = this.getPathFromOptions(options);
|
|
140
|
-
const tags = this.getTagsFromOptions(options);
|
|
141
|
-
return {
|
|
142
|
-
path,
|
|
143
|
-
tags,
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
static getPathFromOptions(optionsOrPath) {
|
|
147
|
-
if (typeof optionsOrPath === 'string') {
|
|
148
|
-
return [optionsOrPath];
|
|
149
|
-
}
|
|
150
|
-
if (Array.isArray(optionsOrPath)) {
|
|
151
|
-
return optionsOrPath;
|
|
152
|
-
}
|
|
153
|
-
return Array.isArray(optionsOrPath.path) ? optionsOrPath.path : [optionsOrPath.path ?? '/'];
|
|
154
|
-
}
|
|
155
|
-
static getTagsFromOptions(options) {
|
|
156
|
-
if (typeof options === 'string' || Array.isArray(options)) {
|
|
157
|
-
return [];
|
|
158
|
-
}
|
|
159
|
-
const { tags = [] } = options;
|
|
160
|
-
return Array.isArray(tags) ? tags : [tags];
|
|
161
|
-
}
|
|
162
|
-
static decorateMethod(decorator, options) {
|
|
163
|
-
const { path, tags } = options;
|
|
164
|
-
return (target, propertyKey, descriptor) => {
|
|
165
|
-
decorator(path)(target, propertyKey, descriptor);
|
|
166
|
-
(0, swagger_1.ApiTags)(...tags)(target, propertyKey, descriptor);
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
static getInputDecoratorArgs(params) {
|
|
170
|
-
const { target, propertyKey, parameterIndex, primitiveSchema, field } = params;
|
|
171
|
-
const { dto, autoResolved } = this.getArgumentSchema({
|
|
172
|
-
target,
|
|
173
|
-
propertyKey,
|
|
174
|
-
parameterIndex,
|
|
175
|
-
primitiveSchema,
|
|
176
|
-
});
|
|
177
|
-
const args = typeof field === 'string' ? [field] : [];
|
|
178
|
-
if (autoResolved) {
|
|
179
|
-
args.push(middlewares_1.ValidationPipe.getInstance());
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
args.push(new middlewares_1.ValidationPipe(dto));
|
|
183
|
-
}
|
|
184
|
-
return args;
|
|
185
|
-
}
|
|
186
|
-
static getArgumentSchema(params) {
|
|
187
|
-
const { target, propertyKey, parameterIndex, primitiveSchema } = params;
|
|
188
|
-
const metatype = Reflect.getMetadata(PARAM_TYPES_METADATA, target, propertyKey);
|
|
189
|
-
strict_1.default.ok(Array.isArray(metatype));
|
|
190
|
-
const argMetaType = metatype[parameterIndex];
|
|
191
|
-
if (!argMetaType) {
|
|
192
|
-
throw new exception_1.WillNeverHappenedException('Argument metadata not found');
|
|
193
|
-
}
|
|
194
|
-
const isPrimitive = [String, Number, BigInt, Boolean].includes(argMetaType);
|
|
195
|
-
if (isPrimitive || primitiveSchema) {
|
|
196
|
-
if (!primitiveSchema) {
|
|
197
|
-
throw new exception_1.InvalidInputException('Schema not passed for primitive argument with decorator');
|
|
198
|
-
}
|
|
199
|
-
return { dto: primitiveSchema, autoResolved: false };
|
|
200
|
-
}
|
|
201
|
-
if (!(0, validation_1.isZodDto)(argMetaType)) {
|
|
202
|
-
throw new exception_1.InvalidInputException('Object argument for decorated method is not validation schema class');
|
|
203
|
-
}
|
|
204
|
-
return { dto: argMetaType.schema, autoResolved: true };
|
|
205
|
-
}
|
|
206
32
|
}
|
|
207
33
|
exports.Http = Http;
|
|
208
34
|
//# sourceMappingURL=decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators/decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators/decorators.ts"],"names":[],"mappings":";;;AACA,kDAAiD;AAEjD,6CAA8C;AAE9C,8CAAuE;AACvE,0CAA+C;AAIlC,QAAA,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAEvE,MAAa,IAAI;IAChB,gBAAuB,CAAC;IAEjB,MAAM,CAAC,eAAe,CAAC,SAAsC,EAAE,UAAkB;QACvF,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,UAA8B,EAAE,EAAE;YACpF,MAAM,SAAS,GACd,OAAO,CAAC,WAAW,CAAC,8BAAsB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;YAE/E,IAAI,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,mDAAsC,CAAC,SAAS,CAAC,CAAC;YAC7D,CAAC;YAED,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YACrC,OAAO,CAAC,cAAc,CAAC,8BAAsB,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;YAE/E,MAAM,iBAAiB,GAAG,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;YAEnD,MAAM,OAAO,GAAG,iBAAiB;iBAC/B,MAAM,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,EAAE,EAAE,CAAC,mBAAmB,KAAK,UAAU,CAAC;iBACvE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,2BAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;iBACjD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;iBACxB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,yBAAY,EAAC,IAAI,CAAC,CAAC;iBAC/B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAa,CAAC,CAAC;YAElC,IAAA,qBAAW,EAAC;gBACX,MAAM,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE;gBAC9D,MAAM,EAAE,UAAU;aAClB,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QACrC,CAAC,CAAC;IACH,CAAC;CACD;AA9BD,oBA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-controller.module.d.ts","sourceRoot":"","sources":["../src/http-controller.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-controller.module.d.ts","sourceRoot":"","sources":["../src/http-controller.module.ts"],"names":[],"mappings":"AAaA,qBAiBa,oBAAoB;CAAG"}
|
|
@@ -2,14 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpControllerModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const core_1 = require("@nestjs/core");
|
|
7
|
+
const middlewares_1 = require("./middlewares");
|
|
6
8
|
const services_1 = require("./services");
|
|
7
|
-
const services = [services_1.SwaggerService];
|
|
8
9
|
let HttpControllerModule = class HttpControllerModule {
|
|
9
10
|
};
|
|
10
11
|
exports.HttpControllerModule = HttpControllerModule;
|
|
11
12
|
exports.HttpControllerModule = HttpControllerModule = tslib_1.__decorate([
|
|
12
|
-
(0,
|
|
13
|
-
|
|
13
|
+
(0, common_1.Module)({
|
|
14
|
+
providers: [
|
|
15
|
+
services_1.SwaggerService,
|
|
16
|
+
{
|
|
17
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
18
|
+
useClass: middlewares_1.ExceptionMapperInterceptor,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
22
|
+
useClass: middlewares_1.DatabaseInterceptor,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
provide: core_1.APP_PIPE,
|
|
26
|
+
useClass: middlewares_1.ValidationPipe,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
})
|
|
14
30
|
], HttpControllerModule);
|
|
15
31
|
//# sourceMappingURL=http-controller.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-controller.module.js","sourceRoot":"","sources":["../src/http-controller.module.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"http-controller.module.js","sourceRoot":"","sources":["../src/http-controller.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,uCAGsB;AACtB,+CAIuB;AAEvB,yCAA4C;AAmBrC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oDAAoB;+BAApB,oBAAoB;IAjBhC,IAAA,eAAM,EAAC;QACP,SAAS,EAAE;YACV,yBAAc;YACd;gBACC,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE,wCAA0B;aACpC;YACD;gBACC,OAAO,EAAE,sBAAe;gBACxB,QAAQ,EAAE,iCAAmB;aAC7B;YACD;gBACC,OAAO,EAAE,eAAQ;gBACjB,QAAQ,EAAE,4BAAc;aACxB;SACD;KACD,CAAC;GACW,oBAAoB,CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.interceptor.d.ts","sourceRoot":"","sources":["../../src/middlewares/database.interceptor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"database.interceptor.d.ts","sourceRoot":"","sources":["../../src/middlewares/database.interceptor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EACN,WAAW,EAEX,gBAAgB,EAEhB,eAAe,EAEf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAGN,UAAU,EACV,MAAM,MAAM,CAAC;AAEd,qBACa,mBAAoB,YAAW,eAAe;IAE1D,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAIlC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAc;IAExC,SAAS,CACf,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,WAAW,GACf,UAAU,CAAC,GAAG,CAAC;CASlB"}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatabaseInterceptor = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const knex_1 = require("@hg-ts/knex");
|
|
6
6
|
const logger_1 = require("@hg-ts/logger");
|
|
7
|
-
const postgres_1 = require("@hg-ts/postgres");
|
|
8
7
|
const common_1 = require("@nestjs/common");
|
|
9
8
|
const rxjs_1 = require("rxjs");
|
|
10
9
|
let DatabaseInterceptor = class DatabaseInterceptor {
|
|
@@ -21,12 +20,13 @@ let DatabaseInterceptor = class DatabaseInterceptor {
|
|
|
21
20
|
};
|
|
22
21
|
exports.DatabaseInterceptor = DatabaseInterceptor;
|
|
23
22
|
tslib_1.__decorate([
|
|
24
|
-
(0,
|
|
23
|
+
(0, common_1.Inject)(),
|
|
25
24
|
tslib_1.__metadata("design:type", logger_1.Logger)
|
|
26
25
|
], DatabaseInterceptor.prototype, "logger", void 0);
|
|
27
26
|
tslib_1.__decorate([
|
|
28
|
-
(0,
|
|
29
|
-
|
|
27
|
+
(0, common_1.Optional)(),
|
|
28
|
+
(0, common_1.Inject)(),
|
|
29
|
+
tslib_1.__metadata("design:type", knex_1.KnexService)
|
|
30
30
|
], DatabaseInterceptor.prototype, "postgresService", void 0);
|
|
31
31
|
exports.DatabaseInterceptor = DatabaseInterceptor = tslib_1.__decorate([
|
|
32
32
|
(0, common_1.Catch)()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.interceptor.js","sourceRoot":"","sources":["../../src/middlewares/database.interceptor.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"database.interceptor.js","sourceRoot":"","sources":["../../src/middlewares/database.interceptor.ts"],"names":[],"mappings":";;;;AAAA,sCAA0C;AAC1C,0CAAuC;AAEvC,2CAOwB;AAExB,+BAIc;AAGP,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEZ,MAAM,CAAS;IAIjB,eAAe,CAAe;IAExC,SAAS,CACf,QAA0B,EAC1B,IAAiB;QAEjB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;YACpD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;QACD,MAAM,oBAAoB,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,KAAK,IAAG,EAAE,CAAC,IAAA,oBAAa,EAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAE5G,OAAO,IAAA,WAAI,EAAC,oBAAoB,CAAC,CAAC;IACnC,CAAC;CACD,CAAA;AApBY,kDAAmB;AAEZ;IADlB,IAAA,eAAM,GAAE;sCACkB,eAAM;mDAAC;AAIjB;IAFhB,IAAA,iBAAQ,GAAE;IACV,IAAA,eAAM,GAAE;sCAC0B,kBAAW;4DAAC;8BANnC,mBAAmB;IAD/B,IAAA,cAAK,GAAE;GACK,mBAAmB,CAoB/B"}
|
|
@@ -6,5 +6,6 @@ export declare class ExceptionMapperInterceptor implements NestInterceptor {
|
|
|
6
6
|
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
7
7
|
private getExceptionMap;
|
|
8
8
|
private getExceptionCtor;
|
|
9
|
+
private getException;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=exception-mapper.interceptor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception-mapper.interceptor.d.ts","sourceRoot":"","sources":["../../src/middlewares/exception-mapper.interceptor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exception-mapper.interceptor.d.ts","sourceRoot":"","sources":["../../src/middlewares/exception-mapper.interceptor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EACN,WAAW,EAEX,gBAAgB,EAEhB,eAAe,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,UAAU,EAEV,MAAM,MAAM,CAAC;AAMd,qBACa,0BAA2B,YAAW,eAAe;IAEjE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAE3B,SAAS,CACf,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,GACf,UAAU,CAAC,GAAG,CAAC;IAelB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,YAAY;CAWpB"}
|
|
@@ -3,20 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExceptionMapperInterceptor = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const exception_1 = require("@hg-ts/exception");
|
|
6
|
-
const ioc_1 = require("@hg-ts/ioc");
|
|
7
6
|
const logger_1 = require("@hg-ts/logger");
|
|
8
7
|
const validation_1 = require("@hg-ts/validation");
|
|
9
8
|
const common_1 = require("@nestjs/common");
|
|
10
|
-
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
11
9
|
const rxjs_1 = require("rxjs");
|
|
12
10
|
const decorators_1 = require("../decorators");
|
|
13
11
|
let ExceptionMapperInterceptor = class ExceptionMapperInterceptor {
|
|
14
12
|
logger;
|
|
15
13
|
intercept(context, next) {
|
|
16
14
|
return next.handle().pipe((0, rxjs_1.tap)({
|
|
17
|
-
error:
|
|
18
|
-
|
|
19
|
-
strict_1.default.ok(exception instanceof exception_1.BaseException);
|
|
15
|
+
error: error => {
|
|
16
|
+
const exception = this.getException(error);
|
|
20
17
|
const exceptionMap = this.getExceptionMap(context);
|
|
21
18
|
const exceptionCtor = this.getExceptionCtor(exception);
|
|
22
19
|
const response = context.switchToHttp().getResponse();
|
|
@@ -35,10 +32,19 @@ let ExceptionMapperInterceptor = class ExceptionMapperInterceptor {
|
|
|
35
32
|
getExceptionCtor(exception) {
|
|
36
33
|
return Object.getPrototypeOf(exception).constructor;
|
|
37
34
|
}
|
|
35
|
+
getException(exception) {
|
|
36
|
+
if (exception instanceof exception_1.BaseException) {
|
|
37
|
+
return exception;
|
|
38
|
+
}
|
|
39
|
+
if (exception instanceof Error) {
|
|
40
|
+
return new exception_1.ErrorException(exception);
|
|
41
|
+
}
|
|
42
|
+
return new exception_1.ErrorException(new Error(String(exception)));
|
|
43
|
+
}
|
|
38
44
|
};
|
|
39
45
|
exports.ExceptionMapperInterceptor = ExceptionMapperInterceptor;
|
|
40
46
|
tslib_1.__decorate([
|
|
41
|
-
(0,
|
|
47
|
+
(0, common_1.Inject)(),
|
|
42
48
|
tslib_1.__metadata("design:type", logger_1.Logger)
|
|
43
49
|
], ExceptionMapperInterceptor.prototype, "logger", void 0);
|
|
44
50
|
exports.ExceptionMapperInterceptor = ExceptionMapperInterceptor = tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception-mapper.interceptor.js","sourceRoot":"","sources":["../../src/middlewares/exception-mapper.interceptor.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"exception-mapper.interceptor.js","sourceRoot":"","sources":["../../src/middlewares/exception-mapper.interceptor.ts"],"names":[],"mappings":";;;;AAAA,gDAG0B;AAC1B,0CAAuC;AACvC,kDAAwD;AAExD,2CAMwB;AAExB,+BAGc;AACd,8CAGuB;AAGhB,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAEnB,MAAM,CAAS;IAE3B,SAAS,CACf,OAAyB,EACzB,IAAiB;QAEjB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC;YAC7B,KAAK,EAAE,KAAK,CAAC,EAAE;gBACd,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;gBACnD,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;gBAEvD,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAgB,CAAC;gBACpE,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAE/C,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;YACzD,CAAC;SACD,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,eAAe,CAAC,OAAyB;QAChD,MAAM,YAAY,GAAiB,OAAO,CAAC,WAAW,CACrD,mCAAsB,EACtB,OAAO,CAAC,QAAQ,EAAE,CAAC,SAAS,EAC5B,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,CACzB,IAAI,IAAI,GAAG,EAAE,CAAC;QAEf,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,gCAAmB,CAAC,EAAE,CAAC;YAC5C,YAAY,CAAC,GAAG,CAAC,gCAAmB,EAAE,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,YAAY,CAAC;IACrB,CAAC;IAEO,gBAAgB,CAA0B,SAAY;QAC7D,OAAO,MAAM,CAAC,cAAc,CAAC,SAAS,CAAE,CAAC,WAA8B,CAAC;IACzE,CAAC;IAGO,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;AAnDY,gEAA0B;AAEnB;IADlB,IAAA,eAAM,GAAE;sCACkB,eAAM;0DAAC;qCAFtB,0BAA0B;IADtC,IAAA,cAAK,GAAE;GACK,0BAA0B,CAmDtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./validation.pipe"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./exception-handler"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./exception-mapper.interceptor"), exports);
|
|
7
6
|
tslib_1.__exportStar(require("./database.interceptor"), exports);
|
|
8
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,yEAA+C;AAC/C,iEAAuC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INestApplication } from '@nestjs/common';
|
|
2
2
|
export declare class SwaggerService {
|
|
3
|
-
|
|
4
|
-
[INIT_HOOK](): Promise<void>;
|
|
3
|
+
setup(app: INestApplication): void;
|
|
5
4
|
private patchSwaggerModule;
|
|
6
5
|
}
|
|
7
6
|
//# sourceMappingURL=swagger.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger.service.d.ts","sourceRoot":"","sources":["../../src/services/swagger.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swagger.service.d.ts","sourceRoot":"","sources":["../../src/services/swagger.service.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQlD,qBAAa,cAAc;IACnB,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI;IAYzC,OAAO,CAAC,kBAAkB;CAc1B"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SwaggerService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const exception_1 = require("@hg-ts/exception");
|
|
6
|
-
const ioc_1 = require("@hg-ts/ioc");
|
|
7
5
|
const validation_1 = require("@hg-ts/validation");
|
|
8
6
|
const swagger_1 = require("@nestjs/swagger");
|
|
9
7
|
const schema_object_factory_1 = require("@nestjs/swagger/dist/services/schema-object-factory");
|
|
10
8
|
class SwaggerService {
|
|
11
|
-
|
|
12
|
-
async [ioc_1.INIT_HOOK]() {
|
|
13
|
-
const { app } = this.appProxy;
|
|
9
|
+
setup(app) {
|
|
14
10
|
this.patchSwaggerModule();
|
|
15
11
|
const config = new swagger_1.DocumentBuilder()
|
|
16
12
|
.setOpenAPIVersion('3.0.0')
|
|
@@ -29,8 +25,4 @@ class SwaggerService {
|
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
27
|
exports.SwaggerService = SwaggerService;
|
|
32
|
-
tslib_1.__decorate([
|
|
33
|
-
(0, ioc_1.Dependency)(),
|
|
34
|
-
tslib_1.__metadata("design:type", ioc_1.AppProxy)
|
|
35
|
-
], SwaggerService.prototype, "appProxy", void 0);
|
|
36
28
|
//# sourceMappingURL=swagger.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger.service.js","sourceRoot":"","sources":["../../src/services/swagger.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swagger.service.js","sourceRoot":"","sources":["../../src/services/swagger.service.ts"],"names":[],"mappings":";;;AAAA,gDAA8D;AAC9D,kDAG2B;AAG3B,6CAGyB;AAEzB,+FAA0F;AAE1F,MAAa,cAAc;IACnB,KAAK,CAAC,GAAqB;QACjC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAE1B,MAAM,MAAM,GAAG,IAAI,yBAAe,EAAE;aAClC,iBAAiB,CAAC,OAAO,CAAC;aAC1B,KAAK,EAAE,CAAC;QAEV,MAAM,QAAQ,GAAG,uBAAa,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAE3D,uBAAa,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9E,CAAC;IAEO,kBAAkB;QACzB,2CAAmB,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAClD,IAA4B,EAC5B,OAA2C;YAE3C,IAAI,CAAC,IAAA,qBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC;gBACrB,MAAM,IAAI,sCAA0B,CAAC,yBAAyB,CAAC,CAAC;YACjE,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;YAEtD,OAAO,IAAI,CAAC,IAAI,CAAC;QAClB,CAAC,CAAC;IACH,CAAC;CACD;AA3BD,wCA2BC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { TestContainer } from '@hg-ts/ioc';
|
|
2
1
|
import { Suite } from '@hg-ts/tests';
|
|
2
|
+
import { INestApplication } from '@nestjs/common';
|
|
3
|
+
import { TestingModule } from '@nestjs/testing';
|
|
3
4
|
import { AxiosInstance } from 'axios';
|
|
4
5
|
export declare abstract class BaseControllerSuite extends Suite {
|
|
5
|
-
protected
|
|
6
|
+
protected module: TestingModule;
|
|
7
|
+
protected container: INestApplication;
|
|
6
8
|
protected client: AxiosInstance;
|
|
7
9
|
private readonly moduleCtor;
|
|
8
10
|
constructor(moduleCtor: Class<any, any[]>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-controller-suite.d.ts","sourceRoot":"","sources":["../../../src/tests/abstracts/base-controller-suite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-controller-suite.d.ts","sourceRoot":"","sources":["../../../src/tests/abstracts/base-controller-suite.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAEN,aAAa,EACb,MAAM,iBAAiB,CAAC;AAEzB,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG7C,8BAAsB,mBAAoB,SAAQ,KAAK;IACtD,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;IAChC,SAAS,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACtC,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;IAgBtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/C,SAAS,CAAC,QAAQ,CAAC,OAAO,IAAI,MAAM;CACpC"}
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseControllerSuite = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const logger_1 = require("@hg-ts/logger");
|
|
6
6
|
const tests_1 = require("@hg-ts/tests");
|
|
7
|
+
const platform_fastify_1 = require("@nestjs/platform-fastify");
|
|
8
|
+
const testing_1 = require("@nestjs/testing");
|
|
7
9
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
10
|
+
const http_controller_module_1 = require("../../http-controller.module");
|
|
8
11
|
class BaseControllerSuite extends tests_1.Suite {
|
|
12
|
+
module;
|
|
9
13
|
container;
|
|
10
14
|
client;
|
|
11
15
|
moduleCtor;
|
|
@@ -14,15 +18,17 @@ class BaseControllerSuite extends tests_1.Suite {
|
|
|
14
18
|
this.moduleCtor = moduleCtor;
|
|
15
19
|
}
|
|
16
20
|
async setUp() {
|
|
17
|
-
this.
|
|
21
|
+
this.module = await testing_1.Test
|
|
22
|
+
.createTestingModule({ imports: [this.moduleCtor, logger_1.LoggerModule, http_controller_module_1.HttpControllerModule] })
|
|
23
|
+
.compile();
|
|
18
24
|
const port = this.getPort();
|
|
25
|
+
this.container = this.module.createNestApplication(new platform_fastify_1.FastifyAdapter());
|
|
19
26
|
await this.container.init();
|
|
20
|
-
await this.container.
|
|
27
|
+
await this.container.listen(port, 'localhost');
|
|
21
28
|
this.client = axios_1.default.create({ baseURL: `http://localhost:${port}` });
|
|
22
29
|
}
|
|
23
30
|
async tearDown() {
|
|
24
|
-
await this.container.
|
|
25
|
-
await this.container.shutdown();
|
|
31
|
+
await this.container.close();
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
exports.BaseControllerSuite = BaseControllerSuite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-controller-suite.js","sourceRoot":"","sources":["../../../src/tests/abstracts/base-controller-suite.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"base-controller-suite.js","sourceRoot":"","sources":["../../../src/tests/abstracts/base-controller-suite.ts"],"names":[],"mappings":";;;;AAAA,0CAA6C;AAC7C,wCAAqC;AAGrC,+DAA0D;AAC1D,6CAGyB;AAEzB,0DAA6C;AAC7C,yEAAoE;AAEpE,MAAsB,mBAAoB,SAAQ,aAAK;IAC5C,MAAM,CAAgB;IACtB,SAAS,CAAmB;IAC5B,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,MAAM,GAAG,MAAM,cAAW;aAC7B,mBAAmB,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,qBAAY,EAAE,6CAAoB,CAAC,EAAE,CAAC;aACvF,OAAO,EAAE,CAAC;QAEZ,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAG5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,iCAAc,EAAE,CAAC,CAAC;QAEzE,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAE/C,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,oBAAoB,IAAI,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;IAEe,KAAK,CAAC,QAAQ;QAC7B,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CAGD;AAjCD,kDAiCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tests/echo/controllers/dto/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tests/echo/controllers/dto/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
|
@@ -3,5 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./echo-get.query"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./echo-post.body"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./echo-get-field.query"), exports);
|
|
7
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/tests/echo/controllers/dto/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,2DAAiC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/tests/echo/controllers/dto/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,2DAAiC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { EchoGetQuery, EchoPostBody } from './dto';
|
|
2
2
|
export declare class EchoController {
|
|
3
3
|
getEchoQuery(query: EchoGetQuery): Promise<EchoGetQuery>;
|
|
4
|
-
getEchoQueryField(query: number): Promise<number>;
|
|
5
4
|
getEchoParam(params: EchoGetQuery): Promise<EchoGetQuery>;
|
|
6
|
-
getEchoParamField(param: number): Promise<number>;
|
|
7
5
|
postEchoQuery(query: EchoGetQuery): Promise<EchoGetQuery>;
|
|
8
6
|
postEchoBody(body: EchoPostBody): Promise<EchoPostBody>;
|
|
9
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echo.controller.d.ts","sourceRoot":"","sources":["../../../../src/tests/echo/controllers/echo.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"echo.controller.d.ts","sourceRoot":"","sources":["../../../../src/tests/echo/controllers/echo.controller.ts"],"names":[],"mappings":"AASA,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,MAAM,OAAO,CAAC;AAEf,qBAEa,cAAc;IAEb,YAAY,CACf,KAAK,EAAE,YAAY,GAC1B,OAAO,CAAC,YAAY,CAAC;IAKX,YAAY,CACf,MAAM,EAAE,YAAY,GAC3B,OAAO,CAAC,YAAY,CAAC;IAKX,aAAa,CAChB,KAAK,EAAE,YAAY,GAC1B,OAAO,CAAC,YAAY,CAAC;IAKX,YAAY,CAChB,IAAI,EAAE,YAAY,GACxB,OAAO,CAAC,YAAY,CAAC;CAGxB"}
|