-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from DEPthes/dev
Dev
- Loading branch information
Showing
55 changed files
with
1,898 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
type CheckAuthNumberResponse = { | ||
check: boolean; | ||
information: { | ||
message: string; | ||
}; | ||
}; | ||
|
||
export async function deleteAuthNumber({ authNumber }: { authNumber: string }) { | ||
const url = '/verify/check/' + authNumber; | ||
return await ieumAxios.delete<CheckAuthNumberResponse>(url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { authToken } from '@/class/authToken'; | ||
import ieumAxios from './ieumAxios'; | ||
|
||
export function deleteUser() { | ||
return ieumAxios.delete('/api/user/leave', { | ||
headers: { | ||
Authorization: `Bearer ${authToken.getToken()}`, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
export type EmailCheckResponse = { | ||
check: boolean; | ||
information: { | ||
available: boolean; | ||
}; | ||
}; | ||
|
||
export async function getEmailDuplicated(email: string) { | ||
const url = '/auth/email/' + email; | ||
return await ieumAxios.get<EmailCheckResponse>(url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
export type NicknameResponse = { | ||
check: boolean; | ||
information: { | ||
nickname: string[]; | ||
}; | ||
}; | ||
|
||
export async function getNickname() { | ||
return await ieumAxios.get<NicknameResponse>('/auth/nickname'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
export type NicknameDuplicatedResponse = { | ||
check: boolean; | ||
information: { | ||
available: boolean; | ||
}; | ||
}; | ||
|
||
export async function getNicknameDuplicated(nickname: string) { | ||
const url = '/auth/nickname/' + nickname; | ||
return await ieumAxios.get<NicknameDuplicatedResponse>(url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
type TempsResponse = { | ||
check: boolean; | ||
information: { | ||
id: number; | ||
title: string; | ||
contents: string; | ||
envelopType: number; | ||
letterType: string; | ||
senderId: number; | ||
receiverId: number | null; | ||
read: boolean; | ||
}; | ||
}; | ||
|
||
export async function getTemp(letterId: number, accessToken: string | null) { | ||
return await ieumAxios.get<TempsResponse>(`/api/letter/temp/${letterId}`, { | ||
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
type TempsResponse = { | ||
check: boolean; | ||
information: { | ||
letterId: number; | ||
title: string; | ||
modifiedAt: string; | ||
}[]; | ||
}; | ||
|
||
export async function getTemps(accessToken: string | null) { | ||
return await ieumAxios.get<TempsResponse>('/api/letter/temp-new', { | ||
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
type TempsResponse = { | ||
check: boolean; | ||
information: { | ||
letterId: number; | ||
title: string; | ||
modifiedAt: string; | ||
}[]; | ||
}; | ||
|
||
export async function getTempsReply(accessToken: string | null) { | ||
return await ieumAxios.get<TempsResponse>('/api/letter/temp-reply', { | ||
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import axios from 'axios'; | ||
import ieumAxios from './ieumAxios'; | ||
|
||
type UserResponse = { | ||
id: string; | ||
nickname: string; | ||
check: boolean; | ||
information: { | ||
id: number; | ||
}; | ||
}; | ||
|
||
export async function getUser(accessToken: string) { | ||
return axios.get<UserResponse>('/api/user'); | ||
return ieumAxios.get<UserResponse>('/api/user/verify', { | ||
headers: { Authorization: `Bearer ${accessToken}` }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
export function logout() { | ||
return ieumAxios.post('/auth/sign-out'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import ieumAxios from './ieumAxios'; | ||
import { authToken } from '@/class/authToken'; | ||
import { IeumError } from '@/class/ieumError'; | ||
import { AxiosError } from 'axios'; | ||
|
||
type CheckResponse = { | ||
check: boolean; | ||
information: { | ||
prohibition: number; | ||
}; | ||
}; | ||
|
||
export async function postCheck({ title, contents }: { title: string; contents: string }) { | ||
const accessToken = authToken.getToken(); | ||
const response = await ieumAxios.post<CheckResponse>( | ||
'/api/letter/check-gpt', | ||
{ | ||
title, | ||
contents, | ||
}, | ||
{ | ||
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` }, | ||
}, | ||
); | ||
if (response.data.information.prohibition === 1) { | ||
throw new IeumError(400) as AxiosError; | ||
} | ||
return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import ieumAxios from './ieumAxios'; | ||
import { authToken } from '@/class/authToken'; | ||
import { IeumError } from '@/class/ieumError'; | ||
import { AxiosError } from 'axios'; | ||
|
||
type SendResponse = { | ||
check: boolean; | ||
information: { | ||
id: number; | ||
title: string; | ||
contents: string; | ||
envelopType: number; | ||
letterType: string; | ||
senderId: number; | ||
receiverId: number | null; | ||
read: boolean; | ||
}; | ||
}; | ||
|
||
export async function postSend({ | ||
title, | ||
contents, | ||
envelopType, | ||
originalLetterId, | ||
letterType, | ||
letterId, | ||
}: { | ||
title: string; | ||
contents: string; | ||
envelopType: number; | ||
originalLetterId: number | null; | ||
letterType: string | undefined; | ||
letterId: number | undefined; | ||
}) { | ||
const accessToken = authToken.getToken(); | ||
const response = await ieumAxios.post<SendResponse>( | ||
'/api/letter/send', | ||
{ | ||
title, | ||
contents, | ||
envelopType, | ||
originalLetterId, | ||
letterType, | ||
letterId, | ||
}, | ||
{ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` } }, | ||
); | ||
if (response.data.check === false) { | ||
throw new IeumError(500) as AxiosError; | ||
} else return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
type SendAuthNumberResponse = { | ||
check: boolean; | ||
information: { | ||
message: string; | ||
}; | ||
}; | ||
|
||
export async function postSendAuthNumber({ email }: { email: string }) { | ||
return await ieumAxios.post<SendAuthNumberResponse>('/verify/send', { | ||
email, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import ieumAxios from './ieumAxios'; | ||
import { authToken } from '@/class/authToken'; | ||
import { IeumError } from '@/class/ieumError'; | ||
import { AxiosError } from 'axios'; | ||
|
||
type GptResponse = { | ||
check: boolean; | ||
information: { | ||
message: string; | ||
}; | ||
}; | ||
|
||
export async function postSendGpt({ | ||
title, | ||
contents, | ||
envelopType, | ||
}: { | ||
title: string; | ||
contents: string; | ||
envelopType: number; | ||
}) { | ||
const accessToken = authToken.getToken(); | ||
const response = await ieumAxios.post<GptResponse>( | ||
'/api/letter/send-gpt', | ||
{ | ||
title, | ||
contents, | ||
envelopType, | ||
}, | ||
{ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` } }, | ||
); | ||
if (response.data.check === false) { | ||
throw new IeumError(500) as AxiosError; | ||
} else return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import ieumAxios from './ieumAxios'; | ||
import { authToken } from '@/class/authToken'; | ||
import { IeumError } from '@/class/ieumError'; | ||
import { AxiosError } from 'axios'; | ||
|
||
type GptResponse = { | ||
check: boolean; | ||
information: { | ||
message: string; | ||
}; | ||
}; | ||
|
||
export async function postSendGptReply({ | ||
title, | ||
contents, | ||
envelopType, | ||
}: { | ||
title: string; | ||
contents: string; | ||
envelopType: number; | ||
}) { | ||
const accessToken = authToken.getToken(); | ||
const response = await ieumAxios.post<GptResponse>( | ||
'/api/letter/reply-gpt', | ||
{ | ||
title, | ||
contents, | ||
envelopType, | ||
}, | ||
{ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` } }, | ||
); | ||
if (response.data.check === false) { | ||
throw new IeumError(500) as AxiosError; | ||
} else return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
type SignUpResponse = { | ||
check: boolean; | ||
information: { | ||
accessToken: string; | ||
refreshToken: string; | ||
}; | ||
}; | ||
|
||
export async function postSignUp({ nickname, email, password }: { nickname: string; email: string; password: string }) { | ||
return await ieumAxios.post<SignUpResponse>('/auth/sign-up', { | ||
nickname, | ||
email, | ||
password, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ieumAxios from './ieumAxios'; | ||
import { authToken } from '@/class/authToken'; | ||
import { IeumError } from '@/class/ieumError'; | ||
import { AxiosError } from 'axios'; | ||
|
||
type TempResponse = { | ||
check: boolean; | ||
information: { | ||
id: number; | ||
title: string; | ||
contents: string; | ||
envelopType: number; | ||
letterType: string; | ||
senderId: number; | ||
receiverId: number | null; | ||
read: boolean; | ||
}; | ||
}; | ||
|
||
export async function postTemp({ | ||
originalLetterId, | ||
title, | ||
contents, | ||
}: { | ||
originalLetterId: number | null; | ||
title: string; | ||
contents: string; | ||
}) { | ||
const accessToken = authToken.getToken(); | ||
const response = await ieumAxios.post<TempResponse>( | ||
'/api/letter/temp', | ||
{ originalLetterId, title, contents }, | ||
{ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${accessToken}` } }, | ||
); | ||
if (response.data.check === false) { | ||
throw new IeumError(500) as AxiosError; | ||
} else return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import ieumAxios from './ieumAxios'; | ||
|
||
// refresh 토큰으로 accessToken 재발급 | ||
export async function getAccessToken() { | ||
export async function refreshAccessToken() { | ||
return ieumAxios.get<{ accessToken: string }>('/api/refresh'); | ||
} |
Oops, something went wrong.