@nest-omni/core 3.1.1-19 → 3.1.1-21
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/common/dto/dto-container.d.ts +9 -0
- package/common/dto/dto-container.js +59 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +59 -0
- package/common/dto/dto-extensions.d.ts +12 -0
- package/common/dto/dto-extensions.js +63 -0
- package/common/dto/dto-service-accessor.d.ts +7 -0
- package/common/dto/dto-service-accessor.js +49 -0
- package/common/dto/dto-transformer.d.ts +11 -0
- package/common/dto/dto-transformer.js +49 -0
- package/common/dto/index.d.ts +6 -0
- package/common/dto/index.js +6 -0
- package/package.json +1 -1
- package/setup/bootstrap.setup.js +7 -2
- package/shared/serviceRegistryModule.js +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class DtoContainer {
|
|
2
|
+
private static instance;
|
|
3
|
+
private container;
|
|
4
|
+
static getInstance(): DtoContainer;
|
|
5
|
+
static useContainer(container: any): void;
|
|
6
|
+
static get<T = any>(serviceToken: string | symbol | any): Promise<T | null>;
|
|
7
|
+
static isInitialized(): boolean;
|
|
8
|
+
static reset(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DtoContainer = void 0;
|
|
13
|
+
class DtoContainer {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.container = null;
|
|
16
|
+
}
|
|
17
|
+
static getInstance() {
|
|
18
|
+
if (!DtoContainer.instance) {
|
|
19
|
+
DtoContainer.instance = new DtoContainer();
|
|
20
|
+
}
|
|
21
|
+
return DtoContainer.instance;
|
|
22
|
+
}
|
|
23
|
+
static useContainer(container) {
|
|
24
|
+
DtoContainer.getInstance().container = container;
|
|
25
|
+
}
|
|
26
|
+
static get(serviceToken) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const instance = DtoContainer.getInstance();
|
|
29
|
+
if (!instance.container) {
|
|
30
|
+
console.warn('DTO Container not initialized. Please call DtoContainer.useContainer(container) in your bootstrap.');
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
if (typeof instance.container.get === 'function') {
|
|
35
|
+
return yield instance.container.get(serviceToken);
|
|
36
|
+
}
|
|
37
|
+
else if (typeof instance.container.resolve === 'function') {
|
|
38
|
+
return yield instance.container.resolve(serviceToken);
|
|
39
|
+
}
|
|
40
|
+
else if (typeof instance.container[serviceToken] === 'function') {
|
|
41
|
+
return instance.container[serviceToken];
|
|
42
|
+
}
|
|
43
|
+
console.warn(`Unable to resolve service: ${String(serviceToken)}`);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.warn(`Failed to resolve service: ${String(serviceToken)}`, error instanceof Error ? error.message : error);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
static isInitialized() {
|
|
53
|
+
return DtoContainer.getInstance().container !== null;
|
|
54
|
+
}
|
|
55
|
+
static reset() {
|
|
56
|
+
DtoContainer.getInstance().container = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.DtoContainer = DtoContainer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Constructor } from '../types';
|
|
2
|
+
import { TransformFnParams } from 'class-transformer';
|
|
3
|
+
export interface ExtendedTransformFnParams extends TransformFnParams {
|
|
4
|
+
context?: any;
|
|
5
|
+
}
|
|
6
|
+
export declare const DTO_SERVICE_KEY = "dto:service-name";
|
|
7
|
+
export declare function DtoService(serviceName?: string): ClassDecorator;
|
|
8
|
+
export declare const DTO_REQUIRED_SERVICES_KEY = "dto:required-services";
|
|
9
|
+
export declare function UseServices(...serviceTokens: Array<string | Constructor<any>>): ClassDecorator;
|
|
10
|
+
export declare const DTO_ENTITY_KEY = "dto:entity";
|
|
11
|
+
export declare function Dto(entityClass: Constructor<any>): ClassDecorator;
|
|
12
|
+
export interface DtoFieldOptions {
|
|
13
|
+
source?: string;
|
|
14
|
+
transform?: (value: any) => any;
|
|
15
|
+
}
|
|
16
|
+
export declare function DtoField(source?: string, transform?: (value: any) => any): PropertyDecorator;
|
|
17
|
+
export declare function DtoField(options?: DtoFieldOptions): PropertyDecorator;
|
|
18
|
+
export declare function DtoComputed(computeFn: (entity: any, context?: any) => any): PropertyDecorator;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DTO_ENTITY_KEY = exports.DTO_REQUIRED_SERVICES_KEY = exports.DTO_SERVICE_KEY = void 0;
|
|
4
|
+
exports.DtoService = DtoService;
|
|
5
|
+
exports.UseServices = UseServices;
|
|
6
|
+
exports.Dto = Dto;
|
|
7
|
+
exports.DtoField = DtoField;
|
|
8
|
+
exports.DtoComputed = DtoComputed;
|
|
9
|
+
const common_1 = require("@nestjs/common");
|
|
10
|
+
exports.DTO_SERVICE_KEY = 'dto:service-name';
|
|
11
|
+
function DtoService(serviceName) {
|
|
12
|
+
return function (target) {
|
|
13
|
+
const name = serviceName || target.name;
|
|
14
|
+
(0, common_1.SetMetadata)(exports.DTO_SERVICE_KEY, name)(target);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.DTO_REQUIRED_SERVICES_KEY = 'dto:required-services';
|
|
18
|
+
function UseServices(...serviceTokens) {
|
|
19
|
+
return function (target) {
|
|
20
|
+
const tokens = serviceTokens.map(token => {
|
|
21
|
+
if (typeof token === 'string') {
|
|
22
|
+
return token;
|
|
23
|
+
}
|
|
24
|
+
return token.name.charAt(0).toLowerCase() + token.name.slice(1);
|
|
25
|
+
});
|
|
26
|
+
(0, common_1.SetMetadata)(exports.DTO_REQUIRED_SERVICES_KEY, tokens)(target);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.DTO_ENTITY_KEY = 'dto:entity';
|
|
30
|
+
function Dto(entityClass) {
|
|
31
|
+
return function (target) {
|
|
32
|
+
(0, common_1.SetMetadata)(exports.DTO_ENTITY_KEY, entityClass)(target);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function DtoField(sourceOrOptions, transform) {
|
|
36
|
+
const options = typeof sourceOrOptions === 'string'
|
|
37
|
+
? { source: sourceOrOptions, transform }
|
|
38
|
+
: sourceOrOptions || {};
|
|
39
|
+
return function (target, propertyKey) {
|
|
40
|
+
const fields = Reflect.getMetadata('dto:fields', target.constructor) || [];
|
|
41
|
+
fields.push({
|
|
42
|
+
property: propertyKey,
|
|
43
|
+
source: options.source || propertyKey,
|
|
44
|
+
transform: options.transform,
|
|
45
|
+
});
|
|
46
|
+
Reflect.defineMetadata('dto:fields', fields, target.constructor);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function DtoComputed(computeFn) {
|
|
50
|
+
return function (target, propertyKey) {
|
|
51
|
+
const fields = Reflect.getMetadata('dto:fields', target.constructor) || [];
|
|
52
|
+
fields.push({
|
|
53
|
+
property: propertyKey,
|
|
54
|
+
computeFn,
|
|
55
|
+
isComputed: true,
|
|
56
|
+
});
|
|
57
|
+
Reflect.defineMetadata('dto:fields', fields, target.constructor);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Constructor } from '../types';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Array<T> {
|
|
4
|
+
toDto<DtoType>(dtoClass: Constructor<DtoType>, context?: any): Promise<DtoType[]>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare module 'typeorm' {
|
|
8
|
+
interface SelectQueryBuilder<Entity> {
|
|
9
|
+
toDtoPage<DtoType>(pageOptionsDto: any, dtoClass: Constructor<DtoType>, context?: any): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare function transformEntityToDto<EntityType, DtoType>(entity: EntityType, dtoClass: Constructor<DtoType>, context?: any): Promise<DtoType>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.transformEntityToDto = transformEntityToDto;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const dto_transformer_1 = require("./dto-transformer");
|
|
15
|
+
Array.prototype.toDto = function (dtoClass, context) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if (!this || this.length === 0) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
return yield dto_transformer_1.DtoTransformer.transformArray(this, dtoClass, context);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
function transformEntityToDto(entity, dtoClass, context) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (!entity) {
|
|
26
|
+
throw new Error('Cannot transform null or undefined to DTO');
|
|
27
|
+
}
|
|
28
|
+
return yield dto_transformer_1.DtoTransformer.transform(entity, dtoClass, context);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
typeorm_1.SelectQueryBuilder.prototype.toDtoPage = function (pageOptionsDto, dtoClass, context) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const page = pageOptionsDto.page || 1;
|
|
34
|
+
const pageSize = pageOptionsDto.pageSize || 10;
|
|
35
|
+
const skip = (page - 1) * pageSize;
|
|
36
|
+
const totalItems = yield this.getCount();
|
|
37
|
+
const entities = yield this
|
|
38
|
+
.skip(skip)
|
|
39
|
+
.take(pageSize)
|
|
40
|
+
.getMany();
|
|
41
|
+
if (entities.length > 0) {
|
|
42
|
+
console.log('Raw entity sample:', JSON.stringify(entities[0], null, 2));
|
|
43
|
+
}
|
|
44
|
+
const data = yield entities.toDto(dtoClass, context);
|
|
45
|
+
if (data.length > 0) {
|
|
46
|
+
console.log('Converted DTO sample:', JSON.stringify(data[0], null, 2));
|
|
47
|
+
}
|
|
48
|
+
const itemCount = totalItems;
|
|
49
|
+
const pageCount = Math.ceil(itemCount / pageSize);
|
|
50
|
+
const hasPreviousPage = page > 1;
|
|
51
|
+
const hasNextPage = page < pageCount;
|
|
52
|
+
return {
|
|
53
|
+
data,
|
|
54
|
+
meta: {
|
|
55
|
+
itemCount,
|
|
56
|
+
page,
|
|
57
|
+
pageCount,
|
|
58
|
+
hasPreviousPage,
|
|
59
|
+
hasNextPage,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Constructor } from '../types';
|
|
2
|
+
export declare class DtoServiceAccessor {
|
|
3
|
+
static getService<T = any>(serviceToken: string | symbol | Constructor<any>): Promise<T | null>;
|
|
4
|
+
static getServices<T = any>(serviceTokens: Array<string | symbol | Constructor<any>>): Promise<Record<string, T>>;
|
|
5
|
+
static getServicesForDto(dtoClass: Constructor<any>): Promise<Record<string, any>>;
|
|
6
|
+
static isInitialized(): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DtoServiceAccessor = void 0;
|
|
13
|
+
const dto_container_1 = require("./dto-container");
|
|
14
|
+
class DtoServiceAccessor {
|
|
15
|
+
static getService(serviceToken) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
return yield dto_container_1.DtoContainer.get(serviceToken);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
static getServices(serviceTokens) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const services = {};
|
|
23
|
+
const promises = serviceTokens.map((token) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const serviceName = typeof token === 'string'
|
|
25
|
+
? token
|
|
26
|
+
: token.name || String(token);
|
|
27
|
+
const service = yield dto_container_1.DtoContainer.get(token);
|
|
28
|
+
if (service) {
|
|
29
|
+
services[serviceName] = service;
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
yield Promise.all(promises);
|
|
33
|
+
return services;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
static getServicesForDto(dtoClass) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const serviceTokens = Reflect.getMetadata('dto:required-services', dtoClass) || [];
|
|
39
|
+
if (serviceTokens.length === 0) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
return yield DtoServiceAccessor.getServices(serviceTokens);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
static isInitialized() {
|
|
46
|
+
return dto_container_1.DtoContainer.isInitialized();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.DtoServiceAccessor = DtoServiceAccessor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Constructor } from '../types';
|
|
2
|
+
export interface DtoTransformContext {
|
|
3
|
+
user?: any;
|
|
4
|
+
request?: any;
|
|
5
|
+
services?: Record<string, any>;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export declare class DtoTransformer {
|
|
9
|
+
static transform<EntityType, DtoType>(entity: EntityType, dtoClass: Constructor<DtoType>, context?: DtoTransformContext): Promise<DtoType>;
|
|
10
|
+
static transformArray<EntityType, DtoType>(entities: EntityType[], dtoClass: Constructor<DtoType>, context?: DtoTransformContext): Promise<DtoType[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DtoTransformer = void 0;
|
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
const dto_service_accessor_1 = require("./dto-service-accessor");
|
|
15
|
+
class DtoTransformer {
|
|
16
|
+
static transform(entity, dtoClass, context) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const services = yield dto_service_accessor_1.DtoServiceAccessor.getServicesForDto(dtoClass);
|
|
19
|
+
const options = {
|
|
20
|
+
excludeExtraneousValues: false,
|
|
21
|
+
exposeUnsetFields: true,
|
|
22
|
+
enableImplicitConversion: true,
|
|
23
|
+
enableCircularCheck: true,
|
|
24
|
+
ignoreDecorators: false,
|
|
25
|
+
context: Object.assign(Object.assign({}, context), { services }),
|
|
26
|
+
};
|
|
27
|
+
return (0, class_transformer_1.plainToInstance)(dtoClass, entity, options);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
static transformArray(entities, dtoClass, context) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
if (!entities || entities.length === 0) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const services = yield dto_service_accessor_1.DtoServiceAccessor.getServicesForDto(dtoClass);
|
|
36
|
+
const options = {
|
|
37
|
+
excludeExtraneousValues: false,
|
|
38
|
+
exposeUnsetFields: true,
|
|
39
|
+
enableImplicitConversion: true,
|
|
40
|
+
enableCircularCheck: true,
|
|
41
|
+
ignoreDecorators: false,
|
|
42
|
+
context: Object.assign(Object.assign({}, context), { services }),
|
|
43
|
+
};
|
|
44
|
+
const transformPromises = entities.map(entity => (0, class_transformer_1.plainToInstance)(dtoClass, entity, options));
|
|
45
|
+
return Promise.all(transformPromises);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.DtoTransformer = DtoTransformer;
|
package/common/dto/index.d.ts
CHANGED
|
@@ -4,3 +4,9 @@ export * from './create-translation.dto';
|
|
|
4
4
|
export * from './page.dto';
|
|
5
5
|
export * from './page-meta.dto';
|
|
6
6
|
export * from './page-options.dto';
|
|
7
|
+
export * from './dto-service-accessor';
|
|
8
|
+
export * from './dto-decorators';
|
|
9
|
+
export * from './dto-transformer';
|
|
10
|
+
export * from './dto-extensions';
|
|
11
|
+
export * from './dto-container';
|
|
12
|
+
import './dto-extensions';
|
package/common/dto/index.js
CHANGED
|
@@ -20,3 +20,9 @@ __exportStar(require("./create-translation.dto"), exports);
|
|
|
20
20
|
__exportStar(require("./page.dto"), exports);
|
|
21
21
|
__exportStar(require("./page-meta.dto"), exports);
|
|
22
22
|
__exportStar(require("./page-options.dto"), exports);
|
|
23
|
+
__exportStar(require("./dto-service-accessor"), exports);
|
|
24
|
+
__exportStar(require("./dto-decorators"), exports);
|
|
25
|
+
__exportStar(require("./dto-transformer"), exports);
|
|
26
|
+
__exportStar(require("./dto-extensions"), exports);
|
|
27
|
+
__exportStar(require("./dto-container"), exports);
|
|
28
|
+
require("./dto-extensions");
|
package/package.json
CHANGED
package/setup/bootstrap.setup.js
CHANGED
|
@@ -118,6 +118,7 @@ const nestjs_cls_1 = require("nestjs-cls");
|
|
|
118
118
|
const class_validator_1 = require("class-validator");
|
|
119
119
|
const setup_1 = require("@sentry/nestjs/setup");
|
|
120
120
|
const vault_1 = require("../vault");
|
|
121
|
+
const dto_1 = require("../common/dto");
|
|
121
122
|
function bootstrapSetup(AppModule, SetupSwagger) {
|
|
122
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
124
|
yield vault_1.VaultConfigLoader.loadVaultConfig();
|
|
@@ -126,7 +127,9 @@ function bootstrapSetup(AppModule, SetupSwagger) {
|
|
|
126
127
|
bufferLogs: true,
|
|
127
128
|
autoFlushLogs: true,
|
|
128
129
|
});
|
|
129
|
-
|
|
130
|
+
const appModuleRef = app.select(AppModule);
|
|
131
|
+
(0, class_validator_1.useContainer)(appModuleRef, { fallbackOnErrors: true });
|
|
132
|
+
dto_1.DtoContainer.useContainer(appModuleRef);
|
|
130
133
|
const configService = app.select(__1.ServiceRegistryModule).get(__1.ApiConfigService);
|
|
131
134
|
const logger = app.get(nestjs_pino_1.Logger);
|
|
132
135
|
app.useLogger(logger);
|
|
@@ -136,7 +139,9 @@ function bootstrapSetup(AppModule, SetupSwagger) {
|
|
|
136
139
|
app.enableShutdownHooks();
|
|
137
140
|
app.enableVersioning();
|
|
138
141
|
app.enable('trust proxy');
|
|
139
|
-
app.use(bodyParse.json({ limit: '50mb' }), new nestjs_cls_1.ClsMiddleware({
|
|
142
|
+
app.use(bodyParse.json({ limit: '50mb' }), new nestjs_cls_1.ClsMiddleware({
|
|
143
|
+
saveReq: true,
|
|
144
|
+
}).use, (0, __1.RequestIdMiddleware)(), (0, __1.PowerByMiddleware)(), (0, __1.OmniAuthMiddleware)(), compression());
|
|
140
145
|
const reflector = app.get(core_1.Reflector);
|
|
141
146
|
app.useGlobalFilters(new setup_1.SentryGlobalFilter(), new __1.HttpExceptionFilter(), new __1.QueryFailedFilter(reflector));
|
|
142
147
|
app.useGlobalInterceptors(new __1.LanguageInterceptor(), new __1.TranslationInterceptor(), new nestjs_pino_1.LoggerErrorInterceptor());
|