.
This commit is contained in:
34
app/lib/api/client/auth.ts
Normal file
34
app/lib/api/client/auth.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import axios from "../http-client"
|
||||
import type { User } from "../types"
|
||||
|
||||
interface RegisterRequest {
|
||||
email: string
|
||||
username: string
|
||||
displayName?: string
|
||||
password: string
|
||||
}
|
||||
|
||||
interface LoginRequest {
|
||||
username: string
|
||||
password: string
|
||||
}
|
||||
|
||||
interface LoginResponse {
|
||||
user: User
|
||||
token: string
|
||||
}
|
||||
|
||||
export async function register(request: RegisterRequest) {
|
||||
await axios.post("/auth/register", request)
|
||||
}
|
||||
|
||||
export async function login(request: LoginRequest) {
|
||||
const response = await axios.post("/auth/login", request)
|
||||
|
||||
return response.data as LoginResponse
|
||||
}
|
||||
|
||||
export default {
|
||||
register,
|
||||
login,
|
||||
}
|
||||
24
app/lib/api/client/server.ts
Normal file
24
app/lib/api/client/server.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import axios from "../http-client"
|
||||
import type { Server } from "../types"
|
||||
|
||||
interface CreateServerRequest {
|
||||
name: string
|
||||
icon?: File
|
||||
}
|
||||
|
||||
export async function create(request: CreateServerRequest) {
|
||||
const response = await axios.postForm("/servers", request)
|
||||
|
||||
return response.data as Server
|
||||
}
|
||||
|
||||
export async function list() {
|
||||
const response = await axios.get("/servers")
|
||||
|
||||
return response.data as Server[]
|
||||
}
|
||||
|
||||
export default {
|
||||
create,
|
||||
list,
|
||||
}
|
||||
14
app/lib/api/client/test.ts
Normal file
14
app/lib/api/client/test.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import axios from "../http-client"
|
||||
import type { Uuid } from "../types"
|
||||
|
||||
export async function test(channel_id: Uuid, sdp: RTCSessionDescriptionInit) {
|
||||
const response = await axios.post(`/voice/${channel_id}/connect`, {
|
||||
sdp: sdp
|
||||
})
|
||||
|
||||
return response.data.sdp as RTCSessionDescriptionInit
|
||||
}
|
||||
|
||||
export default {
|
||||
test
|
||||
}
|
||||
19
app/lib/api/client/user.ts
Normal file
19
app/lib/api/client/user.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import axios from "../http-client"
|
||||
import type { RecipientChannel, User } from "../types"
|
||||
|
||||
export async function me() {
|
||||
const response = await axios.get("/users/@me")
|
||||
|
||||
return response.data as User
|
||||
}
|
||||
|
||||
export async function channels() {
|
||||
const response = await axios.get("/users/@me/channels")
|
||||
|
||||
return response.data as RecipientChannel[]
|
||||
}
|
||||
|
||||
export default {
|
||||
me,
|
||||
channels
|
||||
}
|
||||
Reference in New Issue
Block a user