Skip to content

risevest/rise-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rise API client

This package contains an api client for Risevest. The contract is generated from an OpenAPI file, and then a client is built around this contract.

It uses typebox to generate the contract from an OpenAPI file, and also react-query

Installation

npm install @risemaxi/api-client --save

OR

yarn add @risemaxi/api-client
OR
bun install @risemaxi/api-client

Usage

This lib also ships with a cli rise-api, so you can use it to generate the contract at will, just run:

bunx rise-api generate <input-file>

The input file can be a local file or a url pointing to a file. For example

bunx rise-api generate ./swagger.yaml

Example

import { createRiseApiClient, createRiseApiHooks } from '@risemaxi/api-client'

const apiClient = createRiseApiClient(async (method, url, params) => {
  const data = await fetch(url)
  const res = await data.json()
  return data
} , 'api.com' false)

const apiHooks = createRiseApiHooks(riseApi);
...

// Then later use the client like so:
apiClient.get('/plans', {
    query: {},
})
apiClient.post('/plans', {
    body: { id: "some-uuid" },
})

// Or use the hooks like so:
const { data } = apiHooks.useGet('/plans', {
    query: {},
})

Parameters

Name Type Default
fetcher Function
baseUrl String Optional ""
enableParsing Boolean Optional true

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •