[+] /user/me sdk

pull/14/head
Azalea 2024-02-21 14:14:28 -05:00
parent ff7873313b
commit a2eeac786e
2 changed files with 27 additions and 0 deletions

View File

@ -2,4 +2,25 @@ export interface TrendEntry {
date: string
rating: number
plays: number
}
export interface Card {
luid: string
registerTime: string
accessTime: string
}
export interface UserMe {
username: string
email: string
displayName: string
country: string
lastLogin: number
regTime: number
profileLocation: string
profileBio: string
emailConfirmed: boolean
ghostCard: Card
cards: Card[]
computedName: string
}

View File

@ -1,4 +1,5 @@
import { AQUA_HOST } from "./config";
import type { UserMe } from "./generalTypes";
interface RequestInitWithParams extends RequestInit {
params?: { [index: string]: string }
@ -75,9 +76,14 @@ async function confirmEmail(token: string) {
return await post('/api/v2/user/confirm-email', { token })
}
async function me(): Promise<UserMe> {
return await post('/api/v2/user/me', {})
}
export const USER = {
register,
login,
confirmEmail,
me,
isLoggedIn: () => !!localStorage.getItem('token')
}