Skip to content

Commit

Permalink
Merge pull request #114 from ItaloRAmaral/113-refatorar-aplicacao-par…
Browse files Browse the repository at this point in the history
…a-concentrar-core-e-adapters-dentro-de-apps

113 refatorar aplicacao para concentrar core e adapters dentro de apps
  • Loading branch information
luanavfg authored Jan 4, 2024
2 parents 3b6e9f8 + 83572c9 commit 97d30b7
Show file tree
Hide file tree
Showing 205 changed files with 1,390 additions and 1,839 deletions.
2 changes: 1 addition & 1 deletion apps/core-rest-api/http/clinic-client.http
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Authorization: Bearer {{authToken}}
"name": "{{$dotenv CLINIC_NAME}}",
"psychologistId": "{{$dotenv PSYCHOLOGIST_ID}}",
"city": "{{$dotenv CLINIC_CITY}}}}",
"state": "{{$dotenv CLINIC_STATE}}",
"state": "{{$dotenv CLINIC_STATE}}"
}

####
Expand Down
30 changes: 30 additions & 0 deletions apps/core-rest-api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,36 @@
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"e2e": {
"executor": "@nx/vite:test",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"passWithNoTests": true,
"config": "apps/core-rest-api/vitest.config.e2e.ts",
"reportsDirectory": "../../coverage/apps/core-rest-api/e2e"
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"passWithNoTests": true,
"config": "apps/core-rest-api/vite.config.ts",
"reportsDirectory": "../../coverage/apps/core-rest-api/unit"
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"tags": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { envSchema } from '../../env/env';
import { EnvModule } from '../../env/env.module';
import { UpdatePsychologistController } from './use-cases/psychologist/update-psychologist/update-psychologist.controller';

import { BcryptHasherService } from '@clinicControl/core-rest-api/core/src/shared/cryptography/use-cases/bcrypt-hasher.service';
import { BcryptHasherService } from '../../../core/shared/cryptography/use-cases/bcrypt-hasher.service';
import { PostgreSqlPrismaOrmService } from '../../database/infra/prisma/prisma.service';
import { DatabaseRepositoriesModule } from '../../database/repositories/repositories.module';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import { CreateClinicDto } from '@clinicControl/core-rest-api/core/src/domains/clinic/use-cases/create-clinic/create-clinic-dto';
import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException';
import { Body, Controller, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { CreateClinicDto } from '../../../../../../core/domains/clinic/use-cases/create-clinic/create-clinic-dto';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';
import { NestjsCreateClinicService } from './nestjs-create-clinic.service';

interface CreateClinicResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import request from 'supertest';
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';

import { ClinicEntity } from '@clinicControl/core-rest-api/core/src/domains/clinic/entities/clinic/entity';
import { PsychologistEntity } from '@clinicControl/core-rest-api/core/src/domains/psychologist/entities/psychologist/entity';
import { BcryptHasherService } from '@clinicControl/core-rest-api/core/src/shared/cryptography/use-cases/bcrypt-hasher.service';
import { faker } from '@faker-js/faker';
import { JwtService } from '@nestjs/jwt';
import { makeClinic } from '../../../../../../tests/factories/make-clinic';
import { PsychologistFactory } from '../../../../../../tests/factories/make-psychologist';
import { makeClinic } from '../../../../../../../../tests/factories/make-clinic';
import { PsychologistFactory } from '../../../../../../../../tests/factories/make-psychologist';
import { ClinicEntity } from '../../../../../../core/domains/clinic/entities/clinic/entity';
import { PsychologistEntity } from '../../../../../../core/domains/psychologist/entities/psychologist/entity';
import { BcryptHasherService } from '../../../../../../core/shared/cryptography/use-cases/bcrypt-hasher.service';
import { DatabaseRepositoriesModule } from '../../../../../database/repositories/repositories.module';
import { ApiModule } from '../../../api.module';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@nestjs/common';
import { ClinicDatabaseRepository } from '../../../../../../core/domains/clinic/repositories/database-repository';
import { CreateClinicService } from '../../../../../../core/domains/clinic/use-cases/create-clinic/create-clinic.service';

@Injectable()
export class NestjsCreateClinicService extends CreateClinicService {
constructor(clinicDatabaseRepository: ClinicDatabaseRepository) {
super(clinicDatabaseRepository);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException';
import { Controller, Delete, Param } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';
import { IControllerResponse, RouteParamsDto } from './dto';
import { NestjsDeleteClinicService } from './nestjs-delete-clinic.service';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ClinicEntity } from '@clinicControl/core-rest-api/core/src/domains/clinic/entities/clinic/entity';
import { faker } from '@faker-js/faker';
import { INestApplication } from '@nestjs/common';
import request from 'supertest';
import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-initial-setup';
import { ClinicEntity } from '../../../../../../core/domains/clinic/entities/clinic/entity';
import { PostgreSqlPrismaOrmService } from '../../../../../database/infra/prisma/prisma.service';
import { setupE2ETest } from '../../../shared/utils/e2e-tests-initial-setup';

describe('[E2E] - Delete Clinic', () => {
let prisma: PostgreSqlPrismaOrmService;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@nestjs/common';
import { ClinicDatabaseRepository } from '../../../../../../core/domains/clinic/repositories/database-repository';
import { DeleteClinicService } from '../../../../../../core/domains/clinic/use-cases/delete-clinic/delete-clinic.service';

@Injectable()
export class NestjsDeleteClinicService extends DeleteClinicService {
constructor(clinicDatabaseRepository: ClinicDatabaseRepository) {
super(clinicDatabaseRepository);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@nestjs/common';
import { ClinicDatabaseRepository } from '../../../../../../core/domains/clinic/repositories/database-repository';
import { UpdateClinicService } from '../../../../../../core/domains/clinic/use-cases/update-clinic/update-clinic.service';

@Injectable()
export class NestjsUpdateClinicService extends UpdateClinicService {
constructor(clinicDatabaseRepository: ClinicDatabaseRepository) {
super(clinicDatabaseRepository);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BadRequestException, Body, Controller, Param, Patch } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';

import { UpdateClinicDto } from '@clinicControl/core-rest-api/core/src/domains/clinic/use-cases/update-clinic/update-clinic-dto';
import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException';
import { UpdateClinicDto } from '../../../../../../core/domains/clinic/use-cases/update-clinic/update-clinic-dto';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';
import { UpdateClinicControllerDto } from './dto';
import { NestjsUpdateClinicService } from './nestjs-update-clinic.service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import request from 'supertest';

import { INestApplication } from '@nestjs/common';

import { ClinicEntity } from '@clinicControl/core-rest-api/core/src/domains/clinic/entities/clinic/entity';
import { setupE2ETest } from '../../../shared/utils/e2e-tests-initial-setup';
import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-initial-setup';
import { ClinicEntity } from '../../../../../../core/domains/clinic/entities/clinic/entity';

describe('[E2E] - Update Clinic', () => {
let app: INestApplication;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Body, Controller, Post } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { postMethodDocs } from './docs';

import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';

import { CreatePatientDto } from '@clinicControl/core-rest-api/core/src/domains/patient/use-cases/create-patient/create-patient-dto';
import { CreatePatientDto } from '../../../../../../core/domains/patient/use-cases/create-patient/create-patient-dto';
import { NestjsCreatePatientService } from './nestjs-create-patient.service';

@ApiTags('patient')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import request from 'supertest';

import { PatientEntity } from '@clinicControl/core-rest-api/core/src/domains/patient/entities/patient/entity';
import { CreatePatientDto } from '@clinicControl/core-rest-api/core/src/domains/patient/use-cases/create-patient/create-patient-dto';
import { INestApplication } from '@nestjs/common';
import { makePatient } from '../../../../../../tests/factories/make-patient';
import { makePatient } from '../../../../../../../../tests/factories/make-patient';
import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-initial-setup';
import { PatientEntity } from '../../../../../../core/domains/patient/entities/patient/entity';
import { CreatePatientDto } from '../../../../../../core/domains/patient/use-cases/create-patient/create-patient-dto';
import { PostgreSqlPrismaOrmService } from '../../../../../database/infra/prisma/prisma.service';
import { setupE2ETest } from '../../../shared/utils/e2e-tests-initial-setup';

describe('[E2E] - Create New Patient', () => {
let app: INestApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Injectable } from '@nestjs/common';

import { PatientDatabaseRepository } from '../../../../../../core/domains/patient/repositories/database-repository';
import { CreatePatientService } from '../../../../../../core/domains/patient/use-cases/create-patient/create-patient.service';

@Injectable()
export class NestjsCreatePatientService extends CreatePatientService {
constructor(patientDatabaseRepository: PatientDatabaseRepository) {
super(patientDatabaseRepository);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Controller, Delete, Param } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { deleteMethodDocs } from './docs';

import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';

import { TokenPayload } from '../../../../../auth/jwt.strategy';
import { CurrentUser } from '../../../decorators/current-user.decorator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { fakerPT_BR as faker } from '@faker-js/faker';
import { INestApplication } from '@nestjs/common';
import request from 'supertest';

import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-initial-setup';
import { PostgreSqlPrismaOrmService } from '../../../../../database/infra/prisma/prisma.service';
import { setupE2ETest } from '../../../shared/utils/e2e-tests-initial-setup';

import { ClinicEntity } from '@clinicControl/core-rest-api/core/src/domains/clinic/entities/clinic/entity';
import { PatientEntity } from '@clinicControl/core-rest-api/core/src/domains/patient/entities/patient/entity';
import { PatientFactory } from '../../../../../../tests/factories/make-patient';
import { PsychologistFactory } from '../../../../../../tests/factories/make-psychologist';
import { PatientFactory } from '../../../../../../../../tests/factories/make-patient';
import { PsychologistFactory } from '../../../../../../../../tests/factories/make-psychologist';
import { ClinicEntity } from '../../../../../../core/domains/clinic/entities/clinic/entity';
import { PatientEntity } from '../../../../../../core/domains/patient/entities/patient/entity';

describe('[E2E] - Delete Patient', async () => {
let prisma: PostgreSqlPrismaOrmService;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Injectable } from '@nestjs/common';

import { PatientDatabaseRepository } from '../../../../../../core/domains/patient/repositories/database-repository';
import { DeletePatientService } from '../../../../../../core/domains/patient/use-cases/delete-patient/delete-patient.service';

@Injectable()
export class NestjsDeletePatientService extends DeletePatientService {
constructor(patientDatabaseRepository: PatientDatabaseRepository) {
super(patientDatabaseRepository);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Body, Controller, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';

import { AuthenticatePsychologistDto } from '@clinicControl/core-rest-api/core/src/domains/psychologist/use-cases/authenticate-psychologist/authenticate-psychologist-dto';
import { Encrypter } from '@clinicControl/core-rest-api/core/src/shared/cryptography/repository/encrypter-repository';
import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException';
import { AuthenticatePsychologistDto } from '../../../../../../core/domains/psychologist/use-cases/authenticate-psychologist/authenticate-psychologist-dto';
import { Encrypter } from '../../../../../../core/shared/cryptography/repository/encrypter-repository';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';

import { Public } from '../../../../../auth/public';
import { AuthenticatePsychologistControllerResponse } from './authenticate-psychologist.interface';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { INestApplication } from '@nestjs/common';

import { fakerPT_BR as faker } from '@faker-js/faker';

import { PsychologistEntity } from '@clinicControl/core-rest-api/core/src/domains/psychologist/entities/psychologist/entity';
import { setupE2ETest } from '../../../shared/utils/e2e-tests-initial-setup';
import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-initial-setup';
import { PsychologistEntity } from '../../../../../../core/domains/psychologist/entities/psychologist/entity';

describe('[E2E] - Authenticate Psychologist', () => {
let app: INestApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@nestjs/common';
import { PsychologistDatabaseRepository } from '../../../../../../core/domains/psychologist/repositories/database-repository';
import { AuthenticatePsychologistService } from '../../../../../../core/domains/psychologist/use-cases/authenticate-psychologist/authenticate-psychologist.service';

@Injectable()
export class NestjsAuthenticatePsychologistService extends AuthenticatePsychologistService {
constructor(psychologistDatabaseRepository: PsychologistDatabaseRepository) {
super(psychologistDatabaseRepository);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { plainToInstance } from 'class-transformer';

import { CreatePsychologistDto } from '@clinicControl/core-rest-api/core/src/domains/psychologist/use-cases/create-psychologist/create-psychologist-dto';
import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException';
import { applicationValidateOrReject } from '@clinicControl/core-rest-api/core/src/shared/validators/validate-or-reject';
import { CreatePsychologistDto } from '../../../../../../core/domains/psychologist/use-cases/create-psychologist/create-psychologist-dto';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';
import { applicationValidateOrReject } from '../../../../../../shared/validators/validate-or-reject';
import { Public } from '../../../../../auth/public';
import { ApiKeyGuard } from '../../../guards/api-key.guard';
import { NestjsCreatePsychologistService } from './nestjs-create-psychologist.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import request from 'supertest';

import { INestApplication } from '@nestjs/common';

import { PsychologistEntity } from '@clinicControl/core-rest-api/core/src/domains/psychologist/entities/psychologist/entity';
import { makePsychologist } from '../../../../../../tests/factories/make-psychologist';
import { makePsychologist } from '../../../../../../../../tests/factories/make-psychologist';
import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-initial-setup';
import { PsychologistEntity } from '../../../../../../core/domains/psychologist/entities/psychologist/entity';
import { PostgreSqlPrismaOrmService } from '../../../../../database/infra/prisma/prisma.service';
import { setupE2ETest } from '../../../shared/utils/e2e-tests-initial-setup';

describe('[E2E] - Create Psychologist Account', () => {
let app: INestApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@nestjs/common';
import { PsychologistDatabaseRepository } from '../../../../../../core/domains/psychologist/repositories/database-repository';
import { CreatePsychologistService } from '../../../../../../core/domains/psychologist/use-cases/create-psychologist/create-psychologist.service';

@Injectable()
export class NestjsCreatePsychologistService extends CreatePsychologistService {
constructor(psychologistDatabaseRepository: PsychologistDatabaseRepository) {
super(psychologistDatabaseRepository);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Controller, Delete, ForbiddenException, Param } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { patchMethodDocs } from './docs';

import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';

import { TokenPayload } from '../../../../../auth/jwt.strategy';
import { CurrentUser } from '../../../decorators/current-user.decorator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import request from 'supertest';
import { INestApplication } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';

import { PsychologistEntity } from '@clinicControl/core-rest-api/core/src/domains/psychologist/entities/psychologist/entity';
import { PsychologistEntity } from '../../../../../../core/domains/psychologist/entities/psychologist/entity';

import { PsychologistFactory } from '../../../../../../tests/factories/make-psychologist';
import { PsychologistFactory } from '../../../../../../../../tests/factories/make-psychologist';
import { setupE2ETest } from '../../../../../../../../tests/utils/e2e-tests-initial-setup';
import { PostgreSqlPrismaOrmService } from '../../../../../database/infra/prisma/prisma.service';
import { setupE2ETest } from '../../../shared/utils/e2e-tests-initial-setup';

describe('[E2E] - Delete Psychologist Account', () => {
let prisma: PostgreSqlPrismaOrmService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AssociatedClinics } from '@clinicControl/core-rest-api/core/src/domains/psychologist/use-cases/delete-psychologist/dto';
import { IsEmail } from 'class-validator';
import { AssociatedClinics } from '../../../../../../core/domains/psychologist/use-cases/delete-psychologist/dto';

export class RouteParamsDto {
@IsEmail()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Injectable } from '@nestjs/common';

import { PsychologistDatabaseRepository } from '../../../../../../core/domains/psychologist/repositories/database-repository';
import { DeletePsychologistService } from '../../../../../../core/domains/psychologist/use-cases/delete-psychologist/delete-psychologist.service';

@Injectable()
export class NestjsDeletePsychologistService extends DeletePsychologistService {
constructor(psychologistDatabaseRepository: PsychologistDatabaseRepository) {
super(psychologistDatabaseRepository);
}
}
Loading

0 comments on commit 97d30b7

Please sign in to comment.