From 032a9594c6e27f0643fdfa4f30cbcb33259eaafd Mon Sep 17 00:00:00 2001 From: sgarnica1 Date: Thu, 9 May 2024 15:01:42 -0600 Subject: [PATCH 1/5] fix(projects): show projects ordered by status --- .../infra/repositories/project.repository.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/core/infra/repositories/project.repository.ts b/src/core/infra/repositories/project.repository.ts index 7becab5b..51ed39c4 100644 --- a/src/core/infra/repositories/project.repository.ts +++ b/src/core/infra/repositories/project.repository.ts @@ -26,9 +26,12 @@ async function findAll(): Promise { when status = 'Cancelled' then 7 when status = 'Accepted' then 8 when status = 'Done' then 9 - else 10 + when status = '-' then 10 + else 11 end asc `; + + console.log(data); if (!data) throw new NotFoundError(`${RESOURCE_NAME} error`); return data.map(mapProjectEntityFromDbModel); @@ -49,12 +52,21 @@ async function findAllByRole(role: SupportedRoles): Promise { let doneProjects: PrismaProjectsRes; let res: Awaited; if (role === SupportedRoles.ADMIN) { - projects = Prisma.project.findMany({ where: { NOT: { status: ProjectStatus.DONE } } }); + projects = Prisma.project.findMany({ + where: { NOT: { status: ProjectStatus.DONE } }, + orderBy: { status: 'desc' }, + }); doneProjects = Prisma.project.findMany({ where: { status: ProjectStatus.DONE } }); res = (await Promise.all([projects, doneProjects])).flat(); } else { - projects = Prisma.project.findMany({ where: { area: role, NOT: { status: ProjectStatus.DONE } } }); - doneProjects = Prisma.project.findMany({ where: { status: ProjectStatus.DONE, area: role } }); + projects = Prisma.project.findMany({ + where: { area: role, NOT: { status: ProjectStatus.DONE } }, + orderBy: { status: 'desc' }, + }); + doneProjects = Prisma.project.findMany({ + where: { status: ProjectStatus.DONE, area: role }, + orderBy: { status: 'desc' }, + }); res = (await Promise.all([projects, doneProjects])).flat(); } if (!res) throw new NotFoundError(`${RESOURCE_NAME} error`); From 369f7c906c5589262954df77b8970d1ef2c6227d Mon Sep 17 00:00:00 2001 From: sgarnica1 Date: Thu, 9 May 2024 15:03:07 -0600 Subject: [PATCH 2/5] fix(dependencies): install new dependencies --- pnpm-lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 358409cc..4a8231b2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,7 +9,7 @@ dependencies: specifier: 5.13.0 version: 5.13.0(prisma@5.13.0) chalk: - specifier: ^4.1.2 + specifier: ^4.0.0 version: 4.1.2 cors: specifier: ^2.8.5 From c22209b14960936e2de7d7b945be5b4a054a6f6d Mon Sep 17 00:00:00 2001 From: sgarnica1 Date: Sat, 11 May 2024 13:46:51 -0600 Subject: [PATCH 3/5] fix(projects): remove findAll projects and replace for findAllByRole --- src/api/controllers/project.controller.ts | 15 ------ .../__tests__/company.service.test.ts | 35 +------------ .../services/__tests__/home.service.test.ts | 34 ++++++++++++- .../__tests__/project.service.test.ts | 45 ++++++++++++++--- src/core/app/services/home.service.ts | 8 ++- src/core/app/services/project.service.ts | 20 +++----- .../infra/repositories/employee.repository.ts | 1 + .../infra/repositories/project.repository.ts | 49 +++++-------------- 8 files changed, 98 insertions(+), 109 deletions(-) diff --git a/src/api/controllers/project.controller.ts b/src/api/controllers/project.controller.ts index 2f69e95b..0f0374bb 100644 --- a/src/api/controllers/project.controller.ts +++ b/src/api/controllers/project.controller.ts @@ -94,20 +94,6 @@ async function getProjectsClient(req: Request, res: Response) { } } -/** - * A function that calls the service to get all projects in the database. - * @param req HTTP Request - * @param res Server response - */ -async function getAllProjects(req: Request, res: Response) { - try { - const data = await ProjectService.getAllProjects(); - res.status(200).json({ data: data }); - } catch (error: any) { - res.status(500).json({ message: error.message }); - } -} - /** * Retrieves all projects from a certain department * @param req An HTTP Request @@ -173,7 +159,6 @@ async function updateProjectStatus(req: Request, res: Response) { export const ProjectController = { getReportData, createProject, - getAllProjects, getProjectsClient, getProjectById, updateProject, diff --git a/src/core/app/services/__tests__/company.service.test.ts b/src/core/app/services/__tests__/company.service.test.ts index d798de48..07e50bc5 100644 --- a/src/core/app/services/__tests__/company.service.test.ts +++ b/src/core/app/services/__tests__/company.service.test.ts @@ -3,23 +3,19 @@ import chai, { expect } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import { randomUUID } from 'crypto'; import sinon from 'sinon'; -import { SupportedDepartments } from '../../../../utils/enums'; import { CompanyRepository } from '../../../infra/repositories/company.repository'; -import { ProjectRepository } from '../../../infra/repositories/project.repository'; import { CompanyService } from '../company.service'; chai.use(chaiAsPromised); describe('CompanyService', () => { let findAllCompaniesStub: sinon.SinonStub; - let findAllProjectsStub: sinon.SinonStub; let updateCompanyStub: sinon.SinonStub; let findCompanyByIdStub: sinon.SinonStub; let archiveClientdStub: sinon.SinonStub; let getArchivedStatusStub: sinon.SinonStub; beforeEach(() => { - findAllProjectsStub = sinon.stub(ProjectRepository, 'findAll'); findAllCompaniesStub = sinon.stub(CompanyRepository, 'findAll'); updateCompanyStub = sinon.stub(CompanyRepository, 'update'); findCompanyByIdStub = sinon.stub(CompanyRepository, 'findById'); @@ -33,7 +29,6 @@ describe('CompanyService', () => { it('should return an array of all companies', async () => { const mockData = prepareMockData(); - findAllProjectsStub.resolves(mockData.existingProjects); findAllCompaniesStub.resolves(mockData.existingCompanies); const res = await CompanyService.findAll(); @@ -44,7 +39,6 @@ describe('CompanyService', () => { it('should match the name of the companies', async () => { const mockData = prepareMockData(); - findAllProjectsStub.resolves(mockData.existingProjects); findAllCompaniesStub.resolves(mockData.existingCompanies); const res = await CompanyService.findAll(); @@ -150,34 +144,7 @@ function prepareMockData() { }, ]; - const existingProjects = [ - { - id: randomUUID(), - name: 'Zeitgeist P1', - description: 'Desc', - status: 'Not started', - startDate: new Date(), - totalHours: 10, - isChargeable: true, - area: SupportedDepartments.LEGAL, - createdAt: new Date(), - idCompany: idCompany1, - }, - { - id: randomUUID(), - name: 'Zeitgeist P2', - description: 'Desc', - status: 'Not started', - startDate: new Date(), - totalHours: 5, - isChargeable: true, - area: SupportedDepartments.ACCOUNTING, - createdAt: new Date(), - idCompany: idCompany1, - }, - ]; - - return { existingCompanies, existingProjects }; + return { existingCompanies }; } function prepareSingleFakeCompany() { diff --git a/src/core/app/services/__tests__/home.service.test.ts b/src/core/app/services/__tests__/home.service.test.ts index 987ab82f..2ec8e49c 100644 --- a/src/core/app/services/__tests__/home.service.test.ts +++ b/src/core/app/services/__tests__/home.service.test.ts @@ -3,9 +3,12 @@ import chai, { expect } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import { randomUUID } from 'crypto'; import sinon from 'sinon'; +import { SupportedRoles } from '../../../../utils/enums'; import { CompanyRepository } from '../../../infra/repositories/company.repository'; import { EmployeeTaskRepository } from '../../../infra/repositories/employee-task.repository'; +import { EmployeeRepository } from '../../../infra/repositories/employee.repository'; import { ProjectRepository } from '../../../infra/repositories/project.repository'; +import { RoleRepository } from '../../../infra/repositories/role.repository'; import { TaskRepository } from '../../../infra/repositories/tasks.repository'; import { HomeService } from '../home.service'; @@ -16,12 +19,18 @@ describe('HomeService', () => { let findTaskByEmployeeIdStub: sinon.SinonStub; let findAllTasksStub: sinon.SinonStub; let findAllCompaniesStub: sinon.SinonStub; + let findEmployeeByEmail: sinon.SinonStub; + let findEmployeeById: sinon.SinonStub; + let findRoleById: sinon.SinonStub; beforeEach(() => { - findAllProjectsStub = sinon.stub(ProjectRepository, 'findAll'); + findAllProjectsStub = sinon.stub(ProjectRepository, 'findAllByRole'); findTaskByEmployeeIdStub = sinon.stub(EmployeeTaskRepository, 'findByEmployeeId'); findAllTasksStub = sinon.stub(TaskRepository, 'findAll'); findAllCompaniesStub = sinon.stub(CompanyRepository, 'findAll'); + findEmployeeByEmail = sinon.stub(EmployeeRepository, 'findByEmail'); + findEmployeeById = sinon.stub(EmployeeRepository, 'findById'); + findRoleById = sinon.stub(RoleRepository, 'findById'); }); afterEach(() => { @@ -29,9 +38,26 @@ describe('HomeService', () => { }); describe('getHomeInfo', () => { - it('should return the projects an employee has assigned and teh companies of those projects', async () => { + it('should return the projects an employee has assigned and the companies of those projects', async () => { const employeeId = randomUUID(); + const accountingRole = randomUUID(); + + const role = { + title: SupportedRoles.ACCOUNTING, + createdAr: new Date(), + }; + + const employee = { + id: employeeId, + firstName: 'John', + lastName: 'Doe', + email: 'joe.doe@email.com', + imageUrl: 'http://example.com/john.jpg', + createdAt: new Date(), + idRole: accountingRole, + }; + const companyId = randomUUID(); const companyId2 = randomUUID(); const existingCompanies = [ @@ -122,6 +148,10 @@ describe('HomeService', () => { }, ]; + findEmployeeByEmail.resolves(employee); + findEmployeeById.resolves(employee); + findRoleById.resolves(role); + findAllProjectsStub.resolves(existingProjects); findAllCompaniesStub.resolves(existingCompanies); findAllTasksStub.resolves(existingTasks); diff --git a/src/core/app/services/__tests__/project.service.test.ts b/src/core/app/services/__tests__/project.service.test.ts index 93236ff3..a719f778 100644 --- a/src/core/app/services/__tests__/project.service.test.ts +++ b/src/core/app/services/__tests__/project.service.test.ts @@ -2,28 +2,40 @@ import { faker } from '@faker-js/faker'; import { expect } from 'chai'; import { randomUUID } from 'crypto'; import { default as Sinon, default as sinon } from 'sinon'; -import { ProjectCategory, ProjectPeriodicity, ProjectStatus, SupportedDepartments } from '../../../../utils/enums'; +import { + ProjectCategory, + ProjectPeriodicity, + ProjectStatus, + SupportedDepartments, + SupportedRoles, +} from '../../../../utils/enums'; import { ProjectEntity } from '../../../domain/entities/project.entity'; import { CompanyRepository } from '../../../infra/repositories/company.repository'; +import { EmployeeRepository } from '../../../infra/repositories/employee.repository'; import { ProjectRepository } from '../../../infra/repositories/project.repository'; +import { RoleRepository } from '../../../infra/repositories/role.repository'; import { CompanyService } from '../company.service'; import { ProjectService } from '../project.service'; describe('ProjectService', () => { let findProjectByIdStub: Sinon.SinonStub; let createProject: sinon.SinonStub; - let findAllStub: sinon.SinonStub; + let findAllByRoleStub: sinon.SinonStub; let findCompanyByIdStub: Sinon.SinonStub; let findProjectsByClientId: Sinon.SinonStub; let updateProjectStub: sinon.SinonStub; let updateProjectStatusStub: sinon.SinonStub; + let findEmployeeByEmail: sinon.SinonStub; + let findRoleById: sinon.SinonStub; beforeEach(() => { createProject = sinon.stub(ProjectRepository, 'createProject'); - findAllStub = sinon.stub(ProjectRepository, 'findAll'); + findAllByRoleStub = sinon.stub(ProjectRepository, 'findAllByRole'); findProjectByIdStub = sinon.stub(ProjectRepository, 'findById'); findProjectsByClientId = sinon.stub(ProjectRepository, 'findProjetsByClientId'); findCompanyByIdStub = sinon.stub(CompanyRepository, 'findById'); + findEmployeeByEmail = sinon.stub(EmployeeRepository, 'findByEmail'); + findRoleById = sinon.stub(RoleRepository, 'findById'); }); afterEach(() => { @@ -97,6 +109,23 @@ describe('ProjectService', () => { describe('getAllProjects', () => { it('should return all projects', async () => { + const accountingRole = randomUUID(); + + const role = { + title: SupportedRoles.ACCOUNTING, + createdAr: new Date(), + }; + + const employee = { + id: randomUUID(), + firstName: 'John', + lastName: 'Doe', + email: 'joe.doe@email.com', + imageUrl: 'http://example.com/john.jpg', + createdAt: new Date(), + idRole: accountingRole, + }; + const projects = [ { id: randomUUID(), @@ -110,7 +139,7 @@ describe('ProjectService', () => { endDate: new Date('2023-12-01T00:00:00.000Z'), periodicity: '1 week', isChargeable: true, - area: 'Client', + area: SupportedDepartments.ACCOUNTING, createdAt: new Date('2024-04-19T01:23:49.555Z'), idCompany: randomUUID(), }, @@ -126,15 +155,17 @@ describe('ProjectService', () => { endDate: new Date('2023-12-01T00:00:00.000Z'), periodicity: '1 week', isChargeable: true, - area: 'Client', + area: SupportedDepartments.ACCOUNTING, createdAt: new Date('2024-04-19T01:23:49.555Z'), idCompany: randomUUID(), }, ]; - findAllStub.resolves(projects); + findEmployeeByEmail.resolves(employee); + findRoleById.resolves(role); + findAllByRoleStub.resolves(projects); - const getProjects = await ProjectService.getAllProjects(); + const getProjects = await ProjectService.getDepartmentProjects(employee.email); expect(getProjects).eql(projects); }); diff --git a/src/core/app/services/home.service.ts b/src/core/app/services/home.service.ts index ceec4923..153419c8 100644 --- a/src/core/app/services/home.service.ts +++ b/src/core/app/services/home.service.ts @@ -1,6 +1,8 @@ import { CompanyRepository } from '../../infra/repositories/company.repository'; import { EmployeeTaskRepository } from '../../infra/repositories/employee-task.repository'; +import { EmployeeRepository } from '../../infra/repositories/employee.repository'; import { ProjectRepository } from '../../infra/repositories/project.repository'; +import { RoleRepository } from '../../infra/repositories/role.repository'; import { TaskRepository } from '../../infra/repositories/tasks.repository'; import { Home } from '../interfaces/home.interface'; @@ -14,7 +16,10 @@ import { Home } from '../interfaces/home.interface'; */ async function getMyInfo(idEmployee: string): Promise { try { - const projects = await ProjectRepository.findAll(); + const employee = await EmployeeRepository.findById(idEmployee); + const role = await RoleRepository.findById(employee.idRole); + + const projects = await ProjectRepository.findAllByRole(role.title); const employeeTask = await EmployeeTaskRepository.findByEmployeeId(idEmployee); const tasks = await TaskRepository.findAll(); const companies = await CompanyRepository.findAll(); @@ -48,6 +53,7 @@ async function getMyInfo(idEmployee: string): Promise { return homeInfo; } catch (error: unknown) { + console.log(error); throw new Error('An unexpected error occurred'); } } diff --git a/src/core/app/services/project.service.ts b/src/core/app/services/project.service.ts index fed1ab7b..3f43205b 100644 --- a/src/core/app/services/project.service.ts +++ b/src/core/app/services/project.service.ts @@ -44,24 +44,19 @@ async function createProject(data: CreateProjectData): Promise { return newProject; } -/** - * Gets all projects from the database - * - * @returns {Promise} - An array of project entities - */ -async function getAllProjects(): Promise { - return await ProjectRepository.findAll(); -} - /** * Retrieves all project from a certain role given an email * @param email the email from the requester * @returns the projects only from a specific role */ async function getDepartmentProjects(email: string): Promise { - const role = await EmployeeService.findRoleByEmail(email); - - return await ProjectRepository.findAllByRole(role); + try { + const role = await EmployeeService.findRoleByEmail(email); + return await ProjectRepository.findAllByRole(role); + } catch (error) { + console.log(error); + throw new Error('An unexpected error occured'); + } } /** @@ -148,7 +143,6 @@ async function updateProjectStatus(projectId: string, newStatus: ProjectStatus): export const ProjectService = { createProject, - getAllProjects, findProjectsClient, getProjectById, updateProject, diff --git a/src/core/infra/repositories/employee.repository.ts b/src/core/infra/repositories/employee.repository.ts index 847df5c6..ff955c14 100644 --- a/src/core/infra/repositories/employee.repository.ts +++ b/src/core/infra/repositories/employee.repository.ts @@ -33,6 +33,7 @@ async function findById(id: string): Promise { return mapEmployeeEntityFromDbModel(data); } catch (error: unknown) { + console.log(error); throw new Error('Employee repository error'); } } diff --git a/src/core/infra/repositories/project.repository.ts b/src/core/infra/repositories/project.repository.ts index 51ed39c4..f95bbf07 100644 --- a/src/core/infra/repositories/project.repository.ts +++ b/src/core/infra/repositories/project.repository.ts @@ -7,39 +7,6 @@ import { mapProjectEntityFromDbModel } from '../mappers/project-entity-from-db-m const RESOURCE_NAME = 'Project info'; -/** - * Finds all company entities in the database - * @version 2.0.0 - * @returns {Promise} a promise taht resolves to an array of company entities ordered by status - */ - -async function findAll(): Promise { - try { - const data: Array = await Prisma.$queryRaw` - SELECT * FROM project - ORDER BY case when status = 'Not started' then 1 - when status = 'In progress' then 2 - when status = 'In quotation' then 3 - when status = 'Under revision' then 4 - when status = 'Delayed' then 5 - when status = 'Postponed' then 6 - when status = 'Cancelled' then 7 - when status = 'Accepted' then 8 - when status = 'Done' then 9 - when status = '-' then 10 - else 11 - end asc - `; - - console.log(data); - if (!data) throw new NotFoundError(`${RESOURCE_NAME} error`); - - return data.map(mapProjectEntityFromDbModel); - } catch (error: unknown) { - throw new Error(`${RESOURCE_NAME} repository error`); - } -} - /** * Retrieves all projects from a certain role, done projects appear last * @param role The role from the requester @@ -51,20 +18,29 @@ async function findAllByRole(role: SupportedRoles): Promise { let projects: PrismaProjectsRes; let doneProjects: PrismaProjectsRes; let res: Awaited; + if (role === SupportedRoles.ADMIN) { projects = Prisma.project.findMany({ - where: { NOT: { status: ProjectStatus.DONE } }, + where: { + NOT: { status: ProjectStatus.DONE }, + }, orderBy: { status: 'desc' }, }); doneProjects = Prisma.project.findMany({ where: { status: ProjectStatus.DONE } }); res = (await Promise.all([projects, doneProjects])).flat(); } else { projects = Prisma.project.findMany({ - where: { area: role, NOT: { status: ProjectStatus.DONE } }, + where: { + area: role, + NOT: { status: ProjectStatus.DONE }, + }, orderBy: { status: 'desc' }, }); doneProjects = Prisma.project.findMany({ - where: { status: ProjectStatus.DONE, area: role }, + where: { + status: ProjectStatus.DONE, + area: role, + }, orderBy: { status: 'desc' }, }); res = (await Promise.all([projects, doneProjects])).flat(); @@ -229,7 +205,6 @@ async function updateProjectStatus(projectId: string, newStatus: ProjectStatus): } export const ProjectRepository = { - findAll, findProjectStatusById, findById, findProjetsByClientId, From 2ef752c3a696108961f22c04d75555fda723add8 Mon Sep 17 00:00:00 2001 From: sgarnica1 Date: Sat, 11 May 2024 14:26:00 -0600 Subject: [PATCH 4/5] fix(projects): allow projects to be created only for not archived companies --- src/api/controllers/project.controller.ts | 4 +- .../__tests__/project.service.test.ts | 16 +++++++ src/core/app/services/project.service.ts | 43 +++++++++++-------- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/api/controllers/project.controller.ts b/src/api/controllers/project.controller.ts index 0f0374bb..1d67091e 100644 --- a/src/api/controllers/project.controller.ts +++ b/src/api/controllers/project.controller.ts @@ -48,8 +48,8 @@ async function createProject(req: Request, res: Response) { startDate: data.startDate, }); res.status(201).json(newProject); - } catch (error: unknown) { - res.status(400).json({ message: error }); + } catch (error: any) { + res.status(400).json({ message: error.message }); } } diff --git a/src/core/app/services/__tests__/project.service.test.ts b/src/core/app/services/__tests__/project.service.test.ts index a719f778..68261bf0 100644 --- a/src/core/app/services/__tests__/project.service.test.ts +++ b/src/core/app/services/__tests__/project.service.test.ts @@ -85,6 +85,20 @@ describe('ProjectService', () => { it('should create a project', async () => { const uuid = randomUUID(); const clientUuid = randomUUID(); + + const company = { + id: clientUuid, + name: 'Zeitgeist', + email: 'info@zeitgeist.mx', + phoneNumber: '1234567890', + landlinePhone: '0987654321', + archived: false, + createdAt: new Date(), + updatedAt: null, + idCompanyDirectContact: null, + idForm: null, + }; + const projectData = { id: uuid, name: 'Nuevo Proyecto de Desarrollo', @@ -101,6 +115,8 @@ describe('ProjectService', () => { createdAt: new Date('2024-04-19T01:23:49.555Z'), idCompany: clientUuid, }; + + findCompanyByIdStub.resolves(company); createProject.resolves(projectData); const newProject = await ProjectService.createProject(projectData); expect(newProject).to.equal(projectData); diff --git a/src/core/app/services/project.service.ts b/src/core/app/services/project.service.ts index 3f43205b..42af4153 100644 --- a/src/core/app/services/project.service.ts +++ b/src/core/app/services/project.service.ts @@ -2,6 +2,7 @@ import { randomUUID } from 'crypto'; import { ProjectStatus } from '../../../utils/enums'; import { ProjectEntity } from '../../domain/entities/project.entity'; import { NotFoundError } from '../../errors/not-found.error'; +import { CompanyRepository } from '../../infra/repositories/company.repository'; import { ProjectRepository } from '../../infra/repositories/project.repository'; import { UpdateProjectBody } from '../interfaces/project.interface'; import { EmployeeService } from './employee.service'; @@ -24,24 +25,31 @@ interface CreateProjectData { * @param data The data required to create a project in the database * @returns The entity created */ -async function createProject(data: CreateProjectData): Promise { - const newProject = await ProjectRepository.createProject({ - id: randomUUID(), - name: data.name, - matter: data.matter ? data.matter : undefined, - description: data.description ? data.description : undefined, - area: data.area, - status: data.status, - category: data.category, - endDate: data.endDate, - idCompany: data.idCompany, - isChargeable: data.isChargeable ? data.isChargeable : undefined, - periodicity: data.periodicity, - startDate: data.startDate, - createdAt: new Date(), - }); +async function createProject(data: CreateProjectData): Promise { + try { + const company = await CompanyRepository.findById(data.idCompany); + if (company.archived) throw new Error('Cannot create projects for archived companies'); - return newProject; + const newProject = await ProjectRepository.createProject({ + id: randomUUID(), + name: data.name, + matter: data.matter ? data.matter : undefined, + description: data.description ? data.description : undefined, + area: data.area, + status: data.status, + category: data.category, + endDate: data.endDate, + idCompany: data.idCompany, + isChargeable: data.isChargeable ? data.isChargeable : undefined, + periodicity: data.periodicity, + startDate: data.startDate, + createdAt: new Date(), + }); + + return newProject; + } catch (error: any) { + throw new Error(error.message); + } } /** @@ -54,7 +62,6 @@ async function getDepartmentProjects(email: string): Promise { const role = await EmployeeService.findRoleByEmail(email); return await ProjectRepository.findAllByRole(role); } catch (error) { - console.log(error); throw new Error('An unexpected error occured'); } } From a5f97f0073b5953378d561a2c6422aa1527966ba Mon Sep 17 00:00:00 2001 From: dembA7 Date: Sat, 11 May 2024 15:35:25 -0600 Subject: [PATCH 5/5] fix(log): delete console.log --- src/core/infra/repositories/employee.repository.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/infra/repositories/employee.repository.ts b/src/core/infra/repositories/employee.repository.ts index ff955c14..847df5c6 100644 --- a/src/core/infra/repositories/employee.repository.ts +++ b/src/core/infra/repositories/employee.repository.ts @@ -33,7 +33,6 @@ async function findById(id: string): Promise { return mapEmployeeEntityFromDbModel(data); } catch (error: unknown) { - console.log(error); throw new Error('Employee repository error'); } }