Files
Minikura/apps/web/lib/api-helpers.ts

30 lines
768 B
TypeScript
Raw Normal View History

import { api } from "@/lib/api-client";
2026-02-13 15:52:13 +07:00
type ReverseProxyApi = {
get: () => Promise<{ data?: unknown }>;
(params: {
id: string;
}): {
2026-02-13 15:52:13 +07:00
delete: () => Promise<{ data?: unknown; error?: unknown }>;
"connection-info": { get: () => Promise<{ data?: unknown }> };
};
};
type UserSuspensionApi = {
suspension: {
patch: (body: {
isSuspended: boolean;
suspendedUntil: string | null;
}) => Promise<{ error?: unknown }>;
2026-02-13 15:52:13 +07:00
};
};
export const getReverseProxyApi = (): ReverseProxyApi => {
const apiRoot = api.api as unknown as { "reverse-proxy": ReverseProxyApi };
return apiRoot["reverse-proxy"];
};
export const getUserApi = (id: string): UserSuspensionApi => {
return api.api.users({ id }) as unknown as UserSuspensionApi;
};