Files
sdk/e2e-tests/tests/simple.ts
Neil Movva 9604fd30e1 [BLY-66] direct upload pparams (#28)
* bucket check and async setup
clients perform direct setup by default

* (python) more consistent json for internal api

all requests and response are JSON.
all binary payloads are explicitly encoded as base64
within api.py, and decoded back to bytes before leaving api.py.
User-facing code, e.g. bucket.py and bucket_service.py,
should not see base64 wrangling.

* Support async for all ops

refactor api.py to be async-first
use new asyncio loops to support non-async interface;
cannot call non-async methods from async context

* [js] update client to work with unified service
bump both versions to 0.2.1
disable npm/pypi publish except on manual workflow run

* disable request compression

* fix workflow tests

update standalone Spiral test server to use new JSON interface
2023-09-11 16:55:35 -07:00

29 lines
842 B
TypeScript

import type { Bucket } from '@blyss/sdk';
const blyss = require('@blyss/sdk/node');
export default async function main(port: string) {
const bucket: Bucket = await blyss.Bucket.initializeLocal(
'http://localhost:' + port
);
console.log(bucket.metadata);
// buckets are bytes-in/bytes-out. SDK write() will automatically serialize as UTF-8.
await bucket.write({
Ohio: 'Columbus',
California: 'Sacramento'
});
// but reads are always bytes-out, and must be decoded.
let capital = new TextDecoder().decode(await bucket.privateRead('Ohio'));
if (capital !== 'Columbus') {
throw 'Incorrect result.';
}
// capital = await bucket.privateRead('California');
capital = new TextDecoder().decode(await bucket.privateRead('California'));
if (capital !== 'Sacramento') {
throw 'Incorrect result.';
}
}