From c879964c9b5bc06d1e9ffc247b3f229030126913 Mon Sep 17 00:00:00 2001 From: Gsk54 Date: Tue, 24 Jan 2023 16:00:46 +0100 Subject: [PATCH 1/2] refactor --- package-lock.json | 9 +++------ package.json | 7 ++++++- .../adapters/secondaries/prisma-repository.abstract.ts | 2 -- .../{DatabaseException.ts => database.exception.ts} | 0 4 files changed, 9 insertions(+), 9 deletions(-) rename src/modules/database/src/exceptions/{DatabaseException.ts => database.exception.ts} (100%) diff --git a/package-lock.json b/package-lock.json index 71dba17..2fa8544 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "@types/supertest": "^2.0.11", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", + "class-transformer": "^0.5.1", "dotenv-cli": "^6.0.0" }, "devDependencies": { @@ -3633,9 +3634,7 @@ "node_modules/class-transformer": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", - "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", - "optional": true, - "peer": true + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==" }, "node_modules/class-validator": { "version": "0.14.0", @@ -11679,9 +11678,7 @@ "class-transformer": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", - "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", - "optional": true, - "peer": true + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==" }, "class-validator": { "version": "0.14.0", diff --git a/package.json b/package.json index bc59ff7..a750cb4 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@types/supertest": "^2.0.11", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", + "class-transformer": "^0.5.1", "dotenv-cli": "^6.0.0" }, "devDependencies": { @@ -70,7 +71,11 @@ "json", "ts" ], - "modulePathIgnorePatterns": [".controller.ts",".module.ts","main.ts"], + "modulePathIgnorePatterns": [ + ".controller.ts", + ".module.ts", + "main.ts" + ], "rootDir": "src", "testRegex": ".*\\.spec\\.ts$", "transform": { diff --git a/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts b/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts index 10f7b10..f8c5bf9 100644 --- a/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts +++ b/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts @@ -74,8 +74,6 @@ export abstract class PrismaRepository implements IRepository { } } - // TODO : using any is not good, but needed for nested entities - // TODO : Refactor for good clean architecture ? async create(entity: Partial | any, include?: any): Promise { try { const res = await this._prisma[this._model].create({ diff --git a/src/modules/database/src/exceptions/DatabaseException.ts b/src/modules/database/src/exceptions/database.exception.ts similarity index 100% rename from src/modules/database/src/exceptions/DatabaseException.ts rename to src/modules/database/src/exceptions/database.exception.ts From e5df7ff170d8237ca17203b75ac53da4bd88b438 Mon Sep 17 00:00:00 2001 From: Gsk54 Date: Tue, 24 Jan 2023 16:02:20 +0100 Subject: [PATCH 2/2] refactor --- .../src/adapters/secondaries/prisma-repository.abstract.ts | 2 +- src/modules/database/tests/unit/prisma-repository.spec.ts | 2 +- src/modules/users/adapters/primaries/users.controller.ts | 2 +- src/modules/users/tests/integration/users.repository.spec.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts b/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts index f8c5bf9..0c7fbb2 100644 --- a/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts +++ b/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; import { PrismaClientKnownRequestError } from '@prisma/client/runtime'; -import { DatabaseException } from '../../exceptions/DatabaseException'; +import { DatabaseException } from '../../exceptions/database.exception'; import { ICollection } from '../../interfaces/collection.interface'; import { IRepository } from '../../interfaces/repository.interface'; import { PrismaService } from './prisma-service'; diff --git a/src/modules/database/tests/unit/prisma-repository.spec.ts b/src/modules/database/tests/unit/prisma-repository.spec.ts index 39b9d0a..064ba6e 100644 --- a/src/modules/database/tests/unit/prisma-repository.spec.ts +++ b/src/modules/database/tests/unit/prisma-repository.spec.ts @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { PrismaService } from '../../src/adapters/secondaries/prisma-service'; import { PrismaRepository } from '../../src/adapters/secondaries/prisma-repository.abstract'; -import { DatabaseException } from '../../src/exceptions/DatabaseException'; +import { DatabaseException } from '../../src/exceptions/database.exception'; class FakeEntity { uuid?: string; diff --git a/src/modules/users/adapters/primaries/users.controller.ts b/src/modules/users/adapters/primaries/users.controller.ts index 63361eb..524360f 100644 --- a/src/modules/users/adapters/primaries/users.controller.ts +++ b/src/modules/users/adapters/primaries/users.controller.ts @@ -3,7 +3,7 @@ import { InjectMapper } from '@automapper/nestjs'; import { Controller, UsePipes } from '@nestjs/common'; import { CommandBus, QueryBus } from '@nestjs/cqrs'; import { GrpcMethod, RpcException } from '@nestjs/microservices'; -import { DatabaseException } from '../../../database/src/exceptions/DatabaseException'; +import { DatabaseException } from '../../../database/src/exceptions/database.exception'; import { CreateUserCommand } from '../../commands/create-user.command'; import { DeleteUserCommand } from '../../commands/delete-user.command'; import { UpdateUserCommand } from '../../commands/update-user.command'; diff --git a/src/modules/users/tests/integration/users.repository.spec.ts b/src/modules/users/tests/integration/users.repository.spec.ts index c4b221a..e71c6cc 100644 --- a/src/modules/users/tests/integration/users.repository.spec.ts +++ b/src/modules/users/tests/integration/users.repository.spec.ts @@ -1,7 +1,7 @@ import { TestingModule, Test } from '@nestjs/testing'; import { DatabaseModule } from '../../../database/database.module'; import { PrismaService } from '../../../database/src/adapters/secondaries/prisma-service'; -import { DatabaseException } from '../../../database/src/exceptions/DatabaseException'; +import { DatabaseException } from '../../../database/src/exceptions/database.exception'; import { UsersRepository } from '../../adapters/secondaries/users.repository'; import { User } from '../../domain/entities/user';