node package manager


Everlive SDK for Node.js

Everlive JavaScript SDK

The Everlive JavaScript SDK is intended to run in any Javascript environment. It is packaged with browserify for all environments except for Node.js where the code from the src is used directly. It is distributed in the following forms:

Internally we use it in:

  • The Cloud Code
  • API Server

The docs are available here

  • Browser - <script src="path/to/sdk/everlive.all.js"></script>
  • Node.js - var Everlive = require('everlive-sdk);
  • Cordova (Android, iOS, WindowsPhone) - <script src="path/to/sdk/everlive.all.js"></script>
  • Nativescript (Android, iOS) - var Everlive = require('everlive-sdk);
  1. Make sure that you have grunt-cli installed globally. $ npm install -g grunt-cli
  2. Run $ npm install in the root of the project.

The source code is available in the src folder. The entry point of the application is index.js.

To build the source code use:

$ grunt build

To build the source code on each change:

$ grunt buildWatch

The output is located in the root of the project - everlive.js and

To make a distibution build use the default grunt job:

$ grunt

It outputs the following files:

|-- root
    |-- dist
        |-- everlive.all.js
        |-- everlive.all.min.js
        |-- license
        |-- readme

We have setup automated tests for each supported environment. The tests are located in the test folder.

There are mobile projects for Cordova and Nativescript located in test/mobile/Everlive(Cordova|NativeScript). Currently there are automated tests only for Android.

External files for Node.js and PhantomJs are located in test/external.

  1. Setup Nativescript on your system -
  2. Setup Cordova on your system -

Also make sure to setup ADB on your system.

And grunt-cli if not already installed:

$ npm install -g grunt-cli

The easiest way is to open an .html file in the browser - test/suites/everlive-caching/everlive-caching.html.

To run all tests against all platforms sequentially run:

$ grunt test

Most of the times you will want to run them against specific platforms:

$ grunt test --platform desktop|nodejs|cordova|nativescript

If you want to run only a specific suite (test/suites/everlive-anything) specify the suite flag. By convention it tries to find the suite in test/suites/(suite)/(suite).html.

$ grunt test --platform cordova --suite everlive-files

The test results are shown in the console and written as tap reports in test/testResults(platform).tap:

ok 0 Everlive data -  Online  EmailSubscribers Everlive data -  offline control offline should throw when offline not enabled
ok 1 Everlive data -  Online  EmailSubscribers Everlive data -  offline control isOffline should throw when offline not enabled
not ok 2 Everlive data -  Online  EmailSubscribers Everlive data -  offline control isOnline should throw when offline not enabled -   AssertionError: expected 'expected false to be truthy' to equal 'You have instantiated the SDK without support for offline storage'

Each platform's tests are ran against a different backend-services project. These settings can be changed in test/suites/externalconfig.template.js.

Write the actual tests in the test/suites/everlive-(suite) folder. Each such folder should have a everlive-(suite).html file which specifies its tests:

<!DOCTYPE html>
    <meta charset="utf-8">
    <title>Everlive tests</title>
<script src="../../TestRunner.js" data-js="everlive-caching.test.js"></script>

A simple test:

describe("Test", function () {
    ok(1 === 1);

This will load all the scripts and css needed by default (see test/TestRunner.js), create a div[id=mocha] and add the scripts specified in the data-js attribute.

The TestRunner can be accessed from window.runner.