Skip to content

[김지희] 스프린트미션 2 #23

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

Merged
merged 2 commits into from
Jul 28, 2025

Conversation

jizihub
Copy link
Collaborator

@jizihub jizihub commented Jul 22, 2025

요구사항

클래스 구현하기

  • product 클래스, ElectronicProduct클래스를 만들어주세요
  • class 키워드를 이용해서 Article 클래스를 만들어주세요.
  • 각 클래스 마다 constructor를 작성해주세요.
  • 추상화/캡슐화/상속/ 다형성을 고려하여 코드를 작성해주세요.

요청함수 구현하기

  • GET
  • POST
  • POST, body
  • PATCH
  • DELETE
  • fetch/axios
  • export/ import

GIT 사용하기

  • README.md 작성하기
  • 스프린트 미션 업로드하기
  • 커밋 메시지 남기기
  • PR 커멘트 작성하기

멘토에게

  • ..

@jizihub jizihub changed the title article/product/main API function [김지희] 스프린트미션 2 Jul 22, 2025
Copy link
Collaborator

@shinYeongHyeon shinYeongHyeon left a comment

Choose a reason for hiding this comment

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

요소요소에 WoW 포인트 들이 있었습니다.
엄청난 보석을 발견한 기분이에요!

그럼에도 아직 고쳐야할 부분들은 있으나, 그 부분들이 사소한 부분들이거나, 아직 많은 코드를 작성하지 않아서 나오는 부분들인 것같아요 !
이대로만 하신다면 굉장히 좋을 것 같네요 !

Comment on lines +2 to +4
const instance = axios.create({
baseURL: 'https://panda-market-api-crud.vercel.app'
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

axios 의 create를 통해 instance를 기본적으로 만들어 내다니요 !
감탄했습니다 너무 좋은 코드를 보여주는 단 3줄이네요 ! 👍🏼

Comment on lines +5 to +23
export class Article {
#likeCount;

constructor(title, content, writer, likeCount = 0, createdAt = new Date()) {
this.title = title;
this.writer = writer;
this.#likeCount = likeCount;
this.content = content;
this.createdAt = createdAt;
}
getLikeCount(){
return this.#likeCount;
}

like() {
this.#likeCount += 1
return this.likeCount;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Article 클래스를 Service 안에 녹이기보다는 따로 분리하여 import 하는건 어떨까요 !

Comment on lines +9 to +13
this.title = title;
this.writer = writer;
this.#likeCount = likeCount;
this.content = content;
this.createdAt = createdAt;
Copy link
Collaborator

Choose a reason for hiding this comment

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

다른 변수들도 # 를 통해서 private 하여 캡슐화/추상화 를 진행해보는건 어떨까요 !


like() {
this.#likeCount += 1
return this.likeCount;
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 부분에 return this.#likeCount 가 되어야 할 것 같습니다 !

constructor(title, content, writer, likeCount = 0, createdAt = new Date()) {
this.title = title;
this.writer = writer;
this.#likeCount = likeCount;
Copy link
Collaborator

Choose a reason for hiding this comment

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

likeCount 를 받을때 음수 체크를 해보면 더 안정적인 코드가 작성 될 것 같아요 !

if (likeCount < 0) {
  throw ...
}

}

export async function createArticle(articleBody){
const res = instance. post(`/articles`,articleBody)
Copy link
Collaborator

Choose a reason for hiding this comment

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

instance.post 이렇게 붙여쓰는게 더 좋을 것 같네요 !

}

export async function getArticle(id){
const res = instance.get(`/articles/${id}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

template literal 을 적절하게 사용했네요 ! 👍🏼

return res;
}

export async function patchArticle (id, ArticleListType){
Copy link
Collaborator

Choose a reason for hiding this comment

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

ArticleListType 이 적절한 변수명이 아닌 듯합니다!
적절한 변수명은 가독성에 아주 중요한 역할을 하므로 변수명에 조금 더 신경을 써보면 좋을 것 같아요 !

Copy link
Collaborator

Choose a reason for hiding this comment

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

이 부분도 ProductService와 같은 리뷰들이 남겨집니다 !

import axios from 'axios';
const instance = axios.create({
baseURL: 'https://panda-market-api-crud.vercel.app'
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기서는 fetch를 한번 써보는건 어땠을까요 ! (공부할겸!)

@shinYeongHyeon shinYeongHyeon merged commit ad2021f into codeit-bootcamp-nodejs:김지희 Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants