Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ActivityWatch/aw-client-js
Client library for ActivityWatch in JavaScript
https://github.com/ActivityWatch/aw-client-js
activitywatch javascript nodejs typescript
Last synced: 3 months ago
JSON representation
Client library for ActivityWatch in JavaScript
- Host: GitHub
- URL: https://github.com/ActivityWatch/aw-client-js
- Owner: ActivityWatch
- License: mit
- Created: 2016-04-28T06:33:51.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-31T12:35:19.000Z (about 1 year ago)
- Last Synced: 2024-03-22T13:18:09.168Z (11 months ago)
- Topics: activitywatch, javascript, nodejs, typescript
- Language: TypeScript
- Size: 340 KB
- Stars: 28
- Watchers: 5
- Forks: 16
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-activitywatch - aw-client-js
README
# aw-client-js
Client library for [ActivityWatch](http://activitywatch.net) in TypeScript/JavaScript.
[![Build Status](https://github.com/ActivityWatch/aw-client-js/workflows/Build/badge.svg)](https://github.com/ActivityWatch/aw-client-js/actions)
[![npm](https://img.shields.io/npm/v/aw-client)](https://www.npmjs.com/package/aw-client)
[![Known Vulnerabilities](https://snyk.io/test/github/ActivityWatch/aw-client-js/badge.svg)](https://snyk.io/test/github/ActivityWatch/aw-client-js)## Install
```sh
npm install aw-client
```## Usage
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.
```javascript
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
```sh
npm install
```### Build the library
```sh
npm run compile
```### Run the tests
```sh
npm test
```