better-auth/apps/web/modules/saas/shared/lib/api.ts
 Илья Шалонин 8538ab969a first
2025-10-29 13:43:43 +05:00

27 lines
696 B
TypeScript

import { apiClient } from "@shared/lib/api-client";
import { useMutation } from "@tanstack/react-query";
import type { InferRequestType } from "hono";
export const signedUploadUrlMutationKey = ["signed-upload-url"];
export const useSignedUploadUrlMutation = () => {
return useMutation({
mutationKey: signedUploadUrlMutationKey,
mutationFn: async (
query: InferRequestType<
(typeof apiClient.uploads)["signed-upload-url"]["$post"]
>["query"],
) => {
const response = await apiClient.uploads["signed-upload-url"].$post(
{
query,
},
);
if (!response.ok) {
throw new Error("Failed to get signed upload url");
}
return response.json();
},
});
};