From 07380d48a7c49327d4048a4cabe8397f2f7d0620 Mon Sep 17 00:00:00 2001 From: sbriat Date: Fri, 31 Mar 2023 10:29:25 +0200 Subject: [PATCH] refactor; add health check --- src/app.module.ts | 6 +++-- src/main.ts | 13 +++++---- .../database.module.ts | 0 .../secondaries/prisma-repository.abstract.ts | 0 .../adapters/secondaries/prisma-service.ts | 0 .../src/domain/point.type.ts | 0 .../src/domain/territory-repository.ts | 2 +- .../src/exceptions/database.exception.ts | 0 .../src/interfaces/collection.interface.ts | 0 .../src/interfaces/repository.interface.ts | 0 .../tests/unit/prisma-repository.spec.ts | 0 .../tests/unit/territory-repository.spec.ts | 4 +-- .../adapters/primaries/health.controller.ts | 27 +++++++++++++++++++ .../health/adapters/primaries/health.proto | 21 +++++++++++++++ src/modules/health/health.module.ts | 7 +++++ .../primaries/territory.controller.ts} | 6 ++--- .../adapters/primaries/territory.presenter.ts | 0 .../adapters/primaries/territory.proto | 0 .../adapters/secondaries/messager.ts | 0 .../secondaries/territories.repository.ts | 2 +- .../territory-logging.presenter.ts | 0 .../secondaries/territory.presenter.ts | 0 .../commands/create-territory.command.ts | 0 .../commands/delete-territory.command.ts | 0 .../commands/update-territory.command.ts | 0 .../domain/dtos/create-territory.request.ts | 0 .../find-all-territories-for-point.request.ts | 0 ...find-all-territories-for-points.request.ts | 0 .../dtos/find-all-territories.request.ts | 0 .../dtos/find-territory-by-uuid.request.ts | 0 .../domain/dtos/update-territory.request.ts | 0 .../domain/entities/point.ts | 0 .../domain/entities/territory.ts | 0 .../domain/interfaces/message-broker.ts | 0 .../usecases/create-territory.usecase.ts | 0 .../usecases/delete-territory.usecase.ts | 0 .../find-all-territories-for-point.usecase.ts | 2 +- ...find-all-territories-for-points.usecase.ts | 2 +- .../usecases/find-all-territories.usecase.ts | 2 +- .../find-territory-by-uuid.usecase.ts | 0 .../usecases/update-territory.usecase.ts | 0 .../mappers/territory.profile.ts | 0 .../find-all-territories-for-point.query.ts | 0 .../find-all-territories-for-points.query.ts | 0 .../queries/find-all-territories.query.ts | 0 .../queries/find-territory-by-uuid.query.ts | 0 .../territory.module.ts} | 8 +++--- .../territories.repository.spec.ts | 6 ++--- .../unit/create-territory.usecase.spec.ts | 0 .../unit/delete-territory.usecase.spec.ts | 0 ...-all-territories-for-point.usecase.spec.ts | 0 ...all-territories-for-points.usecase.spec.ts | 0 .../unit/find-all-territories.usecase.spec.ts | 0 .../find-territory-by-uuid.usecase.spec.ts | 0 .../tests/unit/messager.spec.ts | 0 .../unit/update-territory.usecase.spec.ts | 0 .../unit/rpc-validation-pipe.usecase.spec.ts | 2 +- 57 files changed, 85 insertions(+), 25 deletions(-) rename src/modules/{database => databases}/database.module.ts (100%) rename src/modules/{database => databases}/src/adapters/secondaries/prisma-repository.abstract.ts (100%) rename src/modules/{database => databases}/src/adapters/secondaries/prisma-service.ts (100%) rename src/modules/{database => databases}/src/domain/point.type.ts (100%) rename src/modules/{database => databases}/src/domain/territory-repository.ts (96%) rename src/modules/{database => databases}/src/exceptions/database.exception.ts (100%) rename src/modules/{database => databases}/src/interfaces/collection.interface.ts (100%) rename src/modules/{database => databases}/src/interfaces/repository.interface.ts (100%) rename src/modules/{database => databases}/tests/unit/prisma-repository.spec.ts (100%) rename src/modules/{database => databases}/tests/unit/territory-repository.spec.ts (96%) create mode 100644 src/modules/health/adapters/primaries/health.controller.ts create mode 100644 src/modules/health/adapters/primaries/health.proto create mode 100644 src/modules/health/health.module.ts rename src/modules/{territories/adapters/primaries/territories.controller.ts => territory/adapters/primaries/territory.controller.ts} (96%) rename src/modules/{territories => territory}/adapters/primaries/territory.presenter.ts (100%) rename src/modules/{territories => territory}/adapters/primaries/territory.proto (100%) rename src/modules/{territories => territory}/adapters/secondaries/messager.ts (100%) rename src/modules/{territories => territory}/adapters/secondaries/territories.repository.ts (72%) rename src/modules/{territories => territory}/adapters/secondaries/territory-logging.presenter.ts (100%) rename src/modules/{territories => territory}/adapters/secondaries/territory.presenter.ts (100%) rename src/modules/{territories => territory}/commands/create-territory.command.ts (100%) rename src/modules/{territories => territory}/commands/delete-territory.command.ts (100%) rename src/modules/{territories => territory}/commands/update-territory.command.ts (100%) rename src/modules/{territories => territory}/domain/dtos/create-territory.request.ts (100%) rename src/modules/{territories => territory}/domain/dtos/find-all-territories-for-point.request.ts (100%) rename src/modules/{territories => territory}/domain/dtos/find-all-territories-for-points.request.ts (100%) rename src/modules/{territories => territory}/domain/dtos/find-all-territories.request.ts (100%) rename src/modules/{territories => territory}/domain/dtos/find-territory-by-uuid.request.ts (100%) rename src/modules/{territories => territory}/domain/dtos/update-territory.request.ts (100%) rename src/modules/{territories => territory}/domain/entities/point.ts (100%) rename src/modules/{territories => territory}/domain/entities/territory.ts (100%) rename src/modules/{territories => territory}/domain/interfaces/message-broker.ts (100%) rename src/modules/{territories => territory}/domain/usecases/create-territory.usecase.ts (100%) rename src/modules/{territories => territory}/domain/usecases/delete-territory.usecase.ts (100%) rename src/modules/{territories => territory}/domain/usecases/find-all-territories-for-point.usecase.ts (90%) rename src/modules/{territories => territory}/domain/usecases/find-all-territories-for-points.usecase.ts (88%) rename src/modules/{territories => territory}/domain/usecases/find-all-territories.usecase.ts (88%) rename src/modules/{territories => territory}/domain/usecases/find-territory-by-uuid.usecase.ts (100%) rename src/modules/{territories => territory}/domain/usecases/update-territory.usecase.ts (100%) rename src/modules/{territories => territory}/mappers/territory.profile.ts (100%) rename src/modules/{territories => territory}/queries/find-all-territories-for-point.query.ts (100%) rename src/modules/{territories => territory}/queries/find-all-territories-for-points.query.ts (100%) rename src/modules/{territories => territory}/queries/find-all-territories.query.ts (100%) rename src/modules/{territories => territory}/queries/find-territory-by-uuid.query.ts (100%) rename src/modules/{territories/territories.module.ts => territory/territory.module.ts} (91%) rename src/modules/{territories => territory}/tests/integration/territories.repository.spec.ts (96%) rename src/modules/{territories => territory}/tests/unit/create-territory.usecase.spec.ts (100%) rename src/modules/{territories => territory}/tests/unit/delete-territory.usecase.spec.ts (100%) rename src/modules/{territories => territory}/tests/unit/find-all-territories-for-point.usecase.spec.ts (100%) rename src/modules/{territories => territory}/tests/unit/find-all-territories-for-points.usecase.spec.ts (100%) rename src/modules/{territories => territory}/tests/unit/find-all-territories.usecase.spec.ts (100%) rename src/modules/{territories => territory}/tests/unit/find-territory-by-uuid.usecase.spec.ts (100%) rename src/modules/{territories => territory}/tests/unit/messager.spec.ts (100%) rename src/modules/{territories => territory}/tests/unit/update-territory.usecase.spec.ts (100%) diff --git a/src/app.module.ts b/src/app.module.ts index f60a722..aa94fba 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -3,14 +3,16 @@ import { AutomapperModule } from '@automapper/nestjs'; import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { ConfigurationModule } from './modules/configuration/configuration.module'; -import { TerritoriesModule } from './modules/territories/territories.module'; +import { TerritoryModule } from './modules/territory/territory.module'; +import { HealthModule } from './modules/health/health.module'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true }), AutomapperModule.forRoot({ strategyInitializer: classes() }), - TerritoriesModule, + TerritoryModule, ConfigurationModule, + HealthModule, ], controllers: [], providers: [], diff --git a/src/main.ts b/src/main.ts index b9f08f6..9160a01 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,11 +9,14 @@ async function bootstrap() { { transport: Transport.GRPC, options: { - package: 'territory', - protoPath: join( - __dirname, - 'modules/territories/adapters/primaries/territory.proto', - ), + package: ['territory', 'health'], + protoPath: [ + join( + __dirname, + 'modules/territories/adapters/primaries/territory.proto', + ), + join(__dirname, 'modules/health/adapters/primaries/health.proto'), + ], url: process.env.SERVICE_URL + ':' + process.env.SERVICE_PORT, loader: { keepCase: true }, }, diff --git a/src/modules/database/database.module.ts b/src/modules/databases/database.module.ts similarity index 100% rename from src/modules/database/database.module.ts rename to src/modules/databases/database.module.ts diff --git a/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts b/src/modules/databases/src/adapters/secondaries/prisma-repository.abstract.ts similarity index 100% rename from src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts rename to src/modules/databases/src/adapters/secondaries/prisma-repository.abstract.ts diff --git a/src/modules/database/src/adapters/secondaries/prisma-service.ts b/src/modules/databases/src/adapters/secondaries/prisma-service.ts similarity index 100% rename from src/modules/database/src/adapters/secondaries/prisma-service.ts rename to src/modules/databases/src/adapters/secondaries/prisma-service.ts diff --git a/src/modules/database/src/domain/point.type.ts b/src/modules/databases/src/domain/point.type.ts similarity index 100% rename from src/modules/database/src/domain/point.type.ts rename to src/modules/databases/src/domain/point.type.ts diff --git a/src/modules/database/src/domain/territory-repository.ts b/src/modules/databases/src/domain/territory-repository.ts similarity index 96% rename from src/modules/database/src/domain/territory-repository.ts rename to src/modules/databases/src/domain/territory-repository.ts index 79c203a..43cee35 100644 --- a/src/modules/database/src/domain/territory-repository.ts +++ b/src/modules/databases/src/domain/territory-repository.ts @@ -2,7 +2,7 @@ import { PrismaRepository } from '../adapters/secondaries/prisma-repository.abst import { ICollection } from '../interfaces/collection.interface'; import { Point } from './point.type'; import { v4 as uuidv4 } from 'uuid'; -import { Territory } from 'src/modules/territories/domain/entities/territory'; +import { Territory } from 'src/modules/territory/domain/entities/territory'; import { DatabaseException } from '../exceptions/database.exception'; export class TerritoryRepository extends PrismaRepository { diff --git a/src/modules/database/src/exceptions/database.exception.ts b/src/modules/databases/src/exceptions/database.exception.ts similarity index 100% rename from src/modules/database/src/exceptions/database.exception.ts rename to src/modules/databases/src/exceptions/database.exception.ts diff --git a/src/modules/database/src/interfaces/collection.interface.ts b/src/modules/databases/src/interfaces/collection.interface.ts similarity index 100% rename from src/modules/database/src/interfaces/collection.interface.ts rename to src/modules/databases/src/interfaces/collection.interface.ts diff --git a/src/modules/database/src/interfaces/repository.interface.ts b/src/modules/databases/src/interfaces/repository.interface.ts similarity index 100% rename from src/modules/database/src/interfaces/repository.interface.ts rename to src/modules/databases/src/interfaces/repository.interface.ts diff --git a/src/modules/database/tests/unit/prisma-repository.spec.ts b/src/modules/databases/tests/unit/prisma-repository.spec.ts similarity index 100% rename from src/modules/database/tests/unit/prisma-repository.spec.ts rename to src/modules/databases/tests/unit/prisma-repository.spec.ts diff --git a/src/modules/database/tests/unit/territory-repository.spec.ts b/src/modules/databases/tests/unit/territory-repository.spec.ts similarity index 96% rename from src/modules/database/tests/unit/territory-repository.spec.ts rename to src/modules/databases/tests/unit/territory-repository.spec.ts index dd7194e..9476f7b 100644 --- a/src/modules/database/tests/unit/territory-repository.spec.ts +++ b/src/modules/databases/tests/unit/territory-repository.spec.ts @@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { PrismaService } from '../../src/adapters/secondaries/prisma-service'; import { TerritoryRepository } from '../../src/domain/territory-repository'; -import { Territory } from '../../../territories/domain/entities/territory'; -import { Point } from '../../../territories/domain/entities/point'; +import { Territory } from '../../../territory/domain/entities/territory'; +import { Point } from '../../../territory/domain/entities/point'; import { DatabaseException } from '../../src/exceptions/database.exception'; const mockTerritories: Array = [ diff --git a/src/modules/health/adapters/primaries/health.controller.ts b/src/modules/health/adapters/primaries/health.controller.ts new file mode 100644 index 0000000..843a4a9 --- /dev/null +++ b/src/modules/health/adapters/primaries/health.controller.ts @@ -0,0 +1,27 @@ +import { Controller } from '@nestjs/common'; +import { GrpcMethod } from '@nestjs/microservices'; + +enum ServingStatus { + UNKNOWN = 0, + SERVING = 1, + NOT_SERVING = 2, +} + +interface HealthCheckRequest { + service: string; +} + +interface HealthCheckResponse { + status: ServingStatus; +} + +@Controller() +export class HealthController { + @GrpcMethod('Health', 'Check') + // eslint-disable-next-line @typescript-eslint/no-unused-vars + check(data: HealthCheckRequest, metadata: any): HealthCheckResponse { + return { + status: ServingStatus.SERVING, + }; + } +} diff --git a/src/modules/health/adapters/primaries/health.proto b/src/modules/health/adapters/primaries/health.proto new file mode 100644 index 0000000..74e1a4c --- /dev/null +++ b/src/modules/health/adapters/primaries/health.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package health; + + +service Health { + rpc Check(HealthCheckRequest) returns (HealthCheckResponse); +} + +message HealthCheckRequest { + string service = 1; +} + +message HealthCheckResponse { + enum ServingStatus { + UNKNOWN = 0; + SERVING = 1; + NOT_SERVING = 2; + } + ServingStatus status = 1; +} diff --git a/src/modules/health/health.module.ts b/src/modules/health/health.module.ts new file mode 100644 index 0000000..1f715d5 --- /dev/null +++ b/src/modules/health/health.module.ts @@ -0,0 +1,7 @@ +import { Module } from '@nestjs/common'; +import { HealthController } from './adapters/primaries/health.controller'; + +@Module({ + controllers: [HealthController], +}) +export class HealthModule {} diff --git a/src/modules/territories/adapters/primaries/territories.controller.ts b/src/modules/territory/adapters/primaries/territory.controller.ts similarity index 96% rename from src/modules/territories/adapters/primaries/territories.controller.ts rename to src/modules/territory/adapters/primaries/territory.controller.ts index aeaa6ed..bb0816a 100644 --- a/src/modules/territories/adapters/primaries/territories.controller.ts +++ b/src/modules/territory/adapters/primaries/territory.controller.ts @@ -6,7 +6,7 @@ import { GrpcMethod, RpcException } from '@nestjs/microservices'; import { Territory } from '../../domain/entities/territory'; import { FindAllTerritoriesForPointQuery } from '../../queries/find-all-territories-for-point.query'; import { TerritoryPresenter } from './territory.presenter'; -import { ICollection } from '../../../database/src/interfaces/collection.interface'; +import { ICollection } from '../../../databases/src/interfaces/collection.interface'; import { RpcValidationPipe } from '../../../../utils/pipes/rpc.validation-pipe'; import { FindAllTerritoriesForPointRequest } from '../../domain/dtos/find-all-territories-for-point.request'; import { FindAllTerritoriesRequest } from '../../domain/dtos/find-all-territories.request'; @@ -15,7 +15,7 @@ import { FindTerritoryByUuidRequest } from '../../domain/dtos/find-territory-by- import { FindTerritoryByUuidQuery } from '../../queries/find-territory-by-uuid.query'; import { CreateTerritoryRequest } from '../../domain/dtos/create-territory.request'; import { CreateTerritoryCommand } from '../../commands/create-territory.command'; -import { DatabaseException } from 'src/modules/database/src/exceptions/database.exception'; +import { DatabaseException } from 'src/modules/databases/src/exceptions/database.exception'; import { UpdateTerritoryRequest } from '../../domain/dtos/update-territory.request'; import { UpdateTerritoryCommand } from '../../commands/update-territory.command'; import { DeleteTerritoryCommand } from '../../commands/delete-territory.command'; @@ -29,7 +29,7 @@ import { FindAllTerritoriesForPointsQuery } from '../../queries/find-all-territo }), ) @Controller() -export class TerritoriesController { +export class TerritoryController { constructor( private readonly _commandBus: CommandBus, private readonly _queryBus: QueryBus, diff --git a/src/modules/territories/adapters/primaries/territory.presenter.ts b/src/modules/territory/adapters/primaries/territory.presenter.ts similarity index 100% rename from src/modules/territories/adapters/primaries/territory.presenter.ts rename to src/modules/territory/adapters/primaries/territory.presenter.ts diff --git a/src/modules/territories/adapters/primaries/territory.proto b/src/modules/territory/adapters/primaries/territory.proto similarity index 100% rename from src/modules/territories/adapters/primaries/territory.proto rename to src/modules/territory/adapters/primaries/territory.proto diff --git a/src/modules/territories/adapters/secondaries/messager.ts b/src/modules/territory/adapters/secondaries/messager.ts similarity index 100% rename from src/modules/territories/adapters/secondaries/messager.ts rename to src/modules/territory/adapters/secondaries/messager.ts diff --git a/src/modules/territories/adapters/secondaries/territories.repository.ts b/src/modules/territory/adapters/secondaries/territories.repository.ts similarity index 72% rename from src/modules/territories/adapters/secondaries/territories.repository.ts rename to src/modules/territory/adapters/secondaries/territories.repository.ts index 6c617c4..f4e1fba 100644 --- a/src/modules/territories/adapters/secondaries/territories.repository.ts +++ b/src/modules/territory/adapters/secondaries/territories.repository.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { TerritoryRepository } from '../../../database/src/domain/territory-repository'; +import { TerritoryRepository } from '../../../databases/src/domain/territory-repository'; import { Territory } from '../../domain/entities/territory'; @Injectable() diff --git a/src/modules/territories/adapters/secondaries/territory-logging.presenter.ts b/src/modules/territory/adapters/secondaries/territory-logging.presenter.ts similarity index 100% rename from src/modules/territories/adapters/secondaries/territory-logging.presenter.ts rename to src/modules/territory/adapters/secondaries/territory-logging.presenter.ts diff --git a/src/modules/territories/adapters/secondaries/territory.presenter.ts b/src/modules/territory/adapters/secondaries/territory.presenter.ts similarity index 100% rename from src/modules/territories/adapters/secondaries/territory.presenter.ts rename to src/modules/territory/adapters/secondaries/territory.presenter.ts diff --git a/src/modules/territories/commands/create-territory.command.ts b/src/modules/territory/commands/create-territory.command.ts similarity index 100% rename from src/modules/territories/commands/create-territory.command.ts rename to src/modules/territory/commands/create-territory.command.ts diff --git a/src/modules/territories/commands/delete-territory.command.ts b/src/modules/territory/commands/delete-territory.command.ts similarity index 100% rename from src/modules/territories/commands/delete-territory.command.ts rename to src/modules/territory/commands/delete-territory.command.ts diff --git a/src/modules/territories/commands/update-territory.command.ts b/src/modules/territory/commands/update-territory.command.ts similarity index 100% rename from src/modules/territories/commands/update-territory.command.ts rename to src/modules/territory/commands/update-territory.command.ts diff --git a/src/modules/territories/domain/dtos/create-territory.request.ts b/src/modules/territory/domain/dtos/create-territory.request.ts similarity index 100% rename from src/modules/territories/domain/dtos/create-territory.request.ts rename to src/modules/territory/domain/dtos/create-territory.request.ts diff --git a/src/modules/territories/domain/dtos/find-all-territories-for-point.request.ts b/src/modules/territory/domain/dtos/find-all-territories-for-point.request.ts similarity index 100% rename from src/modules/territories/domain/dtos/find-all-territories-for-point.request.ts rename to src/modules/territory/domain/dtos/find-all-territories-for-point.request.ts diff --git a/src/modules/territories/domain/dtos/find-all-territories-for-points.request.ts b/src/modules/territory/domain/dtos/find-all-territories-for-points.request.ts similarity index 100% rename from src/modules/territories/domain/dtos/find-all-territories-for-points.request.ts rename to src/modules/territory/domain/dtos/find-all-territories-for-points.request.ts diff --git a/src/modules/territories/domain/dtos/find-all-territories.request.ts b/src/modules/territory/domain/dtos/find-all-territories.request.ts similarity index 100% rename from src/modules/territories/domain/dtos/find-all-territories.request.ts rename to src/modules/territory/domain/dtos/find-all-territories.request.ts diff --git a/src/modules/territories/domain/dtos/find-territory-by-uuid.request.ts b/src/modules/territory/domain/dtos/find-territory-by-uuid.request.ts similarity index 100% rename from src/modules/territories/domain/dtos/find-territory-by-uuid.request.ts rename to src/modules/territory/domain/dtos/find-territory-by-uuid.request.ts diff --git a/src/modules/territories/domain/dtos/update-territory.request.ts b/src/modules/territory/domain/dtos/update-territory.request.ts similarity index 100% rename from src/modules/territories/domain/dtos/update-territory.request.ts rename to src/modules/territory/domain/dtos/update-territory.request.ts diff --git a/src/modules/territories/domain/entities/point.ts b/src/modules/territory/domain/entities/point.ts similarity index 100% rename from src/modules/territories/domain/entities/point.ts rename to src/modules/territory/domain/entities/point.ts diff --git a/src/modules/territories/domain/entities/territory.ts b/src/modules/territory/domain/entities/territory.ts similarity index 100% rename from src/modules/territories/domain/entities/territory.ts rename to src/modules/territory/domain/entities/territory.ts diff --git a/src/modules/territories/domain/interfaces/message-broker.ts b/src/modules/territory/domain/interfaces/message-broker.ts similarity index 100% rename from src/modules/territories/domain/interfaces/message-broker.ts rename to src/modules/territory/domain/interfaces/message-broker.ts diff --git a/src/modules/territories/domain/usecases/create-territory.usecase.ts b/src/modules/territory/domain/usecases/create-territory.usecase.ts similarity index 100% rename from src/modules/territories/domain/usecases/create-territory.usecase.ts rename to src/modules/territory/domain/usecases/create-territory.usecase.ts diff --git a/src/modules/territories/domain/usecases/delete-territory.usecase.ts b/src/modules/territory/domain/usecases/delete-territory.usecase.ts similarity index 100% rename from src/modules/territories/domain/usecases/delete-territory.usecase.ts rename to src/modules/territory/domain/usecases/delete-territory.usecase.ts diff --git a/src/modules/territories/domain/usecases/find-all-territories-for-point.usecase.ts b/src/modules/territory/domain/usecases/find-all-territories-for-point.usecase.ts similarity index 90% rename from src/modules/territories/domain/usecases/find-all-territories-for-point.usecase.ts rename to src/modules/territory/domain/usecases/find-all-territories-for-point.usecase.ts index c39701d..8888b4a 100644 --- a/src/modules/territories/domain/usecases/find-all-territories-for-point.usecase.ts +++ b/src/modules/territory/domain/usecases/find-all-territories-for-point.usecase.ts @@ -1,5 +1,5 @@ import { QueryHandler } from '@nestjs/cqrs'; -import { ICollection } from 'src/modules/database/src/interfaces/collection.interface'; +import { ICollection } from 'src/modules/databases/src/interfaces/collection.interface'; import { TerritoriesRepository } from '../../adapters/secondaries/territories.repository'; import { FindAllTerritoriesForPointQuery } from '../../queries/find-all-territories-for-point.query'; import { Territory } from '../entities/territory'; diff --git a/src/modules/territories/domain/usecases/find-all-territories-for-points.usecase.ts b/src/modules/territory/domain/usecases/find-all-territories-for-points.usecase.ts similarity index 88% rename from src/modules/territories/domain/usecases/find-all-territories-for-points.usecase.ts rename to src/modules/territory/domain/usecases/find-all-territories-for-points.usecase.ts index 8b103d7..d3faf5e 100644 --- a/src/modules/territories/domain/usecases/find-all-territories-for-points.usecase.ts +++ b/src/modules/territory/domain/usecases/find-all-territories-for-points.usecase.ts @@ -1,5 +1,5 @@ import { QueryHandler } from '@nestjs/cqrs'; -import { ICollection } from 'src/modules/database/src/interfaces/collection.interface'; +import { ICollection } from 'src/modules/databases/src/interfaces/collection.interface'; import { TerritoriesRepository } from '../../adapters/secondaries/territories.repository'; import { FindAllTerritoriesForPointsQuery } from '../../queries/find-all-territories-for-points.query'; import { Territory } from '../entities/territory'; diff --git a/src/modules/territories/domain/usecases/find-all-territories.usecase.ts b/src/modules/territory/domain/usecases/find-all-territories.usecase.ts similarity index 88% rename from src/modules/territories/domain/usecases/find-all-territories.usecase.ts rename to src/modules/territory/domain/usecases/find-all-territories.usecase.ts index dadb3f9..f1f7f62 100644 --- a/src/modules/territories/domain/usecases/find-all-territories.usecase.ts +++ b/src/modules/territory/domain/usecases/find-all-territories.usecase.ts @@ -1,5 +1,5 @@ import { QueryHandler } from '@nestjs/cqrs'; -import { ICollection } from 'src/modules/database/src/interfaces/collection.interface'; +import { ICollection } from 'src/modules/databases/src/interfaces/collection.interface'; import { TerritoriesRepository } from '../../adapters/secondaries/territories.repository'; import { FindAllTerritoriesQuery } from '../../queries/find-all-territories.query'; import { Territory } from '../entities/territory'; diff --git a/src/modules/territories/domain/usecases/find-territory-by-uuid.usecase.ts b/src/modules/territory/domain/usecases/find-territory-by-uuid.usecase.ts similarity index 100% rename from src/modules/territories/domain/usecases/find-territory-by-uuid.usecase.ts rename to src/modules/territory/domain/usecases/find-territory-by-uuid.usecase.ts diff --git a/src/modules/territories/domain/usecases/update-territory.usecase.ts b/src/modules/territory/domain/usecases/update-territory.usecase.ts similarity index 100% rename from src/modules/territories/domain/usecases/update-territory.usecase.ts rename to src/modules/territory/domain/usecases/update-territory.usecase.ts diff --git a/src/modules/territories/mappers/territory.profile.ts b/src/modules/territory/mappers/territory.profile.ts similarity index 100% rename from src/modules/territories/mappers/territory.profile.ts rename to src/modules/territory/mappers/territory.profile.ts diff --git a/src/modules/territories/queries/find-all-territories-for-point.query.ts b/src/modules/territory/queries/find-all-territories-for-point.query.ts similarity index 100% rename from src/modules/territories/queries/find-all-territories-for-point.query.ts rename to src/modules/territory/queries/find-all-territories-for-point.query.ts diff --git a/src/modules/territories/queries/find-all-territories-for-points.query.ts b/src/modules/territory/queries/find-all-territories-for-points.query.ts similarity index 100% rename from src/modules/territories/queries/find-all-territories-for-points.query.ts rename to src/modules/territory/queries/find-all-territories-for-points.query.ts diff --git a/src/modules/territories/queries/find-all-territories.query.ts b/src/modules/territory/queries/find-all-territories.query.ts similarity index 100% rename from src/modules/territories/queries/find-all-territories.query.ts rename to src/modules/territory/queries/find-all-territories.query.ts diff --git a/src/modules/territories/queries/find-territory-by-uuid.query.ts b/src/modules/territory/queries/find-territory-by-uuid.query.ts similarity index 100% rename from src/modules/territories/queries/find-territory-by-uuid.query.ts rename to src/modules/territory/queries/find-territory-by-uuid.query.ts diff --git a/src/modules/territories/territories.module.ts b/src/modules/territory/territory.module.ts similarity index 91% rename from src/modules/territories/territories.module.ts rename to src/modules/territory/territory.module.ts index 72ff8b7..87e308e 100644 --- a/src/modules/territories/territories.module.ts +++ b/src/modules/territory/territory.module.ts @@ -4,8 +4,8 @@ import { CacheModule, Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { CqrsModule } from '@nestjs/cqrs'; import { redisStore } from 'cache-manager-ioredis-yet'; -import { DatabaseModule } from '../database/database.module'; -import { TerritoriesController } from './adapters/primaries/territories.controller'; +import { DatabaseModule } from '../databases/database.module'; +import { TerritoryController } from './adapters/primaries/territory.controller'; import { TerritoriesRepository } from './adapters/secondaries/territories.repository'; import { Messager } from './adapters/secondaries/messager'; import { CreateTerritoryUseCase } from './domain/usecases/create-territory.usecase'; @@ -48,7 +48,7 @@ import { TerritoryProfile } from './mappers/territory.profile'; inject: [ConfigService], }), ], - controllers: [TerritoriesController], + controllers: [TerritoryController], providers: [ TerritoryProfile, TerritoriesRepository, @@ -63,4 +63,4 @@ import { TerritoryProfile } from './mappers/territory.profile'; ], exports: [], }) -export class TerritoriesModule {} +export class TerritoryModule {} diff --git a/src/modules/territories/tests/integration/territories.repository.spec.ts b/src/modules/territory/tests/integration/territories.repository.spec.ts similarity index 96% rename from src/modules/territories/tests/integration/territories.repository.spec.ts rename to src/modules/territory/tests/integration/territories.repository.spec.ts index 63e9655..4a43e97 100644 --- a/src/modules/territories/tests/integration/territories.repository.spec.ts +++ b/src/modules/territory/tests/integration/territories.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/database.exception'; +import { DatabaseModule } from '../../../databases/database.module'; +import { PrismaService } from '../../../databases/src/adapters/secondaries/prisma-service'; +import { DatabaseException } from '../../../databases/src/exceptions/database.exception'; import { TerritoriesRepository } from '../../adapters/secondaries/territories.repository'; import { v4 as uuidv4 } from 'uuid'; import { Territory } from '../../domain/entities/territory'; diff --git a/src/modules/territories/tests/unit/create-territory.usecase.spec.ts b/src/modules/territory/tests/unit/create-territory.usecase.spec.ts similarity index 100% rename from src/modules/territories/tests/unit/create-territory.usecase.spec.ts rename to src/modules/territory/tests/unit/create-territory.usecase.spec.ts diff --git a/src/modules/territories/tests/unit/delete-territory.usecase.spec.ts b/src/modules/territory/tests/unit/delete-territory.usecase.spec.ts similarity index 100% rename from src/modules/territories/tests/unit/delete-territory.usecase.spec.ts rename to src/modules/territory/tests/unit/delete-territory.usecase.spec.ts diff --git a/src/modules/territories/tests/unit/find-all-territories-for-point.usecase.spec.ts b/src/modules/territory/tests/unit/find-all-territories-for-point.usecase.spec.ts similarity index 100% rename from src/modules/territories/tests/unit/find-all-territories-for-point.usecase.spec.ts rename to src/modules/territory/tests/unit/find-all-territories-for-point.usecase.spec.ts diff --git a/src/modules/territories/tests/unit/find-all-territories-for-points.usecase.spec.ts b/src/modules/territory/tests/unit/find-all-territories-for-points.usecase.spec.ts similarity index 100% rename from src/modules/territories/tests/unit/find-all-territories-for-points.usecase.spec.ts rename to src/modules/territory/tests/unit/find-all-territories-for-points.usecase.spec.ts diff --git a/src/modules/territories/tests/unit/find-all-territories.usecase.spec.ts b/src/modules/territory/tests/unit/find-all-territories.usecase.spec.ts similarity index 100% rename from src/modules/territories/tests/unit/find-all-territories.usecase.spec.ts rename to src/modules/territory/tests/unit/find-all-territories.usecase.spec.ts diff --git a/src/modules/territories/tests/unit/find-territory-by-uuid.usecase.spec.ts b/src/modules/territory/tests/unit/find-territory-by-uuid.usecase.spec.ts similarity index 100% rename from src/modules/territories/tests/unit/find-territory-by-uuid.usecase.spec.ts rename to src/modules/territory/tests/unit/find-territory-by-uuid.usecase.spec.ts diff --git a/src/modules/territories/tests/unit/messager.spec.ts b/src/modules/territory/tests/unit/messager.spec.ts similarity index 100% rename from src/modules/territories/tests/unit/messager.spec.ts rename to src/modules/territory/tests/unit/messager.spec.ts diff --git a/src/modules/territories/tests/unit/update-territory.usecase.spec.ts b/src/modules/territory/tests/unit/update-territory.usecase.spec.ts similarity index 100% rename from src/modules/territories/tests/unit/update-territory.usecase.spec.ts rename to src/modules/territory/tests/unit/update-territory.usecase.spec.ts diff --git a/src/utils/tests/unit/rpc-validation-pipe.usecase.spec.ts b/src/utils/tests/unit/rpc-validation-pipe.usecase.spec.ts index 46695ff..5df3e07 100644 --- a/src/utils/tests/unit/rpc-validation-pipe.usecase.spec.ts +++ b/src/utils/tests/unit/rpc-validation-pipe.usecase.spec.ts @@ -1,5 +1,5 @@ import { ArgumentMetadata } from '@nestjs/common'; -import { UpdateTerritoryRequest } from '../../../modules/territories/domain/dtos/update-territory.request'; +import { UpdateTerritoryRequest } from '../../../modules/territory/domain/dtos/update-territory.request'; import { RpcValidationPipe } from '../../pipes/rpc.validation-pipe'; describe('RpcValidationPipe', () => {