Skip to content

[김민희] sprint7#21

Merged
rjc1704 merged 4 commits intocodeit-sprint-fullstack:express-김민희from
smnhree:express-김민희-sprint7
Feb 4, 2025

Hidden character warning

The head ref may contain hidden characters: "express-\uae40\ubbfc\ud76c-sprint7"
Merged

[김민희] sprint7#21
rjc1704 merged 4 commits intocodeit-sprint-fullstack:express-김민희from
smnhree:express-김민희-sprint7

Conversation

@smnhree
Copy link

@smnhree smnhree commented Feb 1, 2025

배포 링크

https://panda-market-mhkim-react.netlify.app/

요구사항

기본

중고마켓

  • mongoDB에서 PostgreSQL을 사용하도록 코드를 마이그레이션 해주세요.

공통

  • PostgreSQL를 이용해 주세요.
  • 데이터 모델 간의 관계를 고려하여 onDelete를 설정해 주세요.
  • 데이터베이스 시딩 코드를 작성해 주세요.
  • 각 API에 적절한 에러 처리를 해 주세요.
  • 각 API 응답에 적절한 상태 코드를 리턴하도록 해 주세요.

자유게시판

  • Article 스키마를 작성해 주세요.
    • id, title, content, createdAt, updatedAt 필드를 가집니다.
  • 게시글 등록 API를 만들어 주세요.
    • title, content를 입력해 게시글을 등록합니다.
  • 게시글 조회 API를 만들어 주세요.
    • id, title, content, createdAt를 조회합니다.
  • 게시글 수정 API를 만들어 주세요.
  • 게시글 삭제 API를 만들어 주세요.
  • 게시글 목록 조회 API를 만들어 주세요.
    • id, title, content, createdAt를 조회합니다.
    • offset 방식의 페이지네이션 기능을 포함해 주세요.
    • 최신순(recent)으로 정렬할 수 있습니다.
    • title, content에 포함된 단어로 검색할 수 있습니다.

댓글

  • 댓글 등록 API를 만들어 주세요.
  • content를 입력하여 댓글을 등록합니다.
    • 중고마켓, 자유게시판 댓글 등록 API를 따로 만들어 주세요.
  • 댓글 수정 API를 만들어 주세요.
    • PATCH 메서드를 사용해 주세요.
  • 댓글 삭제 API를 만들어 주세요.
  • 댓글 목록 조회 API를 만들어 주세요.
    • id, content, createdAt 를 조회합니다.
    • cursor 방식의 페이지네이션 기능을 포함해 주세요.
    • 중고마켓, 자유게시판 댓글 목록 조회 API를 따로 만들어 주세요.

멘토에게

  • 댓글 기능의 mock data seeding 및 테스트, 미션 6의 프론트엔트와 연결은 시간 부족으로 못했습니다.

images String[]
favorite Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments Comment[] 추가하셔서 하나의 Article 에는 복수개의 Comment가 있을 수 있다는 관계필드 설정을 하셔야 합니다.

targetType TargetType
content String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

article Article @relation(fields: [targetId], references: [id], onDelete: Cascade)
위 관계 필드를 추가하셔야 articleId 로 추정되는 targetId 가 Article 테이블의 id 를 참조하게 만듦으로써 1:N 관계를 명시할 수 있습니다. 추가로 onDelete 설정을 Cascade로 명시함으로써 게시글이 삭제되면 그 게시글에 속해있는 댓글들도 함께 삭제될 수 있도록 설정할 수 있습니다.

@rjc1704
Copy link

rjc1704 commented Feb 4, 2025

민희님 대부분의 요구사항들을 모두 만족시켜주셨군요! 고생많으셨습니다. seeding 은 코드 준비는 되었는데 아직 테스트까지 못하신 것 같네요 꼭 한번 해보시면 좋을 것 같아요. 추가 코멘트는 아래에 드리도록 하겠습니다.

  • Article 과 Comment 간의 관계 설정이 스키마에 명시되어 있지 않군요. 하나의 게시글에는 여러 개의 댓글이 달릴 수 있으니, 1:N 관계를 명시하기 위한 prisma 만의 문법인 관계필드 설정을 각 model 마다 추가해줘야 합니다. 자세한 내용은 코드레벨로 코멘트 해드렸습니다.
  • 깃헙 레포지토리에 node_modules 가 들어있군요. 하지만 .gitignore 에는 node_modules 가 기재되어 있는 것으로 보아, .gitignore에 기재하기전에 먼저 push 한 상태에서 추가 조치를 하지 않은 것으로 보입니다. 깃헙 레포지토리에 남아있는 node_modules는 아래 과정을 통해 제거가 가능하니 한번 해보시면 좋겠습니다.
# git 캐시에서 node_modules 제거
git rm -r --cached node_modules

# 커밋 및 푸쉬
git add .
git commit -m "node_modules 제거"
git push origin express-김민희-sprint7
  • 폴더 구조 아키텍처를 아래와 같은 MVC 아키텍처에 따라 분류해보셔도 좋을 것 같습니다. 기능이 추가되고 확장될수록 관리하기 수월해질 겁니다.
src/
├── controllers/
│   ├── articlesController.js
│   └── productsController.js
├── models/
│   ├── articleModel.js
│   └── productModel.js
├── routes/
│   ├── articles.js
│   └── products.js
├── services/
│   ├── articleService.js
│   └── productService.js
└── index.js

@rjc1704 rjc1704 merged commit e3ccf51 into codeit-sprint-fullstack:express-김민희 Feb 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants