README

Type-safe TypeScript client for the Portal DB API, generated from OpenAPI specification using openapi-typescript and openapi-fetch.

Installation

Install (npm)
npm install @grovepath/portal-db-ts-sdk openapi-fetch

Usage

Basic GET Request

basic-get.ts
import createClient from 'openapi-fetch';
import type { paths } from '@grovepath/portal-db-ts-sdk';

const client = createClient<paths>({
  baseUrl: 'http://localhost:3000',
  headers: {
    'Authorization': `Bearer ${JWT_TOKEN}`,
  },
});

// Fetch all services
const { data, error } = await client.GET('/services');

if (error) {
  console.error('Error:', error);
} else {
  console.log('Services:', data);
}

Query with Filters

React with @tanstack/react-query

For React applications, you can use openapi-react-query for a type-safe wrapper around React Query:

Documentation

  • openapi-fetch: https://openapi-ts.dev/openapi-fetch/

  • openapi-react-query: https://openapi-ts.dev/openapi-react-query/

  • PostgREST API Reference: https://postgrest.org/en/stable/references/api/tables_views.html

Was this helpful?