diff --git a/apps/server/src/auth/auth.service.ts b/apps/server/src/auth/auth.service.ts index 5f793080..d435dadc 100644 --- a/apps/server/src/auth/auth.service.ts +++ b/apps/server/src/auth/auth.service.ts @@ -3,6 +3,7 @@ import { ForbiddenException, Injectable, InternalServerErrorException, + Logger, } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; import { JwtService } from "@nestjs/jwt"; @@ -115,6 +116,7 @@ export class AuthService { throw new BadRequestException(ErrorMessage.UserAlreadyExists); } + Logger.error(error); throw new InternalServerErrorException(error); } } @@ -213,6 +215,7 @@ export class AuthService { await this.mailService.sendEmail({ to: email, subject, text }); } catch (error) { + Logger.error(error); throw new InternalServerErrorException(error); } } diff --git a/apps/server/src/resume/resume.controller.ts b/apps/server/src/resume/resume.controller.ts index b2e3d662..991d12a1 100644 --- a/apps/server/src/resume/resume.controller.ts +++ b/apps/server/src/resume/resume.controller.ts @@ -55,6 +55,7 @@ export class ResumeController { throw new BadRequestException(ErrorMessage.ResumeSlugAlreadyExists); } + Logger.error(error); throw new InternalServerErrorException(error); } } @@ -69,6 +70,7 @@ export class ResumeController { throw new BadRequestException(ErrorMessage.ResumeSlugAlreadyExists); } + Logger.error(error); throw new InternalServerErrorException(error); } } diff --git a/apps/server/src/resume/resume.service.ts b/apps/server/src/resume/resume.service.ts index 6bfee96a..e358fa01 100644 --- a/apps/server/src/resume/resume.service.ts +++ b/apps/server/src/resume/resume.service.ts @@ -1,4 +1,9 @@ -import { BadRequestException, Injectable } from "@nestjs/common"; +import { + BadRequestException, + Injectable, + InternalServerErrorException, + Logger, +} from "@nestjs/common"; import { Prisma } from "@prisma/client"; import { CreateResumeDto, ImportResumeDto, ResumeDto, UpdateResumeDto } from "@reactive-resume/dto"; import { defaultResumeData, ResumeData } from "@reactive-resume/schema"; @@ -127,6 +132,13 @@ export class ResumeService { async update(userId: string, id: string, updateResumeDto: UpdateResumeDto) { try { + const { locked } = await this.prisma.resume.findUniqueOrThrow({ + where: { id }, + select: { locked: true }, + }); + + if (locked) throw new BadRequestException(ErrorMessage.ResumeLocked); + const resume = await this.prisma.resume.update({ data: { title: updateResumeDto.title, @@ -134,7 +146,7 @@ export class ResumeService { visibility: updateResumeDto.visibility, data: updateResumeDto.data as unknown as Prisma.JsonObject, }, - where: { userId_id: { userId, id }, locked: false }, + where: { userId_id: { userId, id } }, }); await Promise.all([ @@ -147,7 +159,8 @@ export class ResumeService { return resume; } catch (error) { if (error.code === "P2025") { - throw new BadRequestException(ErrorMessage.ResumeLocked); + Logger.error(error); + throw new InternalServerErrorException(error); } } } diff --git a/apps/server/src/user/user.controller.ts b/apps/server/src/user/user.controller.ts index 81598296..5d61fe2b 100644 --- a/apps/server/src/user/user.controller.ts +++ b/apps/server/src/user/user.controller.ts @@ -5,6 +5,7 @@ import { Delete, Get, InternalServerErrorException, + Logger, Patch, Res, UseGuards, @@ -61,6 +62,7 @@ export class UserController { throw new BadRequestException(ErrorMessage.UserAlreadyExists); } + Logger.error(error); throw new InternalServerErrorException(error); } }