Skip to content
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

Fix/#42/게시물 api 수정 #43

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Fix/#42/게시물 api 수정 #43

wants to merge 2 commits into from

Conversation

sim16065
Copy link
Collaborator

@sim16065 sim16065 commented Feb 27, 2025

관련 이슈

#이슈번호 (#42 )

📝 제목

[Fix] 게시물 권한 처리 및 이미지 업로드 검증 수정

📋 작업 내용

  • 이미지 업로드 URL 검증 추가 (base64 인코딩 및 jpg 포맷 확인)

  • 유저 세션 기반으로 게시물 생성, 수정, 삭제 권한 처리 구현

  • 검증 후 이미지 URL을 DB에 저장

🚀 테스트 사항(선택)

기능 테스트 완료
API 테스트 (Postman으로 이미지 업로드 테스트)
예외 처리 확인 (base64와 jpg 포맷만 허용)

💬 리뷰 요구사항 (선택)

이미지 업로드 로직에 대해 코드 리뷰 부탁드립니다.
예외 처리 부분에서 누락된 부분이 없는지 확인 부탁드립니다.

- 유저 세션 기반으로 게시물 생성, 수정, 삭제 권한 처리 구현.
- 이미지 업로드 URL 검증 추가, base64 인코딩과 jpg 포맷 확인.
- 검증 후 이미지 URL을 DB에 저장.
@sim16065 sim16065 added the duplicate This issue or pull request already exists label Feb 27, 2025
@sim16065 sim16065 self-assigned this Feb 27, 2025
const imageUrl = await uploadBase64ImageToS3(postImg);

const post = new Post({ content, postImg: imageUrl }, userId);
const postId = await post.createPost(); // createPost 호출 (Poststorage와 연결)
Copy link
Collaborator

Choose a reason for hiding this comment

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

createPost 호출은 const Post = require("../models/Post"); 여기서 하는 중인데
주석 오타가 난 것인가요 ?


const post = new Post({ content, postImg: imageUrl }, userId);

const result = await post.updatePost(id);

if (result) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (result) {
if (!result) {
return sendResponse(res, 403, false, "수정 권한이 없거나 게시물이 존재하지 않습니다.");

와 같이 early return 방식을 사용하면 불 필요한 조건문 하나를 없앨 수 있어서
코드 가독성이 더 올라갈 것 같습니다~

imageUrl = await uploadBase64ImageToS3(postImg);
}

const post = new Post({ content, postImg: imageUrl }, userId);
Copy link
Collaborator

@gwgw123 gwgw123 Feb 27, 2025

Choose a reason for hiding this comment

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

@Ryu-02 님한테도 말씀 드렸지만
userId를 DB에 사용하기전 사용자를 검증하는 로직이 필요해보입니다 ~

나중에 확인했는데 명규님이 만들고 계시군요 ㅎㅎ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants