Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 50 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: "./dist"

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
"coverage": "vitest run --coverage"
},
"dependencies": {
"@tanstack/react-query": "^5.90.12",
"@tanstack/react-query-devtools": "^5.91.1",
"react": "^19.2.1",
"react-dom": "^19.2.1"
"react-dom": "^19.2.1",
"zustand": "^5.0.9"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
Expand Down
1,772 changes: 731 additions & 1,041 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { BrowserRouter as Router } from "react-router-dom"
import Header from "./components/Header.tsx"
import Footer from "./components/Footer.tsx"
import PostsManagerPage from "./pages/PostsManagerPage.tsx"
import Header from "./shared/ui/Header.tsx"
import Footer from "./shared/ui/Footer.tsx"
import PostsManagerPage from "./pages/PostManager/PostsManagerPage.tsx"
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"

const App = () => {
const queryClient = new QueryClient()

return (
<Router>
<div className="flex flex-col min-h-screen">
<Header />
<main className="flex-grow container mx-auto px-4 py-8">
<PostsManagerPage />
</main>
<Footer />
</div>
</Router>
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
<Router>
<div className="flex flex-col min-h-screen">
<Header />
<main className="flex-grow container mx-auto px-4 py-8">
<PostsManagerPage />
</main>
<Footer />
</div>
</Router>
</QueryClientProvider>
)
}

Expand Down
214 changes: 0 additions & 214 deletions src/components/index.tsx

This file was deleted.

19 changes: 19 additions & 0 deletions src/entities/comment/api/addCommentApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { AddCommentRequest, Comment } from "../model/comment"
import { getApiUrl } from "../../../shared/api/apiClient"

const addCommentApi = async ({ comment }: { comment: AddCommentRequest }): Promise<Comment> => {
const response = await fetch(getApiUrl(`/comments/add`), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(comment),
})

if (!response.ok) {
throw new Error(`댓글 추가 실패: ${response.status} ${response.statusText}`)
}

const data = await response.json()
return data
}

export default addCommentApi
16 changes: 16 additions & 0 deletions src/entities/comment/api/deleteCommentApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { getApiUrl } from "../../../shared/api/apiClient"

const deleteCommentApi = async ({ id }: { id: number }) => {
const response = await fetch(getApiUrl(`/comments/${id}`), {
method: "DELETE",
})

if (!response.ok) {
throw new Error(`댓글 삭제 실패: ${response.status} ${response.statusText}`)
}

const data = await response.json()
return data
}

export default deleteCommentApi
15 changes: 15 additions & 0 deletions src/entities/comment/api/getCommentsApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { GetCommentsResponse } from "../model/comment"
import { getApiUrl } from "../../../shared/api/apiClient"

const getCommentsApi = async ({ postId }: { postId: number }): Promise<GetCommentsResponse> => {
try {
const response = await fetch(getApiUrl(`/comments/post/${postId}`))
const data = await response.json()
return data
} catch (error) {
console.error("댓글 가져오기 오류:", error)
return { comments: [], total: 0, skip: 0, limit: 0 }
}
}

export default getCommentsApi
18 changes: 18 additions & 0 deletions src/entities/comment/api/likeCommentApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getApiUrl } from "../../../shared/api/apiClient"

const likeCommentApi = async ({ id, likes }: { id: number; likes: number }) => {
const response = await fetch(getApiUrl(`/comments/${id}`), {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ likes }),
})

if (!response.ok) {
throw new Error(`댓글 좋아요 실패: ${response.status} ${response.statusText}`)
}

const data = await response.json()
return data
}

export default likeCommentApi
Loading