rest-api-kit
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -39,7 +39,7 @@ type MethodType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; | ||
}; | ||
type EndpointFix = Record<string, EndpointType<any, any>>; | ||
type EndpointBuilder = <U, V>(endpoint: EndpointType<U, V>) => EndpointType<U, V>; | ||
type BuildCallBackType = (builder: EndpointBuilder) => Record<string, EndpointType<any, any>>; | ||
type RestBaseReturnType = { | ||
createEndpoints: (callback: BuildCallBackType) => Record<string, () => QueryHookReturnType>; | ||
endpoints: any; | ||
createEndpoints: <T extends EndpointFix>(callback: (builder: EndpointBuilder) => T) => Record<`use${string & Capitalize<keyof T extends string ? keyof T : never>}`, () => QueryHookReturnType>; | ||
endpoints: EndpointFix; | ||
}; | ||
@@ -46,0 +46,0 @@ |
@@ -293,12 +293,14 @@ "use strict"; | ||
let endpoints = {}; | ||
const build = (endpoint) => { | ||
function build(endpoint) { | ||
return endpoint; | ||
}; | ||
const createCustomHooks = () => { | ||
} | ||
; | ||
function createCustomHooks(endpoints2) { | ||
const customHooks = {}; | ||
for (const [endpointName, { url, params }] of Object.entries(endpoints)) { | ||
for (const [endpointName, { url, params }] of Object.entries(endpoints2)) { | ||
customHooks[`use${capitalizeFirstLetter(endpointName)}`] = () => useRest(url, { ...params, endpointName: endpointName.toLowerCase() }, restBaseOptions); | ||
} | ||
return customHooks; | ||
}; | ||
} | ||
; | ||
const setEndpoints = (x) => { | ||
@@ -310,3 +312,3 @@ endpoints = x; | ||
setEndpoints(builtEndpoints); | ||
return { ...createCustomHooks() }; | ||
return { ...createCustomHooks(builtEndpoints) }; | ||
}; | ||
@@ -313,0 +315,0 @@ return { |
{ | ||
"name": "rest-api-kit", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.mjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26282
687