Giter Club home page Giter Club logo

activitybox's Introduction

Activity Box Build Status Coverage Status

Live updates, and subscriber/publisher implementation encapsulated in RESTful box.

This package just provides you with basic functionality. You still need to create your own client-side scripts, to show data.

This module creates a RESTful API server, and socket.io listner. Any app should post json data to the API, and socket listener will update the client immediately. It uses redis Pub/Sub methods, so you must have redis server running. Request and response should be always in JSON format.

Installation

$ npm install activitybox

Usage

Run app using default configuration:

var app = require('activitybox');
app.run();

Run app using custom configuration:

var app = require('activitybox');
app.run('path/to/my-config.json');

JSON configuration file default/example:

{
  "server": {
    "name": "activity-box",
    "port": 9000,
    "streamURI": "stream"
  },
  "redis": {
    "host": "127.0.0.1",
    "port": 6379,
    "channel": "my-channel"
  }
}
  • Your running app, will expose a RESTful URI /push to post updates.
  • Sockets will be attached to the namespace streamURI, e.g.: http://localhost:9000/stream/channel-name

Client Example

To run client, open the following file statically in browser:

test/client.example.html

Example: Post data to the API, using cURL:

$ curl -X POST -H "Content-Type: application/json" -d '{"channel": "ch1", "item": {"title": "t1", "image": "t1.png", "link": "/t1"}}' http://localhost:9000/push

Run tests:

$ npm test

License

MIT

activitybox's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.