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

[ADD] 상품 정보 UPDATE #4

Closed
wants to merge 1 commit into from
Closed

Conversation

Gyelanjjim
Copy link
Contributor

@Gyelanjjim Gyelanjjim commented Dec 2, 2022

:: 최근 작업 주제 (하나 이상의 주제를 선택해주세요.)

  • 기능 추가
  • 데이터베이스 작업
  • 리팩토링
  • 버그 수정
  • 컨벤션 수정

:: 구현 목표 - 해당 브랜치(PR)에서 구현하고자 하는 하나의 목표 작성

  • 상품 정보 업데이트

:: 구현 사항 설명 - 해당 브랜치(PR)에서 작업한 내용 작성

  • app.js, server.js 분리
  • 토큰 검증 미들웨어 추가 및 postman 테스트 완료
  • 상태코드 201 -> 200 변경
  • API 호출 시 필요한 값들에 대한 유효성 검사
  • 글로벌 에러핸들링 적용
  • AWS S3 및 유닛테스트는 미적용

:: 테스트 결과 이미지

  1. Server가 잘 동작하는지 확인할 수 있는 Terminal 캡쳐 이미지

스크린샷 2022-12-02 오후 7 24 44

  1. Postman(Client Tool)을 이용한 API 테스트 결과 이미지

스크린샷 2022-12-02 오후 6 53 19

스크린샷 2022-12-02 오후 6 53 35

  1. 작성한 Test Code가 잘 통과했는지 확인할 수 있는 이미지
  2. DB 작업 PR인 경우 Table 생성 및 수정 결과에 대해 확인할 수 있는 이미지

:: 기타 질문 및 특이 사항

Copy link

@bigfanoftim bigfanoftim left a comment

Choose a reason for hiding this comment

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

테스트 코드에 대한 작업은 어떻게 진행할지 의견을 공유해주세요!

const productUpdate = catchAsync(async (req, res) => {
const { productId } = req.params;
const { name, description, price, location, latitude, longitude, product_status_id, category_id, image_url } = req.body;
const userId = 1; //req.user.id;

Choose a reason for hiding this comment

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

토큰을 처리할 수 있는 코드를 만드셔서 이 부분은 하드 코딩되어 있을 필요가 없어보입니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

리뷰 반영했습니다


await productService.productUpdate( productId, name, description, price, location, latitude, longitude, product_status_id, category_id, image_url);

return res.status(201).json({

Choose a reason for hiding this comment

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

201은 update를 의미하는 상태 코드가 아니니 수정해주세요.

@@ -0,0 +1,7 @@
const routes = require("express").Router();
const productController = require("../controllers/product.controller");
//const { verifyToken } = require("../utils/verifyToken")

Choose a reason for hiding this comment

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

👀

Copy link

@bigfanoftim bigfanoftim left a comment

Choose a reason for hiding this comment

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

이외에는 주석이 너무 많아 말씀드리기가 곤란합니다. 불필요한 주석은 최대한 지우시고 올려주시고 주석을 하신 타당한 이유가 있다면 그것에 대한 커멘트도 남겨주세요. PR로 소통하는 것은 개발자가 일을 할 때 갖춰야 할 가장 중요한 기술입니다.

bucket: process.env.BUCKET_NAME,
contentType: multerS3.AUTO_CONTENT_TYPE,
key: (req, file, callback) => {
const uploadDirectory = req.query.directory ?? ''

Choose a reason for hiding this comment

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

req.query.directory를 보니 어디다 저장할지 클라이언트로 부터 받으려고 하시는게 맞을까요?
굳이 그럴 필요가 없어보입니다. 버킷 내 어느 디렉토리에 저장할지는 각 서비스의 서버에서 관리하는 것이 더 좋아보입니다.

@Gyelanjjim
Copy link
Contributor Author

직접 작성한 코드가 아니라 긁어온 자료라서 뭘 어떻게 물어봐야할지 모르겠습니다

AWS S3 생성,
ACL 설정
region, access key, scret access key, bucket name을
.env 파일과 imageUploader.js 파일에 설정

routes:
const upload = require('../utils/imageUplaoder')
upload.single('string') //이미지 1개
upload.array('string', 최대개수) //이미지 n개

...라는 미들웨어를 사용한다는 것까지 이해했습니다

@Gyelanjjim Gyelanjjim closed this Dec 8, 2022
@Gyelanjjim Gyelanjjim deleted the feature/productUpdate branch December 8, 2022 14:14
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.

None yet

2 participants