REST Adapter

Maps @vibecode-db/client queries to standard REST endpoint conventions. No peer dependencies required.

Setup

import { createClient } from '@vibecode-db/client';
import { RestAdapter } from '@vibecode-db/client/adapters/rest';

const adapter = new RestAdapter({
  baseUrl: 'https://api.example.com',
  headers: {
    Authorization: 'Bearer your-token',
  },
});

const client = createClient('', '', { adapter });

Endpoint mapping

OperationHTTP MethodURL
select('*')GET/table?filters
insert(data)POST/table
update(data).eq('id', x)PATCH/table/x
delete().eq('id', x)DELETE/table/x
upsert(data)PUT/table
rpc('fn', args)POST/rpc/fn

Options

OptionTypeDescription
baseUrlstringBase URL for the REST API
headersRecord<string, string>Default headers for all requests
fetchtypeof fetchCustom fetch function (defaults to global)

Custom fetch

const adapter = new RestAdapter({
  baseUrl: 'https://api.example.com',
  fetch: myCustomFetch,
});