Files
sdk/examples/node/main.ts
menonsamir 7b655623c0 Fix Node example (#15)
* 0.1.7

* update examples (fix #14)

* Fix build

* Add crypto to bloom tests
2023-03-14 20:59:41 -07:00

34 lines
874 B
TypeScript

import type { Client } from '@blyss/sdk';
const blyss = require('@blyss/sdk/node');
process.removeAllListeners('warning');
async function main() {
const client: Client = new blyss.Client('<YOUR API KEY HERE>');
// Create the bucket
const bucketName = 'state-capitals';
if (!(await client.exists(bucketName))) {
console.log('creating...');
await client.create(bucketName, true, {
keyStoragePolicy: 'none'
});
}
// Connect to your bucket
const bucket = await client.connect(bucketName);
// Write some data to it
await bucket.write({
Ohio: 'Columbus',
California: 'Sacramento',
Washington: 'Olympia'
});
// This is a completely *private* query:
// the server *cannot* learn that you looked up "California"!
const capital = await bucket.privateRead('California');
console.log(`Got capital: ${capital}`);
}
main();