Skip to content

[Feat] #14 - 네트워크 레이어 구현 및 클린아키텍쳐 예시코드 작성#25

Merged
L-j-h-c merged 7 commits intoTeamRecorDream:developfrom
L-j-h-c:feature/#14-NetworkModule
Oct 23, 2022
Merged

[Feat] #14 - 네트워크 레이어 구현 및 클린아키텍쳐 예시코드 작성#25
L-j-h-c merged 7 commits intoTeamRecorDream:developfrom
L-j-h-c:feature/#14-NetworkModule

Conversation

@L-j-h-c
Copy link
Copy Markdown
Contributor

@L-j-h-c L-j-h-c commented Oct 14, 2022

👻 작업한 내용

  1. Alamofire로 네트워크 모듈 구현
  2. 클린아키텍쳐 샘플 코드 작성

image

🎤 Alamofire로 네트워크 모듈 구현

  1. DreamWriteScene 기준으로 RecordService 내부에 예시 코드 작성했습니다. 기존에 네트워크 통신은 자유롭게 하는 것으로 정했기에 자유롭게 쓰시면 되고, 개선할 여지 있으면 알려주세요~!
  2. AlamoManager는 shared로 구현하여 여러 개의 서비스에서 동일한 매니저를 사용하도록 했습니다. 이유는 하나의 manager가 Session 전체를 관리하는 편이 앱의 규모에 적합하다고 생각했고, 그렇기에 manager가 관리중인 task에 접근하여 그 중 하나를 cancel하거나 adapting하는 것이 편리해집니다.
  3. InterCeptor는 request를 가로채어 request를 retry하거나 adapting할 수 있게 하는 클래스입니다. 토큰 재발급의 경우도 interceptor에서 처리할 수 있습니다.
  4. Service와 Router를 5종으로 나눈 것은, 서버 API에 큰 틀에서 root path가 5개 정도 존재했기 때문입니다. 임의적인 기준이니 수정이 필요하다면 자유롭게 해주시면 될 것 같습니다!

클린아키텍쳐 샘플 코드 작성

저장하기 버튼을 누르면 꿈 기록에 대해 작성할 수 있는 플로우를 클린 아키텍쳐에 따라 작성했습니다. 샘플 코드이기에 대충 작성한 부분이 꽤 있기도 하고, 저도 클린아키텍쳐가 익숙하지 못하지만 흐름을 파악하는데 조금이라도 도움이 되면 좋겠습니다!

PR Point

네트워크 모듈이 현재 Data의 하위에 있기 때문에 DTO가 네트워크 모듈 안에 있어야 했습니다. 따라서 기존에 쓰던 DTO 폴더를 네트워크 모듈 안으로 옮겼습니다. 그리고 DTO를 entity로 만들기 위한 부분을 모아놓은 Datatransform 폴더를 만들었습니다. 네이밍...의견 부탁드립니다..

📮 관련 이슈

@L-j-h-c L-j-h-c added the 록시보이 🌽 담당자 label Oct 14, 2022
@L-j-h-c L-j-h-c self-assigned this Oct 14, 2022
Comment on lines +11 to +14
public struct DreamWriteDTO: Codable {
public let userId: Int
public let content: String
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

저도 DTO 라는 네이밍에 대해 고민해봤는데용 ! 클라 쪽에서는 용도가 Request 랑 Response 로 나누어지니까 DreamWriteRequest , DreamWriteResponse 어떠신가욤 ? 아니면 그냥 Model 이나 Parameter를 붙여 네이밍하는 레퍼도 봤고용 !

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Suyeon9911 @EunHee-Jeong 좋은 의견 감사합니다~~! 저도 Response라는 네이밍 좋은 것 같은데 이걸로 바꿀까요??

Suyeon9911
Suyeon9911 previously approved these changes Oct 18, 2022
Copy link
Copy Markdown
Member

@Suyeon9911 Suyeon9911 left a comment

Choose a reason for hiding this comment

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

수고하셨습니당 ! 클린아키텍처 샘플코드까지 잘봤습니다 ~! 다만 네트워크 모듈 세팅과 샘플코드 작성하신 부분 PR을 분리해서 올려주셨다면 조금 더 확인하기 편했을 것 같습니돵 ㅎㅎ 👍🏻

case withToken
case multiPart
case multiPartWithToken
case reissuance
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

오 reissuance는 언제 쓰이는 헤더타입인가요 ??!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Suyeon9911 토큰 재발급의 경우에 사용하는 케이스입니다! BaseService에서 헤더를 분기처리하는 곳을 보시면 reissuance의 경우에만 access와 refresh token 모두를 헤더에 실어서 보내주는 것을 확인할 수 있습니다. 저번 프로젝트에서 이런 방식으로 재발급을 처리했는데 레코드림의 경우에는 다른 방식(바디에 토큰을 보내는)을 사용할 수도 있을 것 같습니다. 논의하기 나름일듯~~

@L-j-h-c L-j-h-c merged commit f38fb34 into TeamRecorDream:develop Oct 23, 2022
@L-j-h-c L-j-h-c deleted the feature/#14-NetworkModule branch January 5, 2023 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Alamofire로 네트워크 모듈 구현

2 participants