목록NestJS, Node.js/#01 Project - 투표 커뮤니티 (27)
개발일지
로그아웃플로우제가 생각한 로그아웃 플로우는 다음과 같습니다.클라이언트에서 로그아웃 api를 요청합니다.DB에 저장된 refresh token을 삭제한 후 결과를 response 합니다.삭제 성공일 경우, 헤더에 있는 access token을 제거합니다. 구현// auth/auth.controller.ts@Delete('sign-out')async signOut() { const userId = 1; const data: SignOutUserDto = { userId, }; return await this.authService.signOut(data);} // auth/auth.service.tsasync signOut(data: SignO..
작성한 투표글과 댓글 조회는 users 모듈, votes 모듈 어디에 생성할지 고민하다가 users 기능과 더 가깝다고 생각하여 users에 생성했습니다. 프로필 조회전에 만들어놓은 WhereOptionByUserId 타입을 지정하여 where 조건 객체를 생성하여 인수로 넘겨줍니다. @Control..
댓글 목록 조회투표 글을 클릭하면 그 투표글에 대한 댓글 목록을 불러올 수 있어야합니다. @Param()으로 해당 투표 글의 id를 받아옵니다. // votes/votes.controller.ts@Controller('votes/:voteId/comments')export class CommentsController { constructor( private readonly commentsReposit..
앞서 했었던 투표 글 좋아요 및 취소 구현과 구현 방식이 같으므로 설명은 생략하겠습니다. modelingmodel VoteComments { i..
요구사항댓글댓글을 작성할 수 있습니다.댓글에 좋아요를 누를 수 있습니다.대댓글 작성 modeling..
투표 글 삭제투표 글 삭제 시 해당 투표 글의 선택지와 댓글들도 함께 삭제되어야합니다. 스키마에 Cascade 옵션을 추가했습니다. // votes/votes.prismamodel Votes { id Int @id @default(autoincrement()) ... voteChoices VoteChoices[] VoteComments VoteComments[]}model VoteChoices { id Int @id @default(autoincrement()) vote Votes @relation(fields: [voteId], references: [id], onDelete: Cascade) voteId..
투표글 조회생성된 투표글 목록 조회투표 제목, 전체 투표수, 좋아요 수세부 내용 조회투표 제목, 전체 투표수, 좋아요 수, 선택지, 선택지별 투표수좋아요를 누를 수 있습니다. 투표글 목록 조회// votes/votes.controller.ts@Get()async listVotes(): Promise { return { votes: await this.votesRepository.getAllVotes() };} // votes/votes.repository.tsasync getAllVotes(): Promise { return await this.prisma.votes.findMany({ include: { voteChoices: { select: { id: ..