@stakekit/api-hooks
Advanced tools
Comparing version 0.0.76 to 0.0.77
@@ -8,8 +8,6 @@ export { ActionStatus, ActionTypes, BalanceTypes, DailyCumulativeStakeDtoStatus, DailyCumulativeStakeDtoType, EvmEIP1559GasArgsDtoType, EvmLegacyGasArgsDtoType, GasMode, GeolocationErrorTagsItem, GeolocationErrorType, KeyCategory, MasterBannedRegionDtoTagsItem, Networks, RequiredArgumentWithNetworkDtoNetwork, RewardClaiming, RewardSchedule, RewardTypes, Role, TeamCategory, TokenGetTokensNetwork, TransactionStatus, TransactionType, TronResourceType, UpdatePayoutAddressDtoNetwork, ValidatorStatusTypes, WebhookSubscriptionEventDtoEvent, YieldGetMyYieldsNetwork, YieldGetMyYieldsSortBy, YieldGetMyYieldsType, YieldProviders, YieldType, YieldYieldsNetwork, YieldYieldsRevenueOption, YieldYieldsSortBy, YieldYieldsType } from './chunk-6WGTFAQI.js'; | ||
var ApiClientProvider = ({ | ||
apiClient, | ||
children | ||
}) => { | ||
return /* @__PURE__ */ jsx(Context.Provider, { value: apiClient, children }); | ||
}; | ||
var useApiClient = () => { | ||
children, | ||
...apiClientProps | ||
}) => /* @__PURE__ */ jsx(Context.Provider, { value: apiClientProps, children }); | ||
var useApiClientProps = () => { | ||
const value = useContext(Context); | ||
@@ -23,5 +21,32 @@ if (!value) { | ||
// src/use-api-client.ts | ||
var defaultBaseURL = "https://api.stakek.it/"; | ||
var getUrl = ({ | ||
baseURL, | ||
path, | ||
params | ||
}) => { | ||
const url = new URL(baseURL); | ||
url.pathname = path; | ||
url.search = new URLSearchParams(params).toString(); | ||
return url.toString(); | ||
}; | ||
var useApi = () => { | ||
const apiClient = useApiClient(); | ||
return (config) => apiClient(config).then((response) => response.data); | ||
const { | ||
fetchInstance, | ||
apiKey, | ||
baseURL = defaultBaseURL | ||
} = useApiClientProps(); | ||
return ({ | ||
url, | ||
data, | ||
method, | ||
params, | ||
headers, | ||
signal | ||
}) => fetchInstance(getUrl({ baseURL, path: url, params }), { | ||
method, | ||
data, | ||
headers: { ...headers, "X-API-KEY": apiKey }, | ||
signal | ||
}); | ||
}; | ||
@@ -28,0 +53,0 @@ |
{ | ||
"name": "@stakekit/api-hooks", | ||
"description": "React hooks for StakeKit API", | ||
"version": "0.0.76", | ||
"version": "0.0.77", | ||
"type": "module", | ||
@@ -44,2 +44,3 @@ "types": "./dist/index.d.ts", | ||
"@faker-js/faker": "^8", | ||
"@tanstack/react-query": "^5", | ||
"msw": "^2", | ||
@@ -52,2 +53,5 @@ "react": ">=18" | ||
}, | ||
"@tanstack/react-query": { | ||
"optional": true | ||
}, | ||
"msw": { | ||
@@ -57,8 +61,5 @@ "optional": true | ||
}, | ||
"dependencies": { | ||
"@tanstack/react-query": "^5", | ||
"axios": ">=1.6" | ||
}, | ||
"devDependencies": { | ||
"@faker-js/faker": "^8", | ||
"@tanstack/react-query": "^5", | ||
"@types/react": "^18.2.67", | ||
@@ -65,0 +66,0 @@ "eslint": "^8.57.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
539712
4
6315
12
- Removed@tanstack/react-query@^5
- Removedaxios@>=1.6
- Removedasynckit@0.4.0(transitive)
- Removedaxios@1.7.9(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedform-data@4.0.1(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedproxy-from-env@1.1.0(transitive)