0.4.1 • Published 9 months ago
aw-client v0.4.1
aw-client-js
Client library for ActivityWatch in TypeScript/JavaScript.
Install
npm install aw-clientUsage
The library uses Promises for almost everything, so either use .then() or async/await syntax.
The example below is written with .then() to make it easy to run in the node REPL.
const { AWClient } = require('aw-client');
const client = new AWClient('test-client')
// Get server info
client.getInfo().then(console.log);
// List buckets
client.getBuckets().then(console.log);
// Create bucket
const bucketId = "test";
client.createBucket(bucketId, "bucket-type", "your-hostname");
// Send a heartbeat
const nowStr = (new Date()).toISOString();
const heartbeat = {timestamp: nowStr, duration: 0, data: { label: "just testing!" }};
client.heartbeat(bucketId, 5, heartbeat);Contribute
Setup your dev environment
npm installBuild the library
npm run compileRun the tests
npm test