@attaradev/ditto-sdk
v0.2.0
Published
TypeScript client for the ditto ephemeral database copy service
Downloads
46
Maintainers
Readme
ditto JavaScript SDK
TypeScript client for provisioning ephemeral database copies from a running ditto host.
Install
npm install @attaradev/ditto-sdkFor development from a repository checkout:
npm install ./sdk/javascriptUsage
import { DittoClient } from "@attaradev/ditto-sdk";
const client = new DittoClient({
serverUrl: "http://ditto.internal:8080",
token: process.env.DITTO_TOKEN
});
const copy = await client.create({ ttlSeconds: 600 });
console.log(copy.connection_string);
await client.destroy(copy.id);Use withCopy when you want automatic cleanup:
import { DittoClient } from "@attaradev/ditto-sdk";
const client = new DittoClient({ serverUrl: "http://ditto.internal:8080" });
await client.withCopy(async (dsn) => {
console.log(dsn);
});Environment variables
DittoClient reads these variables by default:
DITTO_SERVER_URLDITTO_TOKEN(typically a bearer JWT in shared-host mode)DITTO_TTL
