Skip to content
This repository has been archived by the owner on Dec 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from Team-INSERT/refactor/change-dto
Browse files Browse the repository at this point in the history
refactor : 백엔드 변경사항에 맞게 DTO 변경
  • Loading branch information
Ubinquitous authored Apr 22, 2024
2 parents 2cea5fd + 40fbb7a commit c0ef908
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 30 deletions.
11 changes: 2 additions & 9 deletions apps/wiki/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios from "axios";
import { ERROR, TOKEN } from "@/constants";
import { Storage } from "@/storage";
import { refreshToken } from "./header";
import { ERROR } from "@/constants";
import { refresh } from "@/services/auth/auth.api";

export const http = axios.create({
baseURL: process.env.NEXT_PUBLIC_SERVER_URL,
Expand All @@ -23,9 +22,3 @@ http.interceptors.response.use(
return Promise.reject(error);
},
);

const refresh = async () => {
const { data } = await http.put("/auth/refresh/access", null, refreshToken());
Storage.setItem(TOKEN.ACCESS, data.accessToken);
return data.accessToken;
};
17 changes: 8 additions & 9 deletions apps/wiki/app/history/[title]/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@ import * as styles from "./style.css";

const History = ({ title }: { title: string }) => {
const { formatDate } = useDate();
const { data: historyList } = useSuspenseQuery(historyQuery.list(title));
const decodeTitle = decodeURI(title);
const { data: history } = useSuspenseQuery(historyQuery.list(title));

return (
<Suspense>
<Container title={decodeTitle} docsType={decodeTitle}>
{historyList.versionDocsResponseDto.map((history) => (
<Container title={history.title} docsType={history.docsType}>
{history.versionDocsResponseDto.map((docsHistory) => (
<Link
href={`/history/${decodeTitle}/detail/${history.index}`}
href={`/history/${history.title}/detail/${docsHistory.index}`}
className={styles.historyBox}
key={String(history.thisVersionCreatedAt)}
key={String(docsHistory.thisVersionCreatedAt)}
>
<hgroup className={styles.hgroup}>
<h1 className={styles.historyId}>#{history.index}</h1>
<h1 className={styles.historyId}>#{docsHistory.index}</h1>
<time className={styles.createdAt}>
편집일 ·&nbsp;
{formatDate(history.thisVersionCreatedAt)}
{formatDate(docsHistory.thisVersionCreatedAt)}
</time>
</hgroup>
<span className={styles.author}>작성자 ·&nbsp;{history.nickName}</span>
<span className={styles.author}>작성자 ·&nbsp;{docsHistory.nickName}</span>
</Link>
))}
</Container>
Expand Down
2 changes: 1 addition & 1 deletion apps/wiki/components/Popular/Popular.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Popular = () => {
>
<header className={styles.titleBox}>인기</header>
<ul className={styles.docsList}>
{popularList.slice(0, 10).map((popular, index) => (
{popularList.map((popular, index) => (
<Link
href={`/docs/${popular.title}`}
className={styles.docsListItem[containerStatus]}
Expand Down
15 changes: 10 additions & 5 deletions apps/wiki/services/auth/auth.api.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { http } from "@/apis";
import { refreshToken } from "@/apis/header";
import { TOKEN } from "@/constants";
import { Storage } from "@/storage";

export const requestLogin = async (authCode: string) => {
const { data } = await http.post("/auth/oauth/bsm", null, { headers: { authCode } });
export const refresh = async () => {
const { data } = await http.put("/auth/refresh/access", null, refreshToken());
Storage.setItem(TOKEN.ACCESS, data.accessToken);
return data.accessToken;
};

export const requestLogin = async (accessToken: string) => {
const { data } = await http.post("/auth/oauth/bsm", { accessToken });
return data;
};

export const requestLogout = async () => {
const { data } = await http.delete("/auth/bsm/logout", {
headers: { RefreshToken: Storage.getItem(TOKEN.REFRESH) },
});
const { data } = await http.delete("/auth/bsm/logout", refreshToken());
return data;
};
4 changes: 2 additions & 2 deletions apps/wiki/services/docs/docs.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getLastModifiedDocsList = async (page: number) => {
};

export const requestCreateDocs = async (docs: CreateDocsType) => {
const { data } = await http.post("/docs/create", docs, authorization());
const { data } = await http.post("/docs", docs, authorization());
return data;
};

Expand All @@ -43,7 +43,7 @@ export const requestUpdateDocs = async ({
};

export const requestDeleteDocs = async (id: number) => {
const { data } = await http.delete(`/docs/delete/${id}`, authorization());
const { data } = await http.delete(`/docs/${id}`, authorization());
return data;
};

Expand Down
4 changes: 2 additions & 2 deletions apps/wiki/services/history/history.query.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { queryOptions } from "@tanstack/react-query";
import { HistoryType } from "@/types";
import { HistoryListType } from "@/types";
import { getHistoryDetail, getHistoryList } from "./history.api";

export const historyQuery = {
list: <Title extends string>(title: Title) =>
queryOptions<{ versionDocsResponseDto: Array<HistoryType> }>({
queryOptions<HistoryListType>({
queryKey: ["query.historyList", title],
queryFn: () => getHistoryList(title),
}),
Expand Down
2 changes: 1 addition & 1 deletion apps/wiki/services/user/user.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const getMyInformation = async () => {
};

export const getUserById = async (id: number) => {
const { data } = await http.get(`/user/id/${id}`);
const { data } = await http.get(`/user/${id}`);
return data;
};

Expand Down
7 changes: 7 additions & 0 deletions apps/wiki/types/historyList.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { HistoryType } from ".";

export default interface HistoryListType {
versionDocsResponseDto: Array<HistoryType>;
docsType: string;
title: string;
}
1 change: 1 addition & 0 deletions apps/wiki/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export type { default as ModalState } from "./modal.interface";
export type { default as StyleVariantsType } from "./styleVariants.type";
export type { default as TradeType } from "./trade.interface";
export type { default as UserType } from "./user.interface";
export type { default as HistoryListType } from "./historyList.interface";
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"packages/*"
],
"scripts": {
"build": "turbo run build",
"build": "dotenv -- turbo run build",
"test": "turbo run test",
"dev": "dotenv -- turbo dev",
"lint": "turbo run lint",
Expand Down

0 comments on commit c0ef908

Please sign in to comment.