Skip to content

[A팀 박유경} 백엔드 API 과제제출 - #10

Open
ukongee wants to merge 2 commits into
jinu0328:mainfrom
ukongee:main
Open

[A팀 박유경} 백엔드 API 과제제출#10
ukongee wants to merge 2 commits into
jinu0328:mainfrom
ukongee:main

Conversation

@ukongee

@ukongee ukongee commented Nov 23, 2024

Copy link
Copy Markdown

fastAPI를 사용했습니다

@ukongee ukongee changed the title 박유경 백엔드 과제제출 [A팀 박유경} 백엔드 API 과제제출 Nov 23, 2024

@jinu0328 jinu0328 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

요구사항을 충실히 구현해주신 것 같습니다 👍
몇가지 피드백을 남겼으니 참고해주시면 좋을 것 같습니다.
과제 수행하시느라 고생 많으셨습니다!

Comment thread src/requirements.txt

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

requirements.txt를 통해 의존 라이브러리 관리를 해주고 계십니다. 혹시 앞으로도 파이썬 계열 프레임워크를 사용하실 계획이라면 requirements.txt 보다는 라이브러리별로 버전까지 관리해주는 poetry의 사용법을 한번 익혀보시는 걸 추천드립니다 ㅎㅎ
저도 예전에는 requirements.txt로 관리했던 경험이 있지만 라이브러리끼리 버전 문제로 호환이 되지 않는 경우 직접 에러를 살펴보고 구글링해서 고쳤던 기억이 납니다. poetry를 사용한다면 이런 문제를 사전에 방지할 수 있어 추천드립니다! 😄

Comment thread src/models.py
__tablename__ = 'tasks'

id = Column(Integer, primary_key=True, index=True)
title = Column(String, index=True)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

id 필드는 primary_key를 통해 기본키로 설정되었으므로 명시적으로 index=true 조건을 걸지 않아도 인덱스를 생성합니다 😄

Comment thread src/models.py

id = Column(Integer, primary_key=True, index=True)
title = Column(String, index=True)
is_done = Column(Boolean, default=False)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

요구사항에 따라 달라질 수 있겠지만 현재 요구사항에는 is_done을 통해 쿼리를 하는 경우가 많으므로 title 보다는 is_done에 인덱스를 설정해주는 것이 좋을 것 같습니다!

Comment thread src/schemas.py
class TaskUpdate(BaseModel):
title: str = None
is_done: bool = None

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

클라이언트에 의해 입력된 값만 수정 될 수 있도록 기본값을 None으로 설정해주신 것 좋습니다 👍

Comment thread src/routers/tasks.py

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

현재는 api의 수가 많지 않아 직접 응답을 작성해서 반환하는 것이 큰 단점이라 볼 수는 없겠지만 따로 응답 객체를 만들어서 일관성 있는 응답 형식을 제공해보는 것을 추천 드립니다!

ex)

class ApiResponse(BaseModel):
    status: str  
    message: str  
    data: Optional[Any] = None  

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