Skip to content

Commit

Permalink
adjust(CC-119): folder project structure refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
italorockenbachamaral committed Apr 22, 2024
1 parent 5dde3b5 commit c246ec0
Show file tree
Hide file tree
Showing 93 changed files with 57 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';

import { AuthModule } from '../../auth/auth.module';
import { CryptographyModule } from '../../cryptography/cryptography.module';
import { envSchema } from '../../env/env';
import { EnvModule } from '../../env/env.module';
import { UpdatePsychologistController } from './use-cases/psychologist/update-psychologist/update-psychologist.controller';
import { AuthModule } from '../auth/auth.module';
import { CryptographyModule } from '../cryptography/cryptography.module';
import { envSchema } from '../env/env';
import { EnvModule } from '../env/env.module';

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';
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';

import { NestjsCreateAppointmentService } from './use-cases/appointment/create-appointment/nestjs-create-appointment.service';
import { DeleteAppointmentController } from './use-cases/appointment/delete-appointment/delete-appointment.controller';
import { NestjsDeleteAppointmentService } from './use-cases/appointment/delete-appointment/nestjs-delete-appointment.service';
import { NestjsCreateClinicService } from './use-cases/clinic/create-clinic/nestjs-create-clinic.service';
import { NestjsDeleteClinicService } from './use-cases/clinic/delete-clinic/nestjs-delete-clinic.service';
import { NestjsUpdateClinicService } from './use-cases/clinic/update-clinic/nestjs-update-clinic.service';
import { NestjsCreatePatientService } from './use-cases/patient/create-patient/nestjs-create-patient.service';
import { NestjsDeletePatientService } from './use-cases/patient/delete-patient/nestjs-delete-patient.service';
import { NestjsUpdatePatientService } from './use-cases/patient/update-patient/nestjs-update-patient.service';
import { NestjsAuthenticatePsychologistService } from './use-cases/psychologist/authenticate-psychologist/nestjs-authenticate-psychologist.service';
import { NestjsCreatePsychologistService } from './use-cases/psychologist/create-psychologist/nestjs-create-psychologist.service';
import { NestjsDeletePsychologistService } from './use-cases/psychologist/delete-psychologist/nestjs-delete-psychologist.service';
import { NestjsUpdatePsychologistService } from './use-cases/psychologist/update-psychologist/nestjs-update-psychologist.service';
import { NestjsCreateAppointmentService } from './routes/v1/appointment/create-appointment/nestjs-create-appointment.service';
import { DeleteAppointmentController } from './routes/v1/appointment/delete-appointment/delete-appointment.controller';
import { NestjsDeleteAppointmentService } from './routes/v1/appointment/delete-appointment/nestjs-delete-appointment.service';
import { NestjsCreateClinicService } from './routes/v1/clinic/create-clinic/nestjs-create-clinic.service';
import { NestjsDeleteClinicService } from './routes/v1/clinic/delete-clinic/nestjs-delete-clinic.service';
import { NestjsUpdateClinicService } from './routes/v1/clinic/update-clinic/nestjs-update-clinic.service';
import { NestjsCreatePatientService } from './routes/v1/patient/create-patient/nestjs-create-patient.service';
import { NestjsDeletePatientService } from './routes/v1/patient/delete-patient/nestjs-delete-patient.service';
import { NestjsUpdatePatientService } from './routes/v1/patient/update-patient/nestjs-update-patient.service';
import { NestjsAuthenticatePsychologistService } from './routes/v1/psychologist/authenticate-psychologist/nestjs-authenticate-psychologist.service';
import { NestjsCreatePsychologistService } from './routes/v1/psychologist/create-psychologist/nestjs-create-psychologist.service';
import { NestjsDeletePsychologistService } from './routes/v1/psychologist/delete-psychologist/nestjs-delete-psychologist.service';
import { NestjsUpdatePsychologistService } from './routes/v1/psychologist/update-psychologist/nestjs-update-psychologist.service';

import { CreateAppointmentController } from './use-cases/appointment/create-appointment/create-appointment.controller';
import { NestjsUpdateAppointmentService } from './use-cases/appointment/update-appointment/nestjs-update-appointment.service';
import { UpdateAppointmentController } from './use-cases/appointment/update-appointment/update-appointment.controller';
import { CreateClinicController } from './use-cases/clinic/create-clinic/create-clinic.controller';
import { DeleteClinicController } from './use-cases/clinic/delete-clinic/delete-clinic.controller';
import { UpdateClinicController } from './use-cases/clinic/update-clinic/update-clinic.controller';
import { CreatePatientAppointmentRegistryController } from './use-cases/patient-appointment-registry/create-patient-appointment-registry/create-patient-appointment-registry.controller';
import { NestjsCreatePatientAppointmentRegistryService } from './use-cases/patient-appointment-registry/create-patient-appointment-registry/nestjs-create-patient-appointment-registry.service';
import { DeletePatientAppointmentRegistryController } from './use-cases/patient-appointment-registry/delete-patient-appointment-registry/delete-patient-appointment-registry.controller';
import { NestjsDeletePatientAppointmentRegistryService } from './use-cases/patient-appointment-registry/delete-patient-appointment-registry/nestjs-delete-patient-appointment-registry.service';
import { NestjsUpdatePatientAppointmentRegistryService } from './use-cases/patient-appointment-registry/update-patient-appointment-registry/nestjs-update-patient-appointment-registry.service';
import { UpdatePatientAppointmentRegistryController } from './use-cases/patient-appointment-registry/update-patient-appointment-registry/update-patient-appointment-registry.controller';
import { CreatePatientController } from './use-cases/patient/create-patient/create-patient.controller';
import { DeletePatientController } from './use-cases/patient/delete-patient/delete-patient.controller';
import { UpdatePatientController } from './use-cases/patient/update-patient/update-patient.controller';
import { AuthenticatePsychologistController } from './use-cases/psychologist/authenticate-psychologist/authenticate-psychologist.controller';
import { CreatePsychologistController } from './use-cases/psychologist/create-psychologist/create-psychologist.controller';
import { DeletePsychologistController } from './use-cases/psychologist/delete-psychologist/delete-psychologist.controller';
import { CreateAppointmentController } from './routes/v1/appointment/create-appointment/create-appointment.controller';
import { NestjsUpdateAppointmentService } from './routes/v1/appointment/update-appointment/nestjs-update-appointment.service';
import { UpdateAppointmentController } from './routes/v1/appointment/update-appointment/update-appointment.controller';
import { CreateClinicController } from './routes/v1/clinic/create-clinic/create-clinic.controller';
import { DeleteClinicController } from './routes/v1/clinic/delete-clinic/delete-clinic.controller';
import { UpdateClinicController } from './routes/v1/clinic/update-clinic/update-clinic.controller';
import { CreatePatientAppointmentRegistryController } from './routes/v1/patient-appointment-registry/create-patient-appointment-registry/create-patient-appointment-registry.controller';
import { NestjsCreatePatientAppointmentRegistryService } from './routes/v1/patient-appointment-registry/create-patient-appointment-registry/nestjs-create-patient-appointment-registry.service';
import { DeletePatientAppointmentRegistryController } from './routes/v1/patient-appointment-registry/delete-patient-appointment-registry/delete-patient-appointment-registry.controller';
import { NestjsDeletePatientAppointmentRegistryService } from './routes/v1/patient-appointment-registry/delete-patient-appointment-registry/nestjs-delete-patient-appointment-registry.service';
import { NestjsUpdatePatientAppointmentRegistryService } from './routes/v1/patient-appointment-registry/update-patient-appointment-registry/nestjs-update-patient-appointment-registry.service';
import { UpdatePatientAppointmentRegistryController } from './routes/v1/patient-appointment-registry/update-patient-appointment-registry/update-patient-appointment-registry.controller';
import { CreatePatientController } from './routes/v1/patient/create-patient/create-patient.controller';
import { DeletePatientController } from './routes/v1/patient/delete-patient/delete-patient.controller';
import { UpdatePatientController } from './routes/v1/patient/update-patient/update-patient.controller';
import { AuthenticatePsychologistController } from './routes/v1/psychologist/authenticate-psychologist/authenticate-psychologist.controller';
import { CreatePsychologistController } from './routes/v1/psychologist/create-psychologist/create-psychologist.controller';
import { DeletePsychologistController } from './routes/v1/psychologist/delete-psychologist/delete-psychologist.controller';
import { UpdatePsychologistController } from './routes/v1/psychologist/update-psychologist/update-psychologist.controller';

@Module({
imports: [
Expand Down Expand Up @@ -91,7 +91,7 @@ import { DeletePsychologistController } from './use-cases/psychologist/delete-ps
NestjsDeletePatientAppointmentRegistryService,
NestjsUpdatePatientAppointmentRegistryService,
NestjsUpdatePatientService,
NestjsUpdateAppointmentService
NestjsUpdateAppointmentService,
],
})
export class ApiModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import { ExecutionContext, createParamDecorator } from '@nestjs/common';
import { TokenPayload } from '../../../auth/jwt.strategy';
import { TokenPayload } from '../../auth/jwt.strategy';

export const CurrentUser = createParamDecorator((_: never, context: ExecutionContext) => {
const request = context.switchToHttp().getRequest(); // usamos o switchToHttp para ter acesso ao request da requisição, e getRequest() para pegar o request (o request é um objeto que tem várias informações da requisição)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export class UpdateAppointmentController {
throw new BadRequestException('Must provide at least one field to update');
}

const updatedApointment = await this.updateAppointmentService.execute({ ...updateAppointmentDto, id });
const updatedApointment = await this.updateAppointmentService.execute({
...updateAppointmentDto,
id,
});

return { message: 'Appointment updated successfully', updatedApointment };
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { deleteMethodDocs } from './docs';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';

import { TokenPayload } from '../../../../../auth/jwt.strategy';
import { CurrentUser } from '../../../decorators/current-user.decorator';
import { CurrentUser } from '../../../../decorators/current-user.decorator';
import { DeletePatientControllerParamsInputDto } from './input.dto';
import { NestjsDeletePatientService } from './nestjs-delete-patient.service';
import { DeletePatientControllerOutputDto } from './output.dto';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { plainToInstance } from 'class-transformer';
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 { ApiKeyGuard } from '../../../../guards/api-key.guard';
import { CreatePsychologistControllerBodyInputDto } from './input.dto';
import { NestjsCreatePsychologistService } from './nestjs-create-psychologist.service';
import { CreatePsychologistControllerOutputDto } from './output.dto';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { patchMethodDocs } from './docs';
import { GlobalAppHttpException } from '../../../../../../shared/errors/globalAppHttpException';

import { TokenPayload } from '../../../../../auth/jwt.strategy';
import { CurrentUser } from '../../../decorators/current-user.decorator';
import { CurrentUser } from '../../../../decorators/current-user.decorator';
import { DeletePsychologistParamsInputDto } from './input.dto';
import { NestjsDeletePsychologistService } from './nestjs-delete-psychologist.service';
import { DeletePsychologistControllerOutputDto } from './output.dto';
Expand Down
4 changes: 2 additions & 2 deletions apps/core-rest-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

import { version } from '../package.json';
import { ApiModule } from './app/adapters/controllers/api/api.module';
import { ApiModule } from './app/adapters/controllers/api.module';
import { EnvService } from './app/adapters/env/env.service';
import { mainDescriptionMarkdown } from './main.docs';

Expand Down Expand Up @@ -36,7 +36,7 @@ async function bootstrap() {
transformOptions: {
enableImplicitConversion: true, // With this option set to true, we no longer need to specify types with the @Type decorator;
},
})
}),
);

// Enable version
Expand Down
2 changes: 1 addition & 1 deletion apps/core-rest-api/tests/utils/e2e-tests-initial-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { JwtService } from '@nestjs/jwt';
import { Test, TestingModule } from '@nestjs/testing';
import { BcryptHasherService } from '../../src/app/core/shared/cryptography/use-cases/bcrypt-hasher.service';

import { ApiModule } from '../../src/app/adapters/controllers/api/api.module';
import { ApiModule } from '../../src/app/adapters/controllers/api.module';
import { PostgreSqlPrismaOrmService } from '../../src/app/adapters/database/infra/prisma/prisma.service';
import { DatabaseRepositoriesModule } from '../../src/app/adapters/database/repositories/repositories.module';

Expand Down
7 changes: 6 additions & 1 deletion apps/core-rest-api/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true
},
"exclude": ["src/**/*.spec.ts", "src/**/*.e2e-spec.ts", "tests/**/*.ts", "vitest.config.e2e.ts"],
"exclude": [
"src/**/*.spec.ts",
"src/**/*.e2e-spec.ts",
"tests/**/*.ts",
"vitest.config.e2e.ts"
],
"include": ["src/**/*.ts"]
}

0 comments on commit c246ec0

Please sign in to comment.