@exobase/client-builder
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.1 • Public • Published

@exobase/api

A library for creating clients that communicate with Exobase APIs

Usage

import apiMaker from '@exobase/api'
import * as t from './types'

export { ApiError, ApiResponse, Auth } from '@exobase/api'
export * from './types'


const createApi = (url: string) => {
  const endpoint = apiMaker(url)
  return {
    health: {
      ping: endpoint<{}, {
        message: 'pong'
      }>({
        module: 'health',
        function: 'ping'
      })
    },
    auth: {
      login: endpoint<{}, {
        user: t.User
        platforms: t.PlatformPreview[]
        platformId: string
        idToken: string
        exp: number
      }>({
        module: 'auth',
        function: 'login'
      })
    }
  }
}

const api = createApi('http://localhost:800')

await api.health.ping({})
const { error, data } = await api.auth.login({}, {
  token: 'abc=='
})

Readme

Keywords

none

Package Sidebar

Install

npm i @exobase/client-builder

Weekly Downloads

5

Version

1.0.0-alpha.1

License

MIT

Unpacked Size

10.3 kB

Total Files

5

Last publish

Collaborators

  • rayepps