쉽지 않았을텐데,, 아주 잘하셨습니다! jwt 를 그냥 응답으로 주는 대신 cookie set을 하는 것 좋습니다.
하나 고려해보면 좋은게 jwtFromRequest: ExtractJwt.fromExtractors([...]) 배열 형태로 들어가죠? 이 뜻은 여러 방법으로 "추출" 할 수 있는데, 즉, 지금 처럼 cookie 값에서만 auth 정보를 얻어올 수 있게 하면, header 에 { "authorization" : "Bearer ..." } 값이 있어도 인식을 하지 못합니다.
여기서 user 대신 createUserDto 가 훨씬 올바른 것 같아요. 왜냐면 user 만 사용하면 이미 이 유저는 만들어진 모델인가? 라는 착각을 만들어요. 지금 request 에서 아무 전/후 처리 없이 Dto 값만 쓰고 있는데, "사용자가 요청한 값" 이라는 점에서 createUserDto 가 나을 것 같고
안녕하세요 서린님!! 매번 새로운 도전과제가 생겨서 쉽지않음에도 잘 해주시고 계셔서 좋습니다!! 🔥🔥🔥
전체 과제 체크 사항
필수 기능 구현 리스트
보너스 기능 구현 리스트
세부 피드백
인가 인증
https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/user/user.controller.ts#L28
https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/auth/jwt.strategy.ts#L10-L30
jwtFromRequest: ExtractJwt.fromExtractors([...])
배열 형태로 들어가죠? 이 뜻은 여러 방법으로 "추출" 할 수 있는데, 즉, 지금 처럼 cookie 값에서만 auth 정보를 얻어올 수 있게 하면, header 에{ "authorization" : "Bearer ..." }
값이 있어도 인식을 하지 못합니다.fromAuthHeaderAsBearerToken
도 같이 사용하면 좋습니다.user.service.ts
https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/user/user.service.ts#L27
user
라는 변수가 더 무의미 한 것 같고, 문맥상 더 의미가 옳지 않은 것 같아요.https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/user/user.service.ts#L41-L47
user
대신createUserDto
가 훨씬 올바른 것 같아요. 왜냐면 user 만 사용하면 이미 이 유저는 만들어진 모델인가? 라는 착각을 만들어요. 지금 request 에서 아무 전/후 처리 없이 Dto 값만 쓰고 있는데, "사용자가 요청한 값" 이라는 점에서 createUserDto 가 나을 것 같고https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/user/user.service.ts#L88-L92
point
의 서비스 로직까지 의존성을 가지는 것은 조금 별로인 것 같아요. 단순하게 find 하는 것인데, 차라리 repo 계층을 활용하는게 좋을 것 같아요!show.controller.ts & show.service.ts
https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/show/show.controller.ts#L26-L29
src/auth/roles.guard.ts
역시requiredRoles
좋았습니다.context.switchToHttp().getRequest();
이게 납득이 안되실 수 있는데, 저희 특강때 nestjs 에서 Request 흐름을 한 번 보는게 좋을 것 같아요!https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/show/show.controller.ts#L37-L49
@Get('/')
으로요! 그리고 합쳐지는게 더 REST 아키텍쳐에 맞습니다.search
기능은 url query string 을 활용해야 합니다!https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/show/dto/create-show.dto.ts#L56-L59
Data Transfer Object
라서 계층간 데이터 공유에 활용이 되는 것일 뿐이고, 사용자의 request를 규격화 된 데이터 셋을 컨트롤러에서 처리하게 하죠!https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/show/show.service.ts#L17-L31
showDate
만 하면 안될 것 같아요. 혹시 "데이터 베이스 정규화" 에 대해서 아시나요?!reservation
https://github.com/slianzg/nestproject-in/blob/f270d923657e7059056efe97c158f406179136b8/src/reservation/reservation.service.ts#L18-L41
this.showService.findOne
가능했는데, 동시에 누군가this.reservationRepository.save
를 처리해서 동시 예매가 되어버린다면?!