mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 07:55:25 +02:00
refactor!: Adapt api fetchers to upstream server
This commit is contained in:
parent
f854ab8a17
commit
17673852dd
@ -1,7 +1,7 @@
|
||||
import {AuthenticationDetails} from "~/server-types"
|
||||
import {ServerUser} from "~/server-types"
|
||||
import {client} from "~/constants/axios-client"
|
||||
|
||||
export default async function getMe(): Promise<AuthenticationDetails> {
|
||||
export default async function getMe(): Promise<ServerUser> {
|
||||
const {data} = await client.get(`${import.meta.env.VITE_SERVER_BASE_URL}/v1/account/me`, {
|
||||
withCredentials: true,
|
||||
})
|
||||
|
@ -1,14 +1,9 @@
|
||||
import {ServerUser} from "~/server-types"
|
||||
import {client} from "~/constants/axios-client"
|
||||
|
||||
export interface RefreshTokenResult {
|
||||
user: ServerUser
|
||||
detail: string
|
||||
}
|
||||
|
||||
export const REFRESH_TOKEN_URL = `${import.meta.env.VITE_SERVER_BASE_URL}/v1/auth/refresh`
|
||||
|
||||
export default async function refreshToken(): Promise<RefreshTokenResult> {
|
||||
export default async function refreshToken(): Promise<ServerUser> {
|
||||
const {data} = await client.post(
|
||||
REFRESH_TOKEN_URL,
|
||||
{},
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {AuthenticationDetails, Language} from "~/server-types"
|
||||
import {Language, ServerUser} from "~/server-types"
|
||||
import {client} from "~/constants/axios-client"
|
||||
import parseUser from "~/apis/helpers/parse-user"
|
||||
|
||||
@ -9,9 +9,7 @@ export interface UpdateAccountData {
|
||||
language?: Language
|
||||
}
|
||||
|
||||
export default async function updateAccount(
|
||||
updateData: UpdateAccountData,
|
||||
): Promise<AuthenticationDetails> {
|
||||
export default async function updateAccount(updateData: UpdateAccountData): Promise<ServerUser> {
|
||||
const {data} = await client.patch(
|
||||
`${import.meta.env.VITE_SERVER_BASE_URL}/v1/account`,
|
||||
updateData,
|
||||
@ -20,8 +18,5 @@ export default async function updateAccount(
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
...data,
|
||||
user: parseUser(data.user),
|
||||
}
|
||||
return parseUser(data.user)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {AuthenticationDetails} from "~/server-types"
|
||||
import {ServerUser} from "~/server-types"
|
||||
import {client} from "~/constants/axios-client"
|
||||
import parseUser from "~/apis/helpers/parse-user"
|
||||
|
||||
@ -7,10 +7,7 @@ export interface VerifyEmailData {
|
||||
token: string
|
||||
}
|
||||
|
||||
export default async function verifyEmail({
|
||||
email,
|
||||
token,
|
||||
}: VerifyEmailData): Promise<AuthenticationDetails> {
|
||||
export default async function verifyEmail({email, token}: VerifyEmailData): Promise<ServerUser> {
|
||||
const {data} = await client.post(
|
||||
`${import.meta.env.VITE_SERVER_BASE_URL}/v1/auth/verify-email`,
|
||||
{
|
||||
@ -22,8 +19,5 @@ export default async function verifyEmail({
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
...data,
|
||||
user: parseUser(data.user),
|
||||
}
|
||||
return parseUser(data.user)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {AuthenticationDetails} from "~/server-types"
|
||||
import {ServerUser} from "~/server-types"
|
||||
import {client} from "~/constants/axios-client"
|
||||
import parseUser from "~/apis/helpers/parse-user"
|
||||
|
||||
@ -12,7 +12,7 @@ export default async function verifyLoginWithEmail({
|
||||
email,
|
||||
token,
|
||||
sameRequestToken,
|
||||
}: VerifyLoginWithEmailData): Promise<AuthenticationDetails> {
|
||||
}: VerifyLoginWithEmailData): Promise<ServerUser> {
|
||||
const {data} = await client.post(
|
||||
`${import.meta.env.VITE_SERVER_BASE_URL}/v1/auth/login/email-token/verify`,
|
||||
{
|
||||
@ -25,8 +25,5 @@ export default async function verifyLoginWithEmail({
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
...data,
|
||||
user: parseUser(data.user),
|
||||
}
|
||||
return parseUser(data.user)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user