26 lines
604 B
TypeScript
26 lines
604 B
TypeScript
// ----- createApi -----
|
|
|
|
export type ApiAction = {
|
|
url?: string | ((id?: unknown, data?: any) => string);
|
|
method?: "get" | "post" | "put" | "patch" | "delete";
|
|
body?: (data: any) => any;
|
|
sendRawPayload?: boolean;
|
|
invalidateKeys?: any[] | ((responseData: any, variables: any) => any[]);
|
|
};
|
|
|
|
export type CreateApiConfig = {
|
|
key: string | unknown[];
|
|
url: string;
|
|
actions?: Record<string, ApiAction>;
|
|
axiosInstance?: any;
|
|
fetcher?: any;
|
|
};
|
|
|
|
export function createApi(config: CreateApiConfig): {
|
|
key: unknown[];
|
|
listKey: unknown[];
|
|
useGet: any;
|
|
useItem: any;
|
|
useAction: any;
|
|
};
|