Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a44440d
[#19] 워크플로우 작성
mooninbeom Feb 24, 2025
93a6ffe
[#19] Github Secrets 추가
mooninbeom Feb 24, 2025
4b978c4
[#19] job 네이밍 변경
mooninbeom Feb 24, 2025
e528cde
[#19] CD 구현(깃허브 release)
mooninbeom Feb 24, 2025
e877e1d
[#19] 릴리즈 body 추가
mooninbeom Feb 24, 2025
7bfe8c3
[#21] RepositoryError LocalizedError 적용
thinkySide Feb 27, 2025
552afdd
[#19] workflow renaming
mooninbeom Feb 28, 2025
8a4f382
[#19] workflow 수정
mooninbeom Feb 28, 2025
c300f20
Merge pull request #22 from Team-Capple/issue/#21-networkerror-locliz…
thinkySide Mar 1, 2025
0257dde
Merge pull request #20 from Team-Capple/issue/#19-GithubActions
thinkySide Mar 1, 2025
a6401ff
[#23] 권한 변경 API 추가 및 유닛테스트 추가
thinkySide Mar 1, 2025
8f2b0ff
[#23] 메일 인증 화이트리스트 API 연결
thinkySide Mar 1, 2025
2156477
[#23] 회원가입 인증코드 유닛테스트 추가
thinkySide Mar 3, 2025
6f4a9c5
[#23] CERT_CODE secrets workflow 추가
thinkySide Mar 3, 2025
5c70cf2
[#23] 질문 리스트 조회 테스트 실패 수정
thinkySide Mar 3, 2025
2897149
[#23] 유닛테스트 최적화
thinkySide Mar 3, 2025
9e77f1b
Merge pull request #24 from Team-Capple/issue/#23-unit-test
thinkySide Mar 4, 2025
ccdfd3e
[#27] AnswerAPI writerGeneration 추가
thinkySide Mar 4, 2025
665e716
[#25] DTO 수정
OhMyungJin Mar 4, 2025
60b25be
[#26] DTO 업데이트
mooninbeom Mar 5, 2025
8cf10e2
Merge pull request #28 from Team-Capple/issue/#27-question-answer
mooninbeom Mar 5, 2025
f43b4dc
Merge pull request #29 from Team-Capple/feat/#25-BulletinBoard-API
mooninbeom Mar 5, 2025
2a62587
Merge pull request #30 from Team-Capple/issue/#26-APIWithCommentNotif…
mooninbeom Mar 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/qappleRepoCI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: Package Test

on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main

jobs:
test:
runs-on: macos-latest

steps:
- name: Branch Checkout ✔
uses: actions/checkout@v4

- name: Setup Swift 🦉
uses: swift-actions/setup-swift@v2.2.0
with:
swift-version: "6"

- name: Build 💻
run: swift build -v

- name: Test 🧪
run: TEST_URL=${{secrets.TEST_URL}} PRODUCTION_URL=${{secrets.PRODUCTION_URL}} PORT_NUM=${{secrets.PORT_NUM}} CERT_CODE=${{secrets.CERT_CODE}} swift test -v
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release Tag 🏷️

on:
push:
branches:
- main


jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Branch Checkout
uses: actions/checkout@v4

- name: 버전 정보 추출
run: echo "##[set-output name=version;]$(echo '${{ github.event.head_commit.message }}' | egrap -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')"
id: extract_version_name

- name: Release & Tag 생성 🏎️
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{steps.extract_version_name.outputs.version}}
release_name: ${{steps.extract_version_name.outputs.version}}
body: ${{github.event.pull_request.body}}
4 changes: 2 additions & 2 deletions Sources/QappleRepository/API/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ extension RawRepresentable where RawValue == String, Self: API {
let baseURLString = try BaseURL.fetch(from: server)
guard let baseURL = URL(string: baseURLString)?
.appendingPathComponent(Self.basePath) else {
throw APIError.invalidBaseUrl("BaseURL Error: \(baseURLString)")
throw RepositoryError.invalidBaseUrl("BaseURL Error: \(baseURLString)")
}
guard let url = URL(string: baseURL.absoluteString + rawValue) else {
throw APIError.invalidBaseUrl("RawValue Error: \(rawValue)")
throw RepositoryError.invalidBaseUrl("RawValue Error: \(rawValue)")
}
return url
}
Expand Down
18 changes: 0 additions & 18 deletions Sources/QappleRepository/API/APIError.swift

This file was deleted.

8 changes: 4 additions & 4 deletions Sources/QappleRepository/API/BaseURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ enum BaseURL {
static func fetch(from server: Server) throws -> String {
if Bundle.main == Bundle(for: PackageClass.self) {
guard let host = Bundle.main.infoDictionary?[serverKey(server)] as? String else {
throw APIError.invalidSecretKey("HOST_URL_\(server.rawValue.uppercased())")
throw RepositoryError.invalidSecretKey("HOST_URL_\(server.rawValue.uppercased())")
}
guard let port = Bundle.main.infoDictionary?["PORT_NUM"] as? String else {
throw APIError.invalidSecretKey("PORT_NUM")
throw RepositoryError.invalidSecretKey("PORT_NUM")
}
return "\(scheme)://\(host):\(port)"
} else {
guard let host = ProcessInfo.processInfo.environment[serverKey(server)] else {
throw APIError.invalidSecretKey("HOST_URL_\(server.rawValue.uppercased())")
throw RepositoryError.invalidSecretKey("HOST_URL_\(server.rawValue.uppercased())")
}
guard let port = ProcessInfo.processInfo.environment["PORT_NUM"] else {
throw APIError.invalidSecretKey("PORT_NUM")
throw RepositoryError.invalidSecretKey("PORT_NUM")
}
return "\(scheme)://\(host):\(port)"
}
Expand Down
18 changes: 17 additions & 1 deletion Sources/QappleRepository/API/QappleAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ enum QappleAPI {
/// 회원가입
case signUp

/// 사용자 자격 변경
case roleChange(role: String)

/// 메일 인증 화이트 리스트 등록
case emailWhitelist(mail: String, whitelistDurationMinutes: Int64)

var rawValue: RawValue {
switch self {
case let .certification(signUpToken, email):
Expand Down Expand Up @@ -139,9 +145,19 @@ enum QappleAPI {

case .signUp:
appending(baseString: "sign-up")

case let .roleChange(role):
appending(baseString: "role/change", urlQueryItems: [
.init(key: "role", value: role)
])

case let .emailWhitelist(mail, whitelistDurationMinutes):
appending(baseString: "email/whitelist/register", urlQueryItems: [
.init(key: "mail", value: mail),
.init(key: "whitelistDurationMinutes", value: whitelistDurationMinutes)
])
}
}

}

// MARK: - Board
Expand Down
1 change: 1 addition & 0 deletions Sources/QappleRepository/DTO/Answer/AnswerListOfMine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public struct AnswerListOfMine: Decodable, Sendable {
public let answerId: Int
public let writerId: Int
public let nickname: String
public let writerGeneration: String
public let profileImage: String?
public let content: String
public let heartCount: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public struct AnswerListOfQuestion: Decodable, Sendable {
public let writerId: Int
public let profileImage: String?
public let nickname: String
public let writerGeneration: String
public let content: String
public let isMine: Bool
public let isReported: Bool
Expand Down
1 change: 1 addition & 0 deletions Sources/QappleRepository/DTO/Board/BoardList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct BoardList: Decodable, Sendable {
public let boardId: Int
public let writerId: Int
public let writerNickname: String
public let writerGeneration: String
public let content: String
public let heartCount: Int
public let commentCount: Int
Expand Down
1 change: 1 addition & 0 deletions Sources/QappleRepository/DTO/Board/SearchBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct SearchBoard: Decodable, Sendable {
public let boardId: Int
public let writerId: Int
public let writerNickname: String
public let writerGeneration: String
public let content: String
public let heartCount: Int
public let commentCount: Int
Expand Down
1 change: 1 addition & 0 deletions Sources/QappleRepository/DTO/Board/SingleBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public struct SingleBoard: Decodable, Sendable {
public let boardId: Int
public let writerId: Int
public let writerNickname: String
public let writerGeneration: String
public let content: String
public let heartCount: Int
public let commentCount: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public struct BoardCommentList: Decodable, Sendable {
public struct Content: Decodable, Sendable {
public let boardCommentId: Int
public let writerId: Int
public let writerGeneration: String
public let content: String
public let heartCount: Int
public let isLiked: Bool
Expand Down
13 changes: 13 additions & 0 deletions Sources/QappleRepository/DTO/Member/RoleChange.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// RoleChange.swift
// QappleRepository
//
// Created by Simmons on 2/12/25.
//

import Foundation

public struct RoleChange: Decodable, Sendable {
public let accessToken: String
public let refreshToken: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public struct NotificationList: Decodable, Sendable {
public let subtitle: String?
public let content: String?
public let boardId: String?
public let isReportedBoard: Bool?
public let questionId: String?
public let isResponsedQuestion: Bool?
public let boardCommentId: String?
public let createdAt: String
}
Expand Down
13 changes: 13 additions & 0 deletions Sources/QappleRepository/Entity/MemberRole.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// MemberRole.swift
// QappleRepository
//
// Created by 김민준 on 3/1/25.
//

import Foundation

public enum MemberRole: String, Sendable {
case academier = "ROLE_ACADEMIER"
case admin = "ROLE_ADMIN"
}
14 changes: 0 additions & 14 deletions Sources/QappleRepository/Entity/PaginationInfo.swift

This file was deleted.

58 changes: 58 additions & 0 deletions Sources/QappleRepository/Entity/RepositoryError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// RepositoryError.swift
// Qapple-Repository
//
// Created by 김민준 on 2/9/25.
//

import Foundation

/// Repository에서 발생할 수 있는 에러를 정의합니다.
public enum RepositoryError: Error, Sendable {

/// 유효하지 않은 SecretKey 에러
case invalidSecretKey(String)

/// 기본 URL 에러
case invalidBaseUrl(String)

/// URLReuqest 함수 호출에 실패했습니다.
case urlRequestFailure(urlString: String)

/// 유효하지 않은 Response입니다.
case invalidResponse(urlString: String, statusCode: Int, message: String)

/// 인증에 실패했습니다.(403 에러)
case authenticationFailed

/// Decoding에 실패했습니다.
case decodingFailure(type: Decodable.Type)

/// 실패 Response
struct FailedResponse: Decodable {
let message: String
}
}

// MARK: - LocalizedError

extension RepositoryError: LocalizedError {

/// 에러 메시지
public var errorDescription: String? {
switch self {
case let .invalidSecretKey(string):
NSLocalizedString("\(string) 설정 오류", comment: "invalidSecretKey")
case .invalidBaseUrl:
NSLocalizedString("BaseURL 설정 오류", comment: "invalidBaseUrl")
case .urlRequestFailure:
NSLocalizedString("네트워크 요청 실패", comment: "urlRequestFailure")
case let .invalidResponse(_, statusCode, message):
NSLocalizedString("잘못된 네트워크 응답: \(statusCode) + \(message)", comment: "invalidResponse")
case .authenticationFailed:
NSLocalizedString("액세스 토큰 만료: 403", comment: "authenticationFailed")
case let .decodingFailure(type):
NSLocalizedString("디코딩 실패: \(type)", comment: "decodingFailure")
}
}
}
29 changes: 0 additions & 29 deletions Sources/QappleRepository/NetworkService/NetworkError.swift

This file was deleted.

10 changes: 5 additions & 5 deletions Sources/QappleRepository/NetworkService/NetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extension NetworkService {

return try await URLSession.shared.data(for: request)
} catch {
throw NetworkError.urlRequestFailure(urlString: url.absoluteString)
throw RepositoryError.urlRequestFailure(urlString: url.absoluteString)
}
}

Expand Down Expand Up @@ -127,13 +127,13 @@ extension NetworkService {
let successStatusCodeRange = 200...299
guard successStatusCodeRange.contains(statusCode) else {
if statusCode == 403 {
throw NetworkError.authenticationFailed
throw RepositoryError.authenticationFailed
} else {
let failedResponse = try? decoder.decode(
NetworkError.FailedResponse.self,
RepositoryError.FailedResponse.self,
from: data
)
throw NetworkError.invalidResponse(
throw RepositoryError.invalidResponse(
urlString: response.url?.absoluteString ?? "",
statusCode: statusCode,
message: failedResponse?.message ?? "에러 메시지 없음"
Expand All @@ -156,7 +156,7 @@ extension NetworkService {
)
return decodedData.result
} catch {
throw NetworkError.decodingFailure(type: T.self)
throw RepositoryError.decodingFailure(type: T.self)
}
}
}
Loading
Loading