counter-culture.client

client library for counter-culture.io

Usage no npm install needed!

<script type="module">
  import counterCultureClient from 'https://cdn.skypack.dev/counter-culture.client';
</script>

README

counter-culture.client

A client library for counter-culture.io.


Build Status Coverage Status GitHub tag (latest SemVer) license

NPM

Getting Started

counter-culture.client is a proxy to the gateway and the token server. It was designed to facilitate the development of OAuth 2.0 clients such as counter-culture.app and counter-culture.dev.

Prerequisites

To obtain an access_token, developers should first register an app and then send an authorization request.

Environment Modes

If you are in development mode, be sure to start counter-culture.api and counter-culture.secure on ports 4000 and 5000, respectively.

NODE_ENV Service Location
development counter-culture.api http://counter-culture:4000
development counter-culture.secure http://counter-culture:5000
production counter-culture.api https://api.counter-culture.io
production counter-culture.secure https://secure.counter-culture.io

Installation

$  npm install counter-culture.client

Tests

# unit tests
$ npm run test

# end-to-end tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

# acceptance tests
$ npm run test:spec

Usage

import { CounterCulture } from 'counter-culture.client';

const client = new CounterCulture('{access_token}');

client.GetUser().then(user => ... );

Alternatively, you may instantiate the client using the connect method:

const client = CounterCulture.connect("{access_token}");

Note that the client instance returned from connect may also be accessed via the CounterCulture.client property. In other words, the first code snippet is equivalent to:

CounterCulture.connect("{access_token}");
CounterCulture.client.GetUser().then(user => ... );

Methods

All methods return a promise.

Method Description
client.GetUser() get user info
client.GetCounter(id) get counter by id
client.GetCounters(cursor) get list of counters
client.GetCountersById(cursor) get counters as a dictionary
client.PostCounter(counter) add a new counter
client.PutCounter(id, counter) update a counter
client.PatchCounter(id, jsonPatch[]) modify a counter
client.DeleteCounter(id) remove a counter

License

MIT


Most people are fools, most authority is malignant, God does not exist, and everything is wrong. ~ Ted Nelson