@xcitedbs/client
v0.2.9
Published
XCiteDB BaaS client SDK
Maintainers
Readme
@xcitedbs/client
TypeScript/JavaScript client for the XCiteDB BaaS HTTP API and WebSocket notifications.
Install
From npm:
npm install @xcitedbs/clientFrom this repo:
cd sdks/javascript && npm install && npm run buildLink or npm pack / publish as needed.
Usage
import { XCiteDBClient } from '@xcitedbs/client';
const client = new XCiteDBClient({
baseUrl: 'http://localhost:8080',
apiKey: process.env.XCITEDB_API_KEY,
context: { branch: '', date: '' },
});
await client.health();
const docs = await client.queryByIdentifier('/test1', 'FirstMatch');
await client.put('app.settings', { theme: 'dark' });WebSocket
client.subscribe(
{ pattern: '/us/bills/*', event_type: '*' },
(ev) => console.log(ev)
);With JWT in browsers, tokens are passed as access_token query parameter on the WebSocket URL. API keys can use api_key query parameter.
Build
npm run buildOutputs dist/ (CommonJS + .d.ts).
