first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
27
apps/web/modules/saas/shared/lib/api.ts
Normal file
27
apps/web/modules/saas/shared/lib/api.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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();
|
||||
},
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue