README
Type-safe TypeScript client for the Portal DB API, generated from OpenAPI specification using openapi-typescript and openapi-fetch.
Installation
npm install @grovepath/portal-db-ts-sdk openapi-fetchUsage
Basic GET Request
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
Type Safety
All endpoints, parameters, and responses are fully typed based on the OpenAPI specification. TypeScript will provide autocomplete and catch errors at compile time.
Was this helpful?
