.
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import axios from "../http-client";
|
||||
import { messageSchema, type ChannelId, type Uuid } from "../types";
|
||||
|
||||
export async function paginatedMessages(
|
||||
channelId: ChannelId,
|
||||
limit: number,
|
||||
before: ChannelId | undefined,
|
||||
) {
|
||||
export async function paginatedMessages(channelId: ChannelId, limit: number, before: ChannelId | undefined) {
|
||||
const response = await axios.get(`/channels/${channelId}/messages`, {
|
||||
params: {
|
||||
limit,
|
||||
@@ -13,16 +9,10 @@ export async function paginatedMessages(
|
||||
},
|
||||
});
|
||||
|
||||
return (response.data as any[]).map((value, _) =>
|
||||
messageSchema.parse(value),
|
||||
);
|
||||
return (response.data as any[]).map((value, _) => messageSchema.parse(value));
|
||||
}
|
||||
|
||||
export async function sendMessage(
|
||||
channelId: ChannelId,
|
||||
content: string,
|
||||
attachments?: Uuid[],
|
||||
) {
|
||||
export async function sendMessage(channelId: ChannelId, content: string, attachments?: Uuid[]) {
|
||||
const response = await axios.post(`/channels/${channelId}/messages`, {
|
||||
content,
|
||||
attachments,
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import axios from "../http-client";
|
||||
import type {
|
||||
ChannelId,
|
||||
ChannelType,
|
||||
Server,
|
||||
ServerChannel,
|
||||
ServerId,
|
||||
ServerInvite,
|
||||
} from "../types";
|
||||
import type { ChannelId, ChannelType, Server, ServerChannel, ServerId, ServerInvite } from "../types";
|
||||
|
||||
interface CreateServerRequest {
|
||||
name: string;
|
||||
@@ -48,27 +41,20 @@ export async function listChannels(serverId: ServerId) {
|
||||
return response.data as ServerChannel[];
|
||||
}
|
||||
|
||||
export async function createChannel(
|
||||
serverId: ServerId,
|
||||
request: CreateServerChannelRequest,
|
||||
) {
|
||||
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}`,
|
||||
);
|
||||
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}`,
|
||||
);
|
||||
const response = await axios.delete(`/servers/${serverId}/channels/${channelId}`);
|
||||
|
||||
return response.data as ServerChannel;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import axios from "../http-client";
|
||||
import type {
|
||||
FullUser,
|
||||
PartialUser,
|
||||
RecipientChannel,
|
||||
UserId,
|
||||
Uuid,
|
||||
} from "../types";
|
||||
import type { FullUser, PartialUser, RecipientChannel, UserId, Uuid } from "../types";
|
||||
|
||||
export async function me() {
|
||||
const response = await axios.get("/users/@me");
|
||||
|
||||
@@ -5,9 +5,7 @@ export type TypeToZod<T> = {
|
||||
? undefined extends T[K]
|
||||
? E extends object
|
||||
? z.ZodOptional<z.ZodArray<z.ZodObject<TypeToZod<E>>>>
|
||||
: z.ZodOptional<
|
||||
z.ZodArray<z.ZodType<Exclude<E, null | undefined>>>
|
||||
>
|
||||
: z.ZodOptional<z.ZodArray<z.ZodType<Exclude<E, null | undefined>>>>
|
||||
: E extends object
|
||||
? z.ZodArray<z.ZodObject<TypeToZod<E>>>
|
||||
: z.ZodArray<z.ZodType<Exclude<E, null | undefined>>>
|
||||
|
||||
Reference in New Issue
Block a user