@creek/sync-lib
Node.js library for the Creek Sync API
Last updated 2 years ago by creek-dev .
Repository · Original npm · Tarball · package.json
$ cnpm install @creek/sync-lib 
SYNC missed versions from official npm registry.

Creek Sync API

Node.js API for Creek's Sync capabilities.

⚠ This README is a working draft for the future client. Please do not expect any of the following to work yet ⚠

Install

$ npm install @creek/sync-lib

Usage

Require and create a new instance of the client:

// Import the library
const Sync = require('@creek/sync-lib);

// Read settings from the filesystem
const settings = Sync.helpers.settings.get();

// Create a Sync instance
const sync = new Sync(settings);

// Receive updates on status changes summarising the client activity
// Should contain all information required for providing a user interface.
sync.on('status', () => {

});

// Start up
sync.start()

Events

An instance of Sync provides an EventEmitter interface to catch the following events:

  • next-sync-time
  • debug
  • upload-running
  • upload-finished

Settings helper

Read settings:

const settings = Sync.helpers.settings.get()

Save settings:

Sync.helpers.settings.save(settings)

Recordings helper

List local recordings:

const localRecordings = await Sync.helpers.recordings.listLocalRecordings();

Retrieve missing recordings list:

const domain = 'beepboop.creek.fm';
const missingRecordings = await Sync.helpers.recordings.listMissingRecordings(domain);

Match missing recordings:

const matchedRecordings = Sync.helpers.recordings.matchMissingRecordings(localRecordings, missingRecordings);

S3 helper

Retrieve S3 Credentials:

const credentials = await Sync.helpers.s3.getCredentials();

Upload a file with progress reports:

const upload = Sync.helpers.s3.transferFile(credentials, {
    full_path: path.resolve(__dirname, 'track.mp3'),
    s3_object_name: '/my-track.mp3'
});

upload.onProgress(console.log);

await upload;

console.log('uploaded')

Testing

The test suite can be run by executing npm test, the output is in TAP which can then be piped into your favorite report generator. To quickly run with a human readable output the following is suggested.

$ npm install --global tap-spec

# Ensure you've downloaded the test recordings (only needs to be done once)
$ npm run download-recordings

$ npm test | tap-spec

Coverage

In an attempt to remove dead code and ensure all code is passed through on the tests you can visualise the current code coverage by running the following.

$ npm run coverage

Afterwhich a HTML report will be generated at coverage/index.html.

Code Style

This projects adopts the xo style guide with spaces. The linting tool can be run with the following.

$ npm run lint

Current Tags

  • 0.0.4                                ...           latest (2 years ago)

4 Versions

  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 0
Dependencies (11)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |