diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..3c79f30 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18.16.0 \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a58bffd..fbe37eb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -43,6 +43,7 @@ model User { InviteUser InviteUser[] Following ProjectsFollowers[] ProjectIdea ProjectIdea[] + TaskListProject TaskListProject[] } model Profile { @@ -108,23 +109,37 @@ model Questions { } model Projects { - id String @unique @default(uuid()) - name String + id String @unique @default(uuid()) + name String + description String + url String + visibility Boolean @default(false) + priority Priority + createAt DateTime @default(now()) + updateAt DateTime @updatedAt + user User @relation(fields: [userId], references: [id]) + userId String + goals Goals[] + updates Updates[] + comments Comments[] + decisions Decisions[] + Questions Questions[] + InviteUser InviteUser[] + followers ProjectsFollowers[] + TaskListProject TaskListProject[] +} + +model TaskListProject { + id String @unique @default(uuid()) + title String description String - url String - visibility Boolean @default(false) priority Priority - createAt DateTime @default(now()) - updateAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id]) userId String - goals Goals[] - updates Updates[] - comments Comments[] - decisions Decisions[] - Questions Questions[] - InviteUser InviteUser[] - followers ProjectsFollowers[] + projectId String + User User @relation(fields: [userId], references: [id]) + Projects Projects @relation(fields: [projectId], references: [id]) + createAt DateTime @default(now()) + updateAt DateTime @updatedAt } model Decisions { diff --git a/src/app.module.ts b/src/app.module.ts index 5df68ea..3d81450 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -18,6 +18,7 @@ import { LoggerModule } from './logger/logger.module'; import { JwtModule } from '@nestjs/jwt'; import { APP_INTERCEPTOR } from '@nestjs/core'; import { JwtInterceptor } from './auth/auth.service'; +import { TaskListProjectModule } from './task-list-project/task-list-project.module'; @Module({ imports: [ @@ -40,6 +41,7 @@ import { JwtInterceptor } from './auth/auth.service'; EmailModule, HashModule, LoggerModule, + TaskListProjectModule, ], controllers: [], providers: [ diff --git a/src/comments/services/comments/comments.service.ts b/src/comments/services/comments/comments.service.ts index db65657..6601d2b 100644 --- a/src/comments/services/comments/comments.service.ts +++ b/src/comments/services/comments/comments.service.ts @@ -4,7 +4,7 @@ import { PrismaService } from 'src/database/prisma.service'; import { UserService } from 'src/user/services/user/user.service'; import { ProjectsService } from 'src/projects/services/projects/projects.service'; import { Comments } from '@prisma/client'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -47,7 +47,7 @@ export class CommentsService { return comment; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.commentDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, comment_id); } this.logger.error(`some error ocurred : ${error.message}`); diff --git a/src/decisions/services/decisions/decisions.service.ts b/src/decisions/services/decisions/decisions.service.ts index 9843cd7..d74037e 100644 --- a/src/decisions/services/decisions/decisions.service.ts +++ b/src/decisions/services/decisions/decisions.service.ts @@ -4,7 +4,7 @@ import { Decision } from 'src/decisions/types/decision'; import { ProjectsService } from 'src/projects/services/projects/projects.service'; import { UserService } from 'src/user/services/user/user.service'; import { Decisions } from '@prisma/client'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -45,7 +45,7 @@ export class DecisionsService { return decision; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.decisionDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, decision_id); } this.logger.error(`some error ocurred : ${error.message}`); throw error; diff --git a/src/follow-project/service/follow-project/follow-project.service.ts b/src/follow-project/service/follow-project/follow-project.service.ts index 7522671..44af507 100644 --- a/src/follow-project/service/follow-project/follow-project.service.ts +++ b/src/follow-project/service/follow-project/follow-project.service.ts @@ -1,7 +1,7 @@ import { ConflictException, Injectable } from '@nestjs/common'; import { PrismaService } from 'src/database/prisma.service'; import { Data } from 'src/follow-project/types/follow'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; import { ProjectsService } from 'src/projects/services/projects/projects.service'; import { UserService } from 'src/user/services/user/user.service'; @@ -35,7 +35,10 @@ export class FollowProjectService { return userAlreadyFollowProject; } catch (error) { if (error instanceof ConflictException) { - throw new ConflictException(errors.alreadyFollowProject); + throw new ConflictException( + Errors.RESOURCE_ALREADY_EXISTS, + `${userId} - ${projectId}`, + ); } this.logger.error(`some error ocurred : ${error}`); throw error; diff --git a/src/goals/services/goals/goals.service.ts b/src/goals/services/goals/goals.service.ts index fdf5130..5c22f9c 100644 --- a/src/goals/services/goals/goals.service.ts +++ b/src/goals/services/goals/goals.service.ts @@ -4,7 +4,7 @@ import { TGoals } from 'src/goals/types/gaols'; import { ProjectsService } from 'src/projects/services/projects/projects.service'; import { UserService } from 'src/user/services/user/user.service'; import { Goals } from '@prisma/client'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -81,7 +81,7 @@ export class GoalsService { return goal; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.goalDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, goal_id); } this.logger.error(`some error ocurred : ${error.message}`); throw error; diff --git a/src/helpers/errors.ts b/src/helpers/errors.ts index 385d8ec..464177f 100644 --- a/src/helpers/errors.ts +++ b/src/helpers/errors.ts @@ -1,14 +1,5 @@ -export const errors = { - projectDoesNotExist: 'project does not exist', - userDoesNotExist: 'user does not exist', - userAlreadyExist: 'user already exist', - decisionDoesNotExist: 'decision does not exist', - profileDoesNotExist: 'profile does not exist', - commentDoesNotExist: 'comment does not exist', - goalDoesNotExist: 'goal does not exist', - updateDoesNotExist: 'update does not exist', - questionDoesNotExist: 'question does not exist', - projectIdeaDoesNotExist: 'project idea does not exist', - alreadyFollowProject: 'you already follow this project', - teamDoesNotExist: 'team does not exist', +export const Errors = { + RESOURCE_NOT_FOUND: 'Recurso não encontrado no banco de dados', + RESOURCE_ALREADY_EXISTS: 'Recurso já existe', + MISSING_RESOURCE: 'Recurso ausente', }; diff --git a/src/profile/services/profile/profile.service.ts b/src/profile/services/profile/profile.service.ts index ba73a75..efe9d81 100644 --- a/src/profile/services/profile/profile.service.ts +++ b/src/profile/services/profile/profile.service.ts @@ -3,7 +3,7 @@ import { PrismaService } from 'src/database/prisma.service'; import { TProfile } from 'src/profile/types/profile'; import { UserService } from 'src/user/services/user/user.service'; import { Profile } from '@prisma/client'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -28,7 +28,7 @@ export class ProfileService { return profile; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.profileDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, profile_id); } this.logger.error(`some error ocurred : ${error.message}`); throw error; diff --git a/src/project-idea/services/project-idea.service.ts b/src/project-idea/services/project-idea.service.ts index 1eda627..14d36d7 100644 --- a/src/project-idea/services/project-idea.service.ts +++ b/src/project-idea/services/project-idea.service.ts @@ -2,7 +2,7 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { PrismaService } from 'src/database/prisma.service'; import { ProjectIdea } from '../types/projectIdea'; import { UserService } from 'src/user/services/user/user.service'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -56,7 +56,7 @@ export class ProjectIdeaService { return projectIdea; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.projectIdeaDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, id); } this.logger.error(`some errror ocurred : ${error.message}`); throw error; diff --git a/src/projects/services/projects/projects.service.ts b/src/projects/services/projects/projects.service.ts index 4f19197..0a1d078 100644 --- a/src/projects/services/projects/projects.service.ts +++ b/src/projects/services/projects/projects.service.ts @@ -3,7 +3,7 @@ import { PrismaService } from 'src/database/prisma.service'; import { Project } from 'src/projects/types'; import { UserService } from 'src/user/services/user/user.service'; import { Projects } from '@prisma/client'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -29,7 +29,7 @@ export class ProjectsService { return project; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.projectDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, project_id); } this.logger.error( `some error ocurred checking project existence : ${error.message}`, diff --git a/src/questions/services/questions/questions.service.ts b/src/questions/services/questions/questions.service.ts index 8514840..7c3f97d 100644 --- a/src/questions/services/questions/questions.service.ts +++ b/src/questions/services/questions/questions.service.ts @@ -3,7 +3,7 @@ import { PrismaService } from 'src/database/prisma.service'; import { TQuestion } from 'src/questions/types/question'; import { UserService } from 'src/user/services/user/user.service'; import { Questions } from '@prisma/client'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -38,7 +38,7 @@ export class QuestionsService { }, }); if (!question) { - throw new NotFoundException(errors.questionDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, question_id); } return question; } catch (error) { diff --git a/src/send-email/service/send-email/send-email.service.ts b/src/send-email/service/send-email/send-email.service.ts index 4505476..5d612ed 100644 --- a/src/send-email/service/send-email/send-email.service.ts +++ b/src/send-email/service/send-email/send-email.service.ts @@ -2,7 +2,7 @@ import { MailerService } from '@nestjs-modules/mailer'; import { Injectable, NotFoundException } from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; import { PrismaService } from 'src/database/prisma.service'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -48,7 +48,7 @@ export class SendEmailService { }); if (!user) { - throw new NotFoundException(errors.userDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND); } await this.prismaService.user.update({ diff --git a/src/task-list-project/controller/task-list-project/task-list-project.controller.ts b/src/task-list-project/controller/task-list-project/task-list-project.controller.ts new file mode 100644 index 0000000..afd3e5f --- /dev/null +++ b/src/task-list-project/controller/task-list-project/task-list-project.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('task-list-project') +export class TaskListProjectController {} diff --git a/src/task-list-project/service/task-list-project/task-list-project.service.ts b/src/task-list-project/service/task-list-project/task-list-project.service.ts new file mode 100644 index 0000000..cf8d573 --- /dev/null +++ b/src/task-list-project/service/task-list-project/task-list-project.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class TaskListProjectService {} diff --git a/src/task-list-project/task-list-project.module.ts b/src/task-list-project/task-list-project.module.ts new file mode 100644 index 0000000..cf75cca --- /dev/null +++ b/src/task-list-project/task-list-project.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { TaskListProjectController } from './controller/task-list-project/task-list-project.controller'; +import { TaskListProjectService } from './service/task-list-project/task-list-project.service'; + +@Module({ + controllers: [TaskListProjectController], + providers: [TaskListProjectService], +}) +export class TaskListProjectModule {} diff --git a/src/team/services/team/team.service.ts b/src/team/services/team/team.service.ts index 0cfc38b..a995274 100644 --- a/src/team/services/team/team.service.ts +++ b/src/team/services/team/team.service.ts @@ -1,7 +1,7 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { Team } from '@prisma/client'; import { PrismaService } from 'src/database/prisma.service'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; import { TTeam } from 'src/team/types/team'; import { UserService } from 'src/user/services/user/user.service'; @@ -40,7 +40,7 @@ export class TeamService { return team; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.teamDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, team_id); } this.logger.error(`some error ocurred : ${error.message}`); diff --git a/src/updates/services/updates/updates.service.ts b/src/updates/services/updates/updates.service.ts index 86e2a14..4b5f0a8 100644 --- a/src/updates/services/updates/updates.service.ts +++ b/src/updates/services/updates/updates.service.ts @@ -4,7 +4,7 @@ import { ProjectsService } from 'src/projects/services/projects/projects.service import { TUpdate } from 'src/updates/types/updates'; import { UserService } from 'src/user/services/user/user.service'; import { Updates } from '@prisma/client'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { LoggerService } from 'src/logger/logger.service'; @Injectable() @@ -46,7 +46,7 @@ export class UpdatesService { return updateFound; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.updateDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, update_id); } this.logger.error(`some error ocurred : ${error.message}`); throw error; diff --git a/src/user/services/user/user.service.ts b/src/user/services/user/user.service.ts index cd1a78c..bd11e22 100644 --- a/src/user/services/user/user.service.ts +++ b/src/user/services/user/user.service.ts @@ -7,7 +7,7 @@ import { PrismaService } from 'src/database/prisma.service'; import { TUser } from 'src/user/ultils/types'; import { User } from '@prisma/client'; import { SendEmailService } from 'src/send-email/service/send-email/send-email.service'; -import { errors } from 'src/helpers/errors'; +import { Errors } from 'src/helpers/errors'; import { HashService } from 'src/hash/service/hash/hash.service'; import { LoggerService } from 'src/logger/logger.service'; @@ -35,7 +35,7 @@ export class UserService { return user; } catch (error) { if (error instanceof NotFoundException) { - throw new NotFoundException(errors.userDoesNotExist); + throw new NotFoundException(Errors.RESOURCE_NOT_FOUND, user_id); } throw new Error( @@ -59,7 +59,7 @@ export class UserService { return user; } catch (error) { if (error instanceof ConflictException) { - throw new ConflictException(errors.userAlreadyExist); + throw new ConflictException(Errors.RESOURCE_ALREADY_EXISTS, email); } this.logger.error(`some error ocurred : ${error.message}`);