Eomhyein / employment

Node.js 숙련 개인과제 나만의 채용 서비스 백엔드 서버 만들기
0 stars 0 forks source link

feedback #17

Open ggomma opened 1 month ago

ggomma commented 1 month ago

feedback

총평

필요 구현 사항

개선 사항

router 등록

router를 등록할 때에는 일반적으로 배열을 이용합니다. 물론 현재 구현하신 방식도 틀린 것은 아니나 미들웨어와 동일한 방식으로 router를 등록하기에 가독성이 떨어집니다.

app.use("/", [AuthRouter, UsersRouter, ResumeRouter])

https://github.com/Eomhyein/employment/blob/7784e41bc8c87fc64ac0c66e716974541496f26b/src/app.js#L19

변수명

users 보다는 user 가 좋지 않을까요?

https://github.com/Eomhyein/employment/blob/7784e41bc8c87fc64ac0c66e716974541496f26b/src/routers/auth.router.js#L60

코드 구조

auth에 관련된 코드는 auth.router.js에 함께 구현하는 것이 좋습니다.

환경변수

dotenv는 최초에 한번만 호출해주면 됩니다.

https://github.com/Eomhyein/employment/blob/7784e41bc8c87fc64ac0c66e716974541496f26b/src/constants/auth.constant.js#L4

변수는 camel case로

변수를 선언할 때에는 camel case 방식을 지켜주는 것이 가독성에 도움이 됩니다.

https://github.com/Eomhyein/employment/blob/7784e41bc8c87fc64ac0c66e716974541496f26b/src/routers/resumes.router.js#L11

응답에서 메시지와 데이터 분리

API 응답에서는 메시지와 데이터를 분리하는 것이 좋습니다.

return res.status(201).json({
  data: {
    id: "...",
  },
  message: "...",
})

https://github.com/Eomhyein/employment/blob/7784e41bc8c87fc64ac0c66e716974541496f26b/src/routers/resumes.router.js#L42-L51

Eomhyein commented 1 month ago