This commit is contained in:
2025-05-20 04:16:03 +03:00
parent 21a05dd202
commit 9531bff01a
88 changed files with 7797 additions and 2246 deletions

View File

@@ -1,15 +1,14 @@
import axios from "../http-client"
import type { Server } from "../types"
import type { ChannelId, ChannelType, Server, ServerChannel, ServerId, ServerInvite } from "../types"
interface CreateServerRequest {
name: string
icon?: File
iconId?: string
}
export async function create(request: CreateServerRequest) {
const response = await axios.postForm("/servers", request)
return response.data as Server
interface CreateServerChannelRequest {
name: string
type: ChannelType
}
export async function list() {
@@ -18,7 +17,69 @@ export async function list() {
return response.data as Server[]
}
export async function create(request: CreateServerRequest) {
const response = await axios.post("/servers", request)
return response.data as Server
}
export async function get(serverId: ServerId) {
const response = await axios.get(`/servers/${serverId}`)
return response.data as Server
}
export async function delet(serverId: ServerId) {
const response = await axios.delete(`/servers/${serverId}`)
return response.data as Server
}
export async function listChannels(serverId: ServerId) {
const response = await axios.get(`/servers/${serverId}/channels`)
return response.data as ServerChannel[]
}
export async function createChannel(serverId: ServerId, request: CreateServerChannelRequest) {
const response = await axios.post(`/servers/${serverId}/channels`, request)
return response.data as ServerChannel
}
export async function getChannel(serverId: ServerId, channelId: ChannelId) {
const response = await axios.get(`/servers/${serverId}/channels/${channelId}`)
return response.data as ServerChannel
}
export async function deleteChannel(serverId: ServerId, channelId: ChannelId) {
const response = await axios.delete(`/servers/${serverId}/channels/${channelId}`)
return response.data as ServerChannel
}
export async function createInvite(serverId: ServerId) {
const response = await axios.post(`/servers/${serverId}/invites`)
return response.data as ServerInvite
}
export async function getInvite(inviteCode: string) {
const response = await axios.get(`/invites/${inviteCode}`)
return response.data as Server
}
export default {
create,
list,
listChannels,
get,
delet,
createChannel,
getChannel,
deleteChannel,
createInvite,
getInvite
}