@steroidsjs/nest 1.6.6 → 1.7.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.
Files changed (114) hide show
  1. package/infrastructure/applications/AppModule.d.ts +2 -0
  2. package/infrastructure/applications/AppModule.js +7 -0
  3. package/infrastructure/applications/AppModule.js.map +1 -0
  4. package/infrastructure/applications/BaseApplication.d.ts +8 -0
  5. package/infrastructure/applications/BaseApplication.js +24 -0
  6. package/infrastructure/applications/BaseApplication.js.map +1 -0
  7. package/infrastructure/applications/IAppModuleConfig.d.ts +17 -0
  8. package/infrastructure/applications/IAppModuleConfig.js +3 -0
  9. package/infrastructure/applications/IAppModuleConfig.js.map +1 -0
  10. package/infrastructure/applications/base/config.d.ts +10 -0
  11. package/infrastructure/applications/base/config.js +37 -0
  12. package/infrastructure/applications/base/config.js.map +1 -0
  13. package/infrastructure/applications/console/ConsoleApplication.d.ts +7 -0
  14. package/infrastructure/applications/console/ConsoleApplication.js +27 -0
  15. package/infrastructure/applications/console/ConsoleApplication.js.map +1 -0
  16. package/infrastructure/applications/console/IConsoleAppModuleConfig.d.ts +4 -0
  17. package/infrastructure/applications/console/IConsoleAppModuleConfig.js +3 -0
  18. package/infrastructure/applications/console/IConsoleAppModuleConfig.js.map +1 -0
  19. package/infrastructure/applications/console/config.d.ts +12 -0
  20. package/infrastructure/applications/console/config.js +23 -0
  21. package/infrastructure/applications/console/config.js.map +1 -0
  22. package/infrastructure/applications/rest/IRestAppModuleConfig.d.ts +8 -0
  23. package/infrastructure/applications/rest/IRestAppModuleConfig.js +3 -0
  24. package/infrastructure/applications/rest/IRestAppModuleConfig.js.map +1 -0
  25. package/infrastructure/applications/rest/RestApplication.d.ts +17 -0
  26. package/infrastructure/applications/rest/RestApplication.js +106 -0
  27. package/infrastructure/applications/rest/RestApplication.js.map +1 -0
  28. package/infrastructure/applications/rest/SchemaSerializer.d.ts +4 -0
  29. package/infrastructure/applications/rest/SchemaSerializer.js +12 -0
  30. package/infrastructure/applications/rest/SchemaSerializer.js.map +1 -0
  31. package/infrastructure/applications/rest/SentryExceptionFilter.d.ts +4 -0
  32. package/infrastructure/applications/rest/SentryExceptionFilter.js +64 -0
  33. package/infrastructure/applications/rest/SentryExceptionFilter.js.map +1 -0
  34. package/infrastructure/applications/rest/config.d.ts +18 -0
  35. package/infrastructure/applications/rest/config.js +17 -0
  36. package/infrastructure/applications/rest/config.js.map +1 -0
  37. package/infrastructure/applications/rest/exceptions/RequestExecutionException.d.ts +8 -0
  38. package/infrastructure/applications/rest/exceptions/RequestExecutionException.js +18 -0
  39. package/infrastructure/applications/rest/exceptions/RequestExecutionException.js.map +1 -0
  40. package/infrastructure/applications/rest/filters/RequestExecutionExceptionFilter.d.ts +5 -0
  41. package/infrastructure/applications/rest/filters/RequestExecutionExceptionFilter.js +30 -0
  42. package/infrastructure/applications/rest/filters/RequestExecutionExceptionFilter.js.map +1 -0
  43. package/infrastructure/applications/rest/filters/ValidationExceptionFilterCustom.d.ts +10 -0
  44. package/infrastructure/applications/rest/filters/ValidationExceptionFilterCustom.js +49 -0
  45. package/infrastructure/applications/rest/filters/ValidationExceptionFilterCustom.js.map +1 -0
  46. package/infrastructure/commands/MigrateCommand.js.map +1 -1
  47. package/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.js.map +1 -1
  48. package/infrastructure/decorators/Computable.d.ts +1 -1
  49. package/infrastructure/decorators/Module.d.ts +9 -0
  50. package/infrastructure/decorators/Module.js +32 -0
  51. package/infrastructure/decorators/Module.js.map +1 -0
  52. package/infrastructure/decorators/Transform.d.ts +2 -2
  53. package/infrastructure/decorators/fields/BaseField.d.ts +2 -2
  54. package/infrastructure/decorators/fields/DateField.js +1 -1
  55. package/infrastructure/decorators/fields/DateField.js.map +1 -1
  56. package/infrastructure/decorators/fields/DecimalField.js +1 -1
  57. package/infrastructure/decorators/fields/DecimalField.js.map +1 -1
  58. package/infrastructure/decorators/fields/RelationField.d.ts +1 -1
  59. package/infrastructure/decorators/fields/index.d.ts +1 -1
  60. package/infrastructure/filters/UserExceptionFilter.js.map +1 -1
  61. package/infrastructure/filters/ValidationExceptionFilter.js.map +1 -1
  62. package/infrastructure/helpers/ModuleHelper.d.ts +10 -1
  63. package/infrastructure/helpers/ModuleHelper.js +30 -2
  64. package/infrastructure/helpers/ModuleHelper.js.map +1 -1
  65. package/infrastructure/helpers/typeORM/ConditionHelperTypeORM.d.ts +4 -4
  66. package/infrastructure/pipes/CreateDtoPipe.js.map +1 -1
  67. package/infrastructure/schemas/SearchSchema.js.map +1 -1
  68. package/infrastructure/tests/app/models/ArticleModel.js.map +1 -1
  69. package/infrastructure/tests/app/models/CommentModel.js.map +1 -1
  70. package/infrastructure/tests/app/models/FileModel.js.map +1 -1
  71. package/infrastructure/tests/app/models/ImageModel.js.map +1 -1
  72. package/infrastructure/tests/app/models/TagModel.js.map +1 -1
  73. package/infrastructure/tests/app/models/UserInfoModel.js.map +1 -1
  74. package/infrastructure/tests/app/models/UserModel.js.map +1 -1
  75. package/infrastructure/tests/app/repositories/ArticleRepository.js.map +1 -1
  76. package/infrastructure/tests/app/repositories/CommentRepository.js.map +1 -1
  77. package/infrastructure/tests/app/repositories/FileRepository.js.map +1 -1
  78. package/infrastructure/tests/app/repositories/ImageRepository.js.map +1 -1
  79. package/infrastructure/tests/app/repositories/TagRepository.js.map +1 -1
  80. package/infrastructure/tests/app/repositories/UserRepository.js.map +1 -1
  81. package/infrastructure/tests/app/schemas/ArticleSchema.js.map +1 -1
  82. package/infrastructure/tests/app/schemas/FileSchema.js.map +1 -1
  83. package/infrastructure/tests/app/schemas/ImageSchema.js.map +1 -1
  84. package/infrastructure/tests/app/schemas/UserInfoSchema.js.map +1 -1
  85. package/infrastructure/tests/app/schemas/UserSchema.js.map +1 -1
  86. package/infrastructure/tests/app/services/ArticleService.js.map +1 -1
  87. package/infrastructure/tests/app/services/CommentService.js.map +1 -1
  88. package/infrastructure/tests/app/services/FileService.js.map +1 -1
  89. package/infrastructure/tests/app/services/ImageService.js.map +1 -1
  90. package/infrastructure/tests/app/services/TagService.js.map +1 -1
  91. package/infrastructure/tests/app/services/UserService.js.map +1 -1
  92. package/infrastructure/tests/app/tables/ArticleTable.js.map +1 -1
  93. package/infrastructure/tests/app/tables/CommentTable.js.map +1 -1
  94. package/infrastructure/tests/app/tables/FileTable.js.map +1 -1
  95. package/infrastructure/tests/app/tables/ImageTable.js.map +1 -1
  96. package/infrastructure/tests/app/tables/TagTable.js.map +1 -1
  97. package/infrastructure/tests/app/tables/UserInfoTable.js.map +1 -1
  98. package/infrastructure/tests/app/tables/UserTable.js.map +1 -1
  99. package/infrastructure/tests/bootstrap.js +0 -6
  100. package/infrastructure/tests/bootstrap.js.map +1 -1
  101. package/package.json +25 -25
  102. package/tsconfig.tsbuildinfo +1 -1
  103. package/usecases/base/SearchQuery.d.ts +1 -1
  104. package/usecases/dtos/SearchInputDto.js.map +1 -1
  105. package/usecases/interfaces/ICrudRepository.d.ts +2 -2
  106. package/usecases/interfaces/IDeepPartial.d.ts +1 -1
  107. package/usecases/interfaces/IType.d.ts +3 -0
  108. package/usecases/interfaces/IType.js +3 -0
  109. package/usecases/interfaces/IType.js.map +1 -0
  110. package/usecases/services/CrudService.d.ts +4 -4
  111. package/usecases/services/CrudService.js.map +1 -1
  112. package/usecases/services/ReadService.d.ts +4 -4
  113. package/usecases/services/ReadService.js.map +1 -1
  114. package/usecases/validators/Validator.d.ts +1 -1
@@ -0,0 +1,2 @@
1
+ export declare class AppModule {
2
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppModule = void 0;
4
+ class AppModule {
5
+ }
6
+ exports.AppModule = AppModule;
7
+ //# sourceMappingURL=AppModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppModule.js","sourceRoot":"","sources":["../../../src/infrastructure/applications/AppModule.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAS;CAAG;AAAzB,8BAAyB"}
@@ -0,0 +1,8 @@
1
+ export declare abstract class BaseApplication {
2
+ protected _config: any;
3
+ protected init(): Promise<void>;
4
+ protected initEnv(): void;
5
+ protected initConfig(): void;
6
+ protected initModules(): void;
7
+ abstract start(): any;
8
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseApplication = void 0;
4
+ const dotenv = require("dotenv");
5
+ const ModuleHelper_1 = require("../helpers/ModuleHelper");
6
+ class BaseApplication {
7
+ async init() {
8
+ this.initEnv();
9
+ this.initConfig();
10
+ this.initModules();
11
+ }
12
+ initEnv() {
13
+ process.env.APP_IS_CLI = '1';
14
+ process.env.APP_ENVIRONMENT = process.env.APP_ENVIRONMENT || 'dev';
15
+ dotenv.config();
16
+ }
17
+ initConfig() {
18
+ }
19
+ initModules() {
20
+ ModuleHelper_1.ModuleHelper.runInitializers();
21
+ }
22
+ }
23
+ exports.BaseApplication = BaseApplication;
24
+ //# sourceMappingURL=BaseApplication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseApplication.js","sourceRoot":"","sources":["../../../src/infrastructure/applications/BaseApplication.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,0DAAqD;AAErD,MAAsB,eAAe;IAGvB,KAAK,CAAC,IAAI;QAChB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAES,OAAO;QACb,OAAO,CAAC,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,KAAK,CAAC;QAEnE,MAAM,CAAC,MAAM,EAAE,CAAC;IACpB,CAAC;IAES,UAAU;IAEpB,CAAC;IAES,WAAW;QACjB,2BAAY,CAAC,eAAe,EAAE,CAAC;IACnC,CAAC;CAGJ;AAzBD,0CAyBC"}
@@ -0,0 +1,17 @@
1
+ export interface IAppModuleConfig {
2
+ name: string;
3
+ title: string;
4
+ version: string;
5
+ database?: {
6
+ host: string;
7
+ port: number;
8
+ database: string;
9
+ username: string;
10
+ password: string;
11
+ [key: string]: any;
12
+ };
13
+ sentry?: {
14
+ dsn: string;
15
+ environment: string;
16
+ };
17
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAppModuleConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAppModuleConfig.js","sourceRoot":"","sources":["../../../src/infrastructure/applications/IAppModuleConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { AppModule } from '../AppModule';
2
+ import { IAppModuleConfig } from '../IAppModuleConfig';
3
+ declare const _default: {
4
+ rootTarget: typeof AppModule;
5
+ config: () => IAppModuleConfig;
6
+ module: (config: IAppModuleConfig) => {
7
+ imports: import("@nestjs/common").DynamicModule[];
8
+ };
9
+ };
10
+ export default _default;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const nest_typeorm_1 = require("@steroidsjs/nest-typeorm");
4
+ const nestjs_sentry_1 = require("@ntegral/nestjs-sentry");
5
+ const ModuleHelper_1 = require("../../helpers/ModuleHelper");
6
+ const AppModule_1 = require("../AppModule");
7
+ const DatabaseNamingStrategy_1 = require("../../base/DatabaseNamingStrategy");
8
+ exports.default = {
9
+ rootTarget: AppModule_1.AppModule,
10
+ config: () => ({
11
+ name: 'app',
12
+ title: 'App',
13
+ version: '1.0',
14
+ database: {
15
+ type: 'postgres',
16
+ host: process.env.APP_DATABASE_HOST,
17
+ port: parseInt(process.env.APP_DATABASE_PORT, 10),
18
+ database: process.env.APP_DATABASE_NAME,
19
+ username: process.env.APP_DATABASE_USERNAME,
20
+ password: process.env.APP_DATABASE_PASSWORD,
21
+ synchronize: false,
22
+ migrationsRun: false,
23
+ logging: ['schema', 'warn', 'error', 'migration'],
24
+ namingStrategy: new DatabaseNamingStrategy_1.DatabaseNamingStrategy(),
25
+ },
26
+ }),
27
+ module: (config) => ({
28
+ imports: [
29
+ nest_typeorm_1.TypeOrmModule.forRoot(Object.assign(Object.assign({}, config.database), { entities: ModuleHelper_1.ModuleHelper.getEntities() })),
30
+ config.sentry && nestjs_sentry_1.SentryModule.forRoot({
31
+ dsn: config.sentry.dsn,
32
+ environment: config.sentry.environment || process.env.APP_ENVIRONMENT,
33
+ }),
34
+ ].filter(Boolean),
35
+ }),
36
+ };
37
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/base/config.ts"],"names":[],"mappings":";;AAAA,2DAA6E;AAE7E,0DAAoD;AACpD,6DAAwD;AACxD,4CAAuC;AAEvC,8EAAyE;AAEzE,kBAAe;IACX,UAAU,EAAE,qBAAS;IACrB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACX,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE;YACN,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;YACnC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC;YACjD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;YACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC3C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC3C,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAgB;YAChE,cAAc,EAAE,IAAI,+CAAsB,EAAE;SAClB;KACZ,CAAA;IACtB,MAAM,EAAE,CAAC,MAAwB,EAAE,EAAE,CAAC,CAAC;QACnC,OAAO,EAAE;YACL,4BAAa,CAAC,OAAO,CAAC,gCACf,MAAM,CAAC,QAAQ,KAClB,QAAQ,EAAE,2BAAY,CAAC,WAAW,EAAE,GACf,CAAC;YAC1B,MAAM,CAAC,MAAM,IAAI,4BAAY,CAAC,OAAO,CAAC;gBAClC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;gBACtB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe;aACxE,CAAC;SACL,CAAC,MAAM,CAAC,OAAO,CAAC;KACpB,CAAC;CACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { BaseApplication } from '../BaseApplication';
2
+ export declare class ConsoleApplication extends BaseApplication {
3
+ protected _app: any;
4
+ protected _moduleClass: any;
5
+ constructor(AppModule: any);
6
+ start(): Promise<void>;
7
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsoleApplication = void 0;
4
+ const core_1 = require("@nestjs/core");
5
+ const nestjs_command_1 = require("nestjs-command");
6
+ const BaseApplication_1 = require("../BaseApplication");
7
+ class ConsoleApplication extends BaseApplication_1.BaseApplication {
8
+ constructor(AppModule) {
9
+ super();
10
+ this._moduleClass = AppModule;
11
+ }
12
+ async start() {
13
+ this._app = await core_1.NestFactory.createApplicationContext(this._moduleClass, {
14
+ logger: ['warn', 'error'],
15
+ });
16
+ await this.init();
17
+ try {
18
+ await this._app.select(nestjs_command_1.CommandModule).get(nestjs_command_1.CommandService).exec();
19
+ }
20
+ catch (error) {
21
+ console.error(error);
22
+ }
23
+ await this._app.close();
24
+ }
25
+ }
26
+ exports.ConsoleApplication = ConsoleApplication;
27
+ //# sourceMappingURL=ConsoleApplication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleApplication.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/console/ConsoleApplication.ts"],"names":[],"mappings":";;;AAAA,uCAAyC;AACzC,mDAA6D;AAC7D,wDAAmD;AAEnD,MAAa,kBAAmB,SAAQ,iCAAe;IAKnD,YAAY,SAAS;QACjB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAClC,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,IAAI,CAAC,IAAI,GAAG,MAAM,kBAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,YAAY,EAAE;YACtE,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;SAC5B,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAElB,IAAI;YACA,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,8BAAa,CAAC,CAAC,GAAG,CAAC,+BAAc,CAAC,CAAC,IAAI,EAAE,CAAC;SACpE;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACxB;QAED,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACJ;AA1BD,gDA0BC"}
@@ -0,0 +1,4 @@
1
+ import { IAppModuleConfig } from '../IAppModuleConfig';
2
+ export interface IConsoleAppModuleConfig extends IAppModuleConfig {
3
+ todo?: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IConsoleAppModuleConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IConsoleAppModuleConfig.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/console/IConsoleAppModuleConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { IConsoleAppModuleConfig } from './IConsoleAppModuleConfig';
2
+ import { EntityCodeGenerateCommand } from '../../commands/entity-generator/EntityCodeGenerateCommand';
3
+ import { MigrateCommand } from '../../commands/MigrateCommand';
4
+ declare const _default: {
5
+ config: () => IConsoleAppModuleConfig;
6
+ module: (config: IConsoleAppModuleConfig) => {
7
+ providers: (typeof EntityCodeGenerateCommand | typeof MigrateCommand)[];
8
+ imports: import("@nestjs/common").DynamicModule[];
9
+ };
10
+ rootTarget: typeof import("../AppModule").AppModule;
11
+ };
12
+ export default _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ const fs = require("node:fs");
5
+ const config_1 = require("../base/config");
6
+ const EntityCodeGenerateCommand_1 = require("../../commands/entity-generator/EntityCodeGenerateCommand");
7
+ const MigrateCommand_1 = require("../../commands/MigrateCommand");
8
+ const moduleNames = fs.readdirSync(process.cwd());
9
+ const isMigrateCommand = !!(process.argv || []).find(arg => /^migrate/.exec(arg));
10
+ exports.default = Object.assign(Object.assign({}, config_1.default), { config: () => {
11
+ const config = config_1.default.config();
12
+ return Object.assign(Object.assign({}, config), { database: Object.assign(Object.assign({}, config.database), { migrations: isMigrateCommand
13
+ ? moduleNames.map(name => (0, path_1.join)(__dirname, `../${name}/infrastructure/migrations/*{.ts,.js}`))
14
+ : [], migrationsTableName: 'migrations' }), api: {
15
+ corsAllowDomains: [
16
+ '127.0.0.1:9996',
17
+ ],
18
+ } });
19
+ }, module: (config) => (Object.assign(Object.assign({}, config_1.default.module(config)), { providers: [
20
+ EntityCodeGenerateCommand_1.EntityCodeGenerateCommand,
21
+ MigrateCommand_1.MigrateCommand,
22
+ ] })) });
23
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/console/config.ts"],"names":[],"mappings":";;AACA,+BAA0B;AAC1B,8BAA8B;AAC9B,2CAAwC;AAExC,yGAAoG;AACpG,kEAA6D;AAE7D,MAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAElF,kDACO,gBAAU,KACb,MAAM,EAAE,GAAG,EAAE;QACT,MAAM,MAAM,GAAG,gBAAU,CAAC,MAAM,EAAE,CAAC;QACnC,OAAO,gCACA,MAAM,KACT,QAAQ,EAAE,gCACH,MAAM,CAAC,QAAQ,KAClB,UAAU,EAAE,gBAAgB;oBACxB,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,MAAM,IAAI,uCAAuC,CAAC,CAAC;oBAC7F,CAAC,CAAC,EAAE,EACR,mBAAmB,EAAE,YAAY,GACP,EAC9B,GAAG,EAAE;gBACD,gBAAgB,EAAE;oBACd,gBAAgB;iBACnB;aACJ,GACuB,CAAC;IACjC,CAAC,EACD,MAAM,EAAE,CAAC,MAA+B,EAAE,EAAE,CAAC,iCACtC,gBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,KAC5B,SAAS,EAAE;YACP,qDAAyB;YACzB,+BAAc;SACjB,IACH,IACJ"}
@@ -0,0 +1,8 @@
1
+ import { IAppModuleConfig } from '../IAppModuleConfig';
2
+ export interface IRestAppModuleConfig extends IAppModuleConfig {
3
+ cors?: {
4
+ allowDomains?: string[];
5
+ allowMethods?: string[];
6
+ allowHeaders?: string[];
7
+ };
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IRestAppModuleConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRestAppModuleConfig.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/IRestAppModuleConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { IRestAppModuleConfig } from './IRestAppModuleConfig';
2
+ import { BaseApplication } from '../BaseApplication';
3
+ export declare class RestApplication extends BaseApplication {
4
+ protected _app: any;
5
+ protected _moduleClass: any;
6
+ protected _config: IRestAppModuleConfig;
7
+ constructor(AppModule: any);
8
+ protected initConfig(): void;
9
+ protected initSwagger(): void;
10
+ protected initCors(): void;
11
+ protected initPipes(): void;
12
+ protected initFilters(): void;
13
+ protected initSentry(): void;
14
+ protected initInterceptors(): void;
15
+ protected init(): Promise<void>;
16
+ start(): Promise<void>;
17
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RestApplication = void 0;
4
+ const core_1 = require("@nestjs/core");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const common_1 = require("@nestjs/common");
7
+ const SentryExceptionFilter_1 = require("./SentryExceptionFilter");
8
+ const SchemaSerializer_1 = require("./SchemaSerializer");
9
+ const CreateDtoPipe_1 = require("../../pipes/CreateDtoPipe");
10
+ const ValidationExceptionFilter_1 = require("../../filters/ValidationExceptionFilter");
11
+ const UserExceptionFilter_1 = require("../../filters/UserExceptionFilter");
12
+ const BaseApplication_1 = require("../BaseApplication");
13
+ const ModuleHelper_1 = require("../../helpers/ModuleHelper");
14
+ class RestApplication extends BaseApplication_1.BaseApplication {
15
+ constructor(AppModule) {
16
+ super();
17
+ this._moduleClass = AppModule;
18
+ }
19
+ initConfig() {
20
+ const custom = ModuleHelper_1.ModuleHelper.getConfig(this._moduleClass);
21
+ this._config = Object.assign(Object.assign({}, custom), { cors: Object.assign({ allowHeaders: [
22
+ 'Origin',
23
+ 'X-Requested-With',
24
+ 'Content-Type',
25
+ 'Accept',
26
+ 'Authorization',
27
+ 'Admin-Authorization',
28
+ 'X-CSRF-Token',
29
+ 'If-None-Match',
30
+ 'If-Modified-Since',
31
+ 'Cache-Control',
32
+ 'X-Requested-With',
33
+ 'Content-Disposition',
34
+ 'Content-Range',
35
+ ], allowMethods: [
36
+ 'POST',
37
+ 'PUT',
38
+ 'GET',
39
+ 'OPTIONS',
40
+ 'DELETE',
41
+ ] }, custom === null || custom === void 0 ? void 0 : custom.cors) });
42
+ }
43
+ initSwagger() {
44
+ const swaggerConfig = new swagger_1.DocumentBuilder()
45
+ .setTitle(this._config.title || 'Application')
46
+ .setDescription('Документация REST API')
47
+ .setVersion(this._config.version || '1.0')
48
+ .build();
49
+ const document = swagger_1.SwaggerModule.createDocument(this._app, swaggerConfig);
50
+ swagger_1.SwaggerModule.setup('/api/docs', this._app, document);
51
+ this._app.setGlobalPrefix('/api/v1');
52
+ this._app.enableVersioning({
53
+ type: common_1.VersioningType.URI,
54
+ });
55
+ }
56
+ initCors() {
57
+ const origin = [];
58
+ (this._config.cors.allowDomains || []).forEach(domain => {
59
+ if (domain.indexOf('://') !== -1) {
60
+ origin.push(domain);
61
+ }
62
+ else {
63
+ origin.push('https://' + domain);
64
+ origin.push('http://' + domain);
65
+ }
66
+ });
67
+ this._app.enableCors({
68
+ credentials: true,
69
+ origin,
70
+ methods: this._config.cors.allowMethods,
71
+ allowedHeaders: this._config.cors.allowHeaders,
72
+ });
73
+ }
74
+ initPipes() {
75
+ this._app.useGlobalPipes(new CreateDtoPipe_1.CreateDtoPipe());
76
+ }
77
+ initFilters() {
78
+ this._app.useGlobalFilters(new ValidationExceptionFilter_1.ValidationExceptionFilter());
79
+ this._app.useGlobalFilters(new UserExceptionFilter_1.UserExceptionFilter());
80
+ }
81
+ initSentry() {
82
+ if (process.env.APP_SENTRY_DSN) {
83
+ this._app.useGlobalFilters(new SentryExceptionFilter_1.SentryExceptionFilter());
84
+ }
85
+ }
86
+ initInterceptors() {
87
+ this._app.useGlobalInterceptors(new SchemaSerializer_1.SchemaSerializer(this._app.get(core_1.Reflector)));
88
+ }
89
+ async init() {
90
+ await super.init();
91
+ this._app = await core_1.NestFactory.create(this._moduleClass);
92
+ this.initSwagger();
93
+ this.initCors();
94
+ this.initPipes();
95
+ this.initFilters();
96
+ this.initSentry();
97
+ this.initInterceptors();
98
+ }
99
+ async start() {
100
+ await this.init();
101
+ const port = parseInt(process.env.PORT, 10);
102
+ await this._app.listen(port, () => console.log(`Server started http://localhost:${port}`));
103
+ }
104
+ }
105
+ exports.RestApplication = RestApplication;
106
+ //# sourceMappingURL=RestApplication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestApplication.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/RestApplication.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ import { ClassSerializerInterceptor, PlainLiteralObject } from '@nestjs/common';
2
+ export declare class SchemaSerializer extends ClassSerializerInterceptor {
3
+ transformToPlain(data: any, options: any): PlainLiteralObject;
4
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaSerializer = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const DataMapper_1 = require("../../../usecases/helpers/DataMapper");
6
+ class SchemaSerializer extends common_1.ClassSerializerInterceptor {
7
+ transformToPlain(data, options) {
8
+ return DataMapper_1.DataMapper.create(Object, data);
9
+ }
10
+ }
11
+ exports.SchemaSerializer = SchemaSerializer;
12
+ //# sourceMappingURL=SchemaSerializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaSerializer.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/SchemaSerializer.ts"],"names":[],"mappings":";;;AAAA,2CAA8E;AAC9E,qEAAgE;AAEhE,MAAa,gBAAiB,SAAQ,mCAA0B;IAC5D,gBAAgB,CAAC,IAAS,EAAE,OAAY;QACpC,OAAO,uBAAU,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;CACJ;AAJD,4CAIC"}
@@ -0,0 +1,4 @@
1
+ import { ExceptionFilter, ArgumentsHost } from '@nestjs/common';
2
+ export declare class SentryExceptionFilter implements ExceptionFilter {
3
+ catch(exception: Error, host: ArgumentsHost): void;
4
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.SentryExceptionFilter = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const Sentry = require("@sentry/node");
12
+ const uuid_1 = require("uuid");
13
+ let SentryExceptionFilter = class SentryExceptionFilter {
14
+ catch(exception, host) {
15
+ var _a;
16
+ const ctx = host.switchToHttp();
17
+ const response = ctx.getResponse();
18
+ if (exception instanceof common_1.HttpException) {
19
+ const exceptionResponse = exception.getResponse();
20
+ let payload = {
21
+ statusCode: exception.getStatus(),
22
+ message: exception.message,
23
+ };
24
+ if (typeof exceptionResponse === 'object') {
25
+ payload = Object.assign(Object.assign({}, payload), exceptionResponse);
26
+ }
27
+ else {
28
+ payload.response = exceptionResponse;
29
+ }
30
+ response
31
+ .status(exception.getStatus())
32
+ .json(payload);
33
+ return;
34
+ }
35
+ const request = ctx.getRequest();
36
+ const errorUid = (0, uuid_1.v4)();
37
+ const context = {
38
+ tags: {
39
+ errorUid,
40
+ },
41
+ extra: Object.assign({ errorUid, url: request.url }, request.headers),
42
+ user: {
43
+ id: (_a = request === null || request === void 0 ? void 0 : request.user) === null || _a === void 0 ? void 0 : _a.id,
44
+ },
45
+ };
46
+ Sentry.captureException(exception, context);
47
+ exception.message = 'Внутренняя ошибка сервера. ' + exception.message || '';
48
+ if (errorUid) {
49
+ exception.message += ` Ошибка #${errorUid}`;
50
+ }
51
+ const message = exception.message;
52
+ response
53
+ .status(common_1.HttpStatus.INTERNAL_SERVER_ERROR)
54
+ .json({
55
+ statusCode: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
56
+ message,
57
+ });
58
+ }
59
+ };
60
+ SentryExceptionFilter = __decorate([
61
+ (0, common_1.Catch)(Error)
62
+ ], SentryExceptionFilter);
63
+ exports.SentryExceptionFilter = SentryExceptionFilter;
64
+ //# sourceMappingURL=SentryExceptionFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SentryExceptionFilter.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/SentryExceptionFilter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgG;AAEhG,uCAAuC;AACvC,+BAAoC;AAI7B,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,KAAK,CAAC,SAAgB,EAAE,IAAmB;;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAE7C,IAAI,SAAS,YAAY,sBAAa,EAAE;YACpC,MAAM,iBAAiB,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YAClD,IAAI,OAAO,GAAQ;gBACf,UAAU,EAAE,SAAS,CAAC,SAAS,EAAE;gBACjC,OAAO,EAAE,SAAS,CAAC,OAAO;aAC7B,CAAC;YACF,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;gBACvC,OAAO,mCAAO,OAAO,GAAK,iBAAiB,CAAC,CAAC;aAChD;iBAAM;gBACH,OAAO,CAAC,QAAQ,GAAG,iBAAiB,CAAC;aACxC;YACD,QAAQ;iBACH,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;iBAC7B,IAAI,CAAC,OAAO,CAAC,CAAC;YACnB,OAAO;SACV;QAED,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,IAAA,SAAM,GAAE,CAAC;QAE1B,MAAM,OAAO,GAAmB;YAC5B,IAAI,EAAE;gBACF,QAAQ;aACX;YACD,KAAK,kBACD,QAAQ,EACR,GAAG,EAAE,OAAO,CAAC,GAAG,IACb,OAAO,CAAC,OAAO,CACrB;YACD,IAAI,EAAE;gBACF,EAAE,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,0CAAE,EAAE;aACxB;SACJ,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE5C,SAAS,CAAC,OAAO,GAAG,6BAA6B,GAAG,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC;QAC5E,IAAI,QAAQ,EAAE;YACV,SAAS,CAAC,OAAO,IAAI,YAAY,QAAQ,EAAE,CAAC;SAC/C;QAED,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;QAClC,QAAQ;aACH,MAAM,CAAC,mBAAU,CAAC,qBAAqB,CAAC;aACxC,IAAI,CAAC;YACF,UAAU,EAAE,mBAAU,CAAC,qBAAqB;YAC5C,OAAO;SACV,CAAC,CAAC;IACX,CAAC;CACJ,CAAA;AAtDY,qBAAqB;IADjC,IAAA,cAAK,EAAC,KAAK,CAAC;GACA,qBAAqB,CAsDjC;AAtDY,sDAAqB"}
@@ -0,0 +1,18 @@
1
+ import { IRestAppModuleConfig } from './IRestAppModuleConfig';
2
+ import { ValidationExceptionFilterCustom } from './filters/ValidationExceptionFilterCustom';
3
+ import { RequestExecutionExceptionFilter } from './filters/RequestExecutionExceptionFilter';
4
+ declare const _default: {
5
+ module: (config: IRestAppModuleConfig) => {
6
+ providers: ({
7
+ provide: string;
8
+ useClass: typeof ValidationExceptionFilterCustom;
9
+ } | {
10
+ provide: string;
11
+ useClass: typeof RequestExecutionExceptionFilter;
12
+ })[];
13
+ imports: import("@nestjs/common").DynamicModule[];
14
+ };
15
+ rootTarget: typeof import("../AppModule").AppModule;
16
+ config: () => import("../IAppModuleConfig").IAppModuleConfig;
17
+ };
18
+ export default _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@nestjs/core");
4
+ const config_1 = require("../base/config");
5
+ const ValidationExceptionFilterCustom_1 = require("./filters/ValidationExceptionFilterCustom");
6
+ const RequestExecutionExceptionFilter_1 = require("./filters/RequestExecutionExceptionFilter");
7
+ exports.default = Object.assign(Object.assign({}, config_1.default), { module: (config) => (Object.assign(Object.assign({}, config_1.default.module(config)), { providers: [
8
+ {
9
+ provide: core_1.APP_FILTER,
10
+ useClass: ValidationExceptionFilterCustom_1.ValidationExceptionFilterCustom,
11
+ },
12
+ {
13
+ provide: core_1.APP_FILTER,
14
+ useClass: RequestExecutionExceptionFilter_1.RequestExecutionExceptionFilter,
15
+ },
16
+ ] })) });
17
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/infrastructure/applications/rest/config.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AACxC,2CAAwC;AAExC,+FAA0F;AAC1F,+FAA0F;AAE1F,kDACO,gBAAU,KACb,MAAM,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,iCACnC,gBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,KAC5B,SAAS,EAAE;YACP;gBACI,OAAO,EAAE,iBAAU;gBACnB,QAAQ,EAAE,iEAA+B;aAC5C;YACD;gBACI,OAAO,EAAE,iBAAU;gBACnB,QAAQ,EAAE,iEAA+B;aAC5C;SACJ,IACH,IACJ"}
@@ -0,0 +1,8 @@
1
+ import { HttpStatus } from '@nestjs/common';
2
+ export declare class RequestExecutionException {
3
+ message: any;
4
+ status: HttpStatus;
5
+ constructor(message: string);
6
+ getStatus(): number;
7
+ getMessage(): string;
8
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestExecutionException = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ class RequestExecutionException {
6
+ constructor(message) {
7
+ this.status = common_1.HttpStatus.INTERNAL_SERVER_ERROR;
8
+ this.message = message;
9
+ }
10
+ getStatus() {
11
+ return this.status;
12
+ }
13
+ getMessage() {
14
+ return this.message;
15
+ }
16
+ }
17
+ exports.RequestExecutionException = RequestExecutionException;
18
+ //# sourceMappingURL=RequestExecutionException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestExecutionException.js","sourceRoot":"","sources":["../../../../../src/infrastructure/applications/rest/exceptions/RequestExecutionException.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAQ1C,MAAa,yBAAyB;IAKlC,YAAY,OAAe;QAFpB,WAAM,GAAG,mBAAU,CAAC,qBAAqB,CAAC;QAG7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,SAAS;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEM,UAAU;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAhBD,8DAgBC"}
@@ -0,0 +1,5 @@
1
+ import { ExceptionFilter, ArgumentsHost } from '@nestjs/common';
2
+ import { RequestExecutionException } from '../exceptions/RequestExecutionException';
3
+ export declare class RequestExecutionExceptionFilter implements ExceptionFilter {
4
+ catch(exception: RequestExecutionException, host: ArgumentsHost): void;
5
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.RequestExecutionExceptionFilter = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const RequestExecutionException_1 = require("../exceptions/RequestExecutionException");
12
+ let RequestExecutionExceptionFilter = class RequestExecutionExceptionFilter {
13
+ catch(exception, host) {
14
+ const ctx = host.switchToHttp();
15
+ const response = ctx.getResponse();
16
+ const status = exception.getStatus();
17
+ const message = exception.getMessage();
18
+ response
19
+ .status(status)
20
+ .json({
21
+ statusCode: status,
22
+ message,
23
+ });
24
+ }
25
+ };
26
+ RequestExecutionExceptionFilter = __decorate([
27
+ (0, common_1.Catch)(RequestExecutionException_1.RequestExecutionException)
28
+ ], RequestExecutionExceptionFilter);
29
+ exports.RequestExecutionExceptionFilter = RequestExecutionExceptionFilter;
30
+ //# sourceMappingURL=RequestExecutionExceptionFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestExecutionExceptionFilter.js","sourceRoot":"","sources":["../../../../../src/infrastructure/applications/rest/filters/RequestExecutionExceptionFilter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAqE;AAErE,uFAAkF;AAG3E,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IACxC,KAAK,CAAC,SAAoC,EAAE,IAAmB;QAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAE7C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;QAEvC,QAAQ;aACH,MAAM,CAAC,MAAM,CAAC;aACd,IAAI,CAAC;YACF,UAAU,EAAE,MAAM;YAClB,OAAO;SACV,CAAC,CAAC;IACX,CAAC;CACJ,CAAA;AAfY,+BAA+B;IAD3C,IAAA,cAAK,EAAC,qDAAyB,CAAC;GACpB,+BAA+B,CAe3C;AAfY,0EAA+B"}
@@ -0,0 +1,10 @@
1
+ import { ExceptionFilter, ArgumentsHost } from '@nestjs/common';
2
+ import { ValidationException } from '../../../../usecases/exceptions';
3
+ type ErrorsCompositeObject = {
4
+ [propertyName: string]: string[] | ErrorsCompositeObject;
5
+ };
6
+ export declare class ValidationExceptionFilterCustom implements ExceptionFilter {
7
+ parseErrors(errors: any, contextLanguage: string): Promise<ErrorsCompositeObject>;
8
+ catch(exception: ValidationException, host: ArgumentsHost): Promise<void>;
9
+ }
10
+ export {};