1.1.0 • Published 8 years ago

js-lib2 v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

Stackable Javascript Library

This is the Official Stackable API Javascript library for getting data from stacks.

Available and Support in both Browser and NodeJs.

Working examples are found in examples directory!

In browser jQuery is required.

Install

You can get it on npm

npm install stackable --save

Or bower, too.

bower install stackable --save

Include Stackable file in your project

<script src="dist/stackable.min.js"></script>

Usage

Make sure to create an account at http://www.stackable.space and setup your Stack and Containers.

To initialize

var stackable = new Stackable('YOUR-STACK-PUBLIC-KEY-HERE');

To list all containers

stackable.getContainers(function (error, result) {
    console.log(error, result);
});

To get single containers

stackable.getContainer('CONTAINER-ID-HERE', function (error, result) {
    console.log(error, result);
});

To get all items within single container

stackable.getContainerItems('CONTAINER-ID-HERE', function (error, result) {
    console.log(error, result);
});

To get all items within stack

stackable.getAllItems(function (error, result) {
    console.log(error, result);
});

To get single item

stackable.getItem('ITEM-ID-HERE', function (error, result) {
    console.log(error, result);
});

To create new item

  • First initialize, using PRIVATE KEY, (MAKE SURE YOU KEEP THIS KEY SAFE! MOSTLY ON SERVER SIDE)
var stackable = new Stackable('YOUR-STACK-PRIVATE-KEY-HERE');
var dataToPost = {
    name: 'John Doe',
    age: 29
};

stackable.createItem('CONTAINER-ID-HERE', dataToPost, function (error, result) {
    console.log(error, result);
});

To update an item

var dataToUpdate = {
    name: 'John Doe',
    age: 29
};

stackable.updateItem('ITEM-ID-HERE', dataToUpdate, function (error, result) {
    console.log(error, result);
});

To build (development)

Sources files are located in src directory

Run npm install to setup required libraries.

npm install

npm Scripts

  • npm test - Lint the library and tests, then run the unit tests
  • npm run lint - Lint the source and unit tests
  • npm run watch - Continuously run the unit tests as you make changes to the source and test files themselves
  • npm run test-browser - Build the library for use with the browser spec runner. Changes to the source will cause the runner to automatically refresh.
  • npm run build - Lint then build the library
  • npm run coverage - Generate a coverage report

Todo

  • Write tests.
  • Test with Nodejs App
  • Nodejs example