Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new table and module #4

Merged
merged 4 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.16.0
43 changes: 29 additions & 14 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ model User {
InviteUser InviteUser[]
Following ProjectsFollowers[]
ProjectIdea ProjectIdea[]
TaskListProject TaskListProject[]
}

model Profile {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -40,6 +41,7 @@ import { JwtInterceptor } from './auth/auth.service';
EmailModule,
HashModule,
LoggerModule,
TaskListProjectModule,
],
controllers: [],
providers: [
Expand Down
4 changes: 2 additions & 2 deletions src/comments/services/comments/comments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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}`);
Expand Down
4 changes: 2 additions & 2 deletions src/decisions/services/decisions/decisions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/goals/services/goals/goals.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 4 additions & 13 deletions src/helpers/errors.ts
Original file line number Diff line number Diff line change
@@ -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',
};
4 changes: 2 additions & 2 deletions src/profile/services/profile/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/project-idea/services/project-idea.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/projects/services/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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}`,
Expand Down
4 changes: 2 additions & 2 deletions src/questions/services/questions/questions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/send-email/service/send-email/send-email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';

@Controller('task-list-project')
export class TaskListProjectController {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class TaskListProjectService {}
9 changes: 9 additions & 0 deletions src/task-list-project/task-list-project.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
4 changes: 2 additions & 2 deletions src/team/services/team/team.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`);
Expand Down
4 changes: 2 additions & 2 deletions src/updates/services/updates/updates.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/user/services/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(
Expand All @@ -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}`);
Expand Down
Loading