1.0.2-alpha • Published 4 years ago

counter-culture.client v1.0.2-alpha

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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_ENVServiceLocation
developmentcounter-culture.apihttp://counter-culture:4000
developmentcounter-culture.securehttp://counter-culture:5000
productioncounter-culture.apihttps://api.counter-culture.io
productioncounter-culture.securehttps://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.

MethodDescription
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