Skip to content

Commit

Permalink
Merge pull request #160 from Make-A-Wish-Sopt/feature/159-API
Browse files Browse the repository at this point in the history
Feature/159 api
  • Loading branch information
myeongheonhong authored Dec 21, 2023
2 parents 98f9236 + 4762515 commit 955b3cc
Show file tree
Hide file tree
Showing 94 changed files with 1,534 additions and 1,450 deletions.
17 changes: 17 additions & 0 deletions api/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { API_VERSION_01, PATH_AUTH } from './path';
import { client } from './common/axios';

export const postAuthKakao = async (code: string) => {
const data = await client.post(
`${API_VERSION_01}${PATH_AUTH.KAKAO}?redirectUri=${process.env.NEXT_PUBLIC_KAKAO_REDIRECT_URI}`,
{},
{
headers: {
'Content-Type': 'application/json',
code: `${code}`,
},
},
);

return data.data.data;
};
35 changes: 35 additions & 0 deletions api/cakes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { getAccessToken } from '@/utils/common/token';
import { client } from './common/axios';
import { API_VERSION_01, PATH_CAKES } from './path';

const ACCESS_TOKEN = getAccessToken();

/**
* 해당 소원에 대한 케이크 조회
*/
export const getCakesInfo = async (
wishId: string | string[] | undefined,
cakeId: string | string[] | undefined,
) => {
const data = await client.get(`${API_VERSION_01}${PATH_CAKES.GET_CAKES_INFO(wishId, cakeId)}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
});

return data.data.data;
};

/**
* 해당 소원에 대한 모든 케이크 리스트 결과 조회
*/
export const getCakesResult = async (wishId: string | string[] | undefined) => {
const data = await client.get(`${API_VERSION_01}${PATH_CAKES.GET_CAKES_RESULT(wishId)}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${ACCESS_TOKEN}`,
},
});
return data.data.data;
};
53 changes: 0 additions & 53 deletions api/cakes/cakesAPI.ts

This file was deleted.

1 change: 0 additions & 1 deletion api/common/axios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PATH from '@/constant/path';
import axios from 'axios';

//서버통신 함수
Expand Down
25 changes: 25 additions & 0 deletions api/file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import axios from 'axios';
import { client } from './common/axios';
import { API_VERSION_01 } from './path';
import { getAccessToken } from '@/utils/common/token';

export const uploadPresignedURL = async (signedURL: string, file: File | Blob | null) => {
const data = await axios.put(signedURL, file, {
headers: {
'Content-Type': file?.type,
},
});

return data;
};

export const getPresignedURL = async (fileName: string | undefined) => {
const data = await client.get(`${API_VERSION_01}/file?fileName=${fileName}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${getAccessToken()}`,
},
});

return data;
};
20 changes: 0 additions & 20 deletions api/letters/getCakeLetters.ts

This file was deleted.

16 changes: 0 additions & 16 deletions api/letters/getCakesCount.ts

This file was deleted.

20 changes: 0 additions & 20 deletions api/links/deleteWishLinks.ts

This file was deleted.

17 changes: 0 additions & 17 deletions api/links/getOneWish.ts

This file was deleted.

17 changes: 0 additions & 17 deletions api/links/getWishLinks.ts

This file was deleted.

19 changes: 0 additions & 19 deletions api/login/sendCodeToServer.ts

This file was deleted.

17 changes: 0 additions & 17 deletions api/main/getProgressData.ts

This file was deleted.

45 changes: 0 additions & 45 deletions api/mypage/mypageAPI.ts

This file was deleted.

41 changes: 41 additions & 0 deletions api/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export const API_VERSION_01 = '/api/v1';

const PATH = {
auth: '/auth',
user: '/user',
wishes: '/wishes',
public: '/public',
cakes: '/cakes',
};

export const PATH_AUTH = {
TOKEN: `${PATH.auth}/token`,
KAKAO: `${PATH.auth}/kakao/callback`,
};

export const PATH_USER = {
DEFAULT: PATH.user,
ACCOUNT: `${PATH.user}/account`,
ACCOUNT_VERIFY: `${PATH.user}/verify-account`,
ABUSE: `${PATH.user}/abuse`,
};

export const PATH_WISHES = {
DEFAULT: PATH.wishes,
PROGRESS: `${PATH.wishes}/progress`,
GET_SINGLE_WISH_INFO: (wishId: string | string[] | undefined) => `${PATH.wishes}/${wishId}`,
PRESENT_LINK_INFO: `${PATH.wishes}/present/info`,
MAIN: `${PATH.wishes}/main`,
};

export const PATH_PUBLIC = {
CAKES: `${PATH.public}/cakes`,
GET_WISHES_INFO: (wishId: string | string[] | undefined) =>
`${PATH.public}${PATH.wishes}/${wishId}`,
};

export const PATH_CAKES = {
GET_CAKES_RESULT: (wishId: string | string[] | undefined) => `${PATH.cakes}/${wishId}`,
GET_CAKES_INFO: (wishId: string | string[] | undefined, cakeId: string | string[] | undefined) =>
`${PATH.cakes}/${wishId}/${cakeId}`,
};
11 changes: 11 additions & 0 deletions api/public.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { PublicWishesDataResponseType } from '@/types/api/response';
import { client } from './common/axios';
import { API_VERSION_01, PATH_PUBLIC } from './path';

export const getPublicWishes = async (wishId: string | string[] | undefined) => {
const data = await client.get<PublicWishesDataResponseType>(
`${API_VERSION_01}${PATH_PUBLIC.GET_WISHES_INFO(wishId)}`,
);

return data.data.data;
};
Loading

0 comments on commit 955b3cc

Please sign in to comment.