0.0.3 • Published 2 months ago

jsonkv-client v0.0.3

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 months ago

jsonkv-client

A simple client for jsonkv-server. It was specifically created for use in some broadcasts.

https://www.npmjs.com/package/jsonkv-client

Usage

$ pnpm i jsonkv-client
import { JsonKvClient, JsonKvListener } from 'jsonkv-client';

const client = new JsonKvClient('baseUrl', 'secret');

const getOp = await client.get('key');
const postOp = await client.post('key', 'value');
const putOp = await client.put('key', 'value');
// uses rfc6902, JSON patch.
// https://tools.ietf.org/html/rfc6902
const patchOp = await client.patch('key', [
  {op: 'replace', path: '/0/age', value: 21},
  {op: 'add', path: '/-', value: {first: 'Raphael', age: 37}},
]);

const listener = client.bulk_listen((l) => {
  l.listen("overall", () => console.log("overall updated", overall));
});

setTimeout(() => {
  console.log("overall yay", listener.get("overall"));
}, 5000);

TODO

  • Add tests
  • Add UI dashboard

License

Apache-2.0

0.0.3

2 months ago

0.0.2

2 months ago

0.0.1

2 months ago