[Chore] v2 네트워크 공통 기반 구성 - #83
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a v2 networking foundation using Moya and Alamofire, including shared request contracts, typed response handling, bearer authentication, timeout configuration, error and cancellation mapping, health-check support, comprehensive tests, and architecture documentation. ChangesNetwork Foundation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant DefaultAPIClient
participant MoyaProviderFactory
participant MoyaProvider
participant Server
Caller->>DefaultAPIClient: request target
DefaultAPIClient->>MoyaProviderFactory: adapt target and configure provider
DefaultAPIClient->>MoyaProvider: perform request
MoyaProvider->>Server: send HTTP request
Server-->>MoyaProvider: return response
MoyaProvider-->>DefaultAPIClient: return data or error
DefaultAPIClient-->>Caller: decode result or throw APIError
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Moru/Moru/Network/Core/APIClient.swift (1)
42-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate envelope decode +
isSuccesshandling betweenrequestandrequestVoid.Both methods repeat the same decode-and-map-to-
APIErrorlogic (Lines 51-63 vs 86-101). Extracting a shared helper would keep the envelope contract in one place and reduce future drift risk.♻️ Proposed refactor
+ private func decodeEnvelope<Payload: Decodable & Sendable>( + _ type: Payload.Type, + from response: HTTPResponseSnapshot + ) throws -> APIResponse<Payload> { + do { + return try decoder.decode(APIResponse<Payload>.self, from: response.data) + } catch { + throw APIError.decoding(error.localizedDescription) + } + } + func request<Target: MoruTargetType, Payload: Decodable & Sendable>( _ target: Target, as payloadType: Payload.Type ) async throws -> Payload { let response = try await perform(target) try validateStatus(response) - let envelope: APIResponse<Payload> - - do { - envelope = try decoder.decode(APIResponse<Payload>.self, from: response.data) - } catch { - throw APIError.decoding(error.localizedDescription) - } + let envelope = try decodeEnvelope(Payload.self, from: response) guard envelope.isSuccess else { throw APIError.server( statusCode: response.statusCode, code: envelope.code, message: envelope.message ) } ... } func requestVoid<Target: MoruTargetType>(_ target: Target) async throws { let response = try await perform(target) try validateStatus(response) guard response.statusCode != 204, response.statusCode != 205 else { return } - let envelope: APIResponse<EmptyAPIResult> - - do { - envelope = try decoder.decode( - APIResponse<EmptyAPIResult>.self, - from: response.data - ) - } catch { - throw APIError.decoding(error.localizedDescription) - } + let envelope = try decodeEnvelope(EmptyAPIResult.self, from: response) guard envelope.isSuccess else { throw APIError.server( statusCode: response.statusCode, code: envelope.code, message: envelope.message ) } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Moru/Moru/Network/Core/APIClient.swift` around lines 42 - 102, Extract the duplicated envelope decoding and success validation from request and requestVoid into a shared helper on APIClient, parameterized for the requested Decodable payload type and response data/status code. Have both methods reuse that helper while preserving their existing result-unwrapping behavior in request and void-response handling for 204/205 in requestVoid.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Moru/Moru/Network/Core/APIClient.swift`:
- Around line 42-102: Extract the duplicated envelope decoding and success
validation from request and requestVoid into a shared helper on APIClient,
parameterized for the requested Decodable payload type and response data/status
code. Have both methods reuse that helper while preserving their existing
result-unwrapping behavior in request and void-response handling for 204/205 in
requestVoid.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e4ee65bf-b92f-45e5-b64e-e8309565fa87
📒 Files selected for processing (13)
Moru/Moru/Network/Core/APIClient.swiftMoru/Moru/Network/Core/APIError.swiftMoru/Moru/Network/Core/APIResponse.swiftMoru/Moru/Network/Core/AuthenticationRequirement.swiftMoru/Moru/Network/Core/MoruTargetType.swiftMoru/Moru/Network/Core/MoyaProviderFactory.swiftMoru/Moru/Network/Core/MoyaTargetAdapter.swiftMoru/Moru/Network/Core/NetworkConfiguration.swiftMoru/Moru/Network/Core/NetworkLogPlugin.swiftMoru/Moru/Network/Targets/HealthTarget.swiftMoru/MoruTests/NetworkFoundationTests.swiftMoru/docs/V2NetworkFoundation.mdREADME.md
✨ PR 유형
어떤 변경 사항이 있나요??
🛠️ 작업내용
NetworkConfiguration을 추가했습니다.MoruTargetType, public/bearer 인증 경계, Moya provider 조립과DefaultAPIClientactor를 추가했습니다.bearer token을 주입하도록 고정했습니다.
/healthTarget, deterministic Moya stub 테스트와 v2 확장 문서를 추가했습니다.검증
294 passed, 0 failed/skipped
bash Scripts/check-iphone-functional-gate.sh: passedbash Scripts/check-swiftdata-boundary.sh: passedplutil -lint Moru/Info.plist: passedgit diff --check: passed/health:HTTP 200 / OK📋 추후 진행 상황
📌 리뷰 포인트
한 번 읽는지 확인해 주세요.
맞는지 확인해 주세요.
✅ Checklist
PR이 다음 요구 사항을 충족하는지 확인해주세요!!!
Closes #81
Summary by CodeRabbit