Git Product home page Git Product logo

shariff-backend-node's Introduction

Shariff Node Backend

Shariff is used to determine how often a page is shared in social media, but without generating requests from the displaying page to the social sites.

Shariff Logo © 2014 Heise Zeitschriften Verlag

This document describes the Node backend. The following backends are also available:

The frontend is available here:

Installing the Shariff backend on you own server

Option 1: Run the standalone server

Create a project folder and install the Shariff server using npm:

$ mkdir my-shariff-server
$ cd my-shariff-server
$ npm init
$ npm install --save shariff-backend-node

The node package contains a configuration file shariff.json. The following configuration options are available:

Key Type Description
port integer Port Shariff runs on
host string Host/IP address Shariff runs on
cache object Cache settings described below

Cache settings:

Key Type Description
engine string catbox backend
expiresIn integer Cache duration in milliseconds

Start Shariff with:

$ node node_modules/shariff-backend-node/run.js
141104/143603.929, info, Server ist running at: http://localhost:3001

Option 2:

Alternatively, you may call the Shariff backend from your own code. If called directly, the code will still use a cache and honor the expiresIn setting, the engine will however not be used in this case, just a simple object store.

Sample:

var Shariff = require('shariff-backend-node');

Shariff.getCounts('google.com').then(function(counts) {
    console.log('Success, counts:', counts);
}, function(err) {
    console.log('Failed to grab counts!', err);
});

If passed true as second parameter, the getCounts() method will not use its cache and instead re-query the services.

Testing your installation

Visit http://localhost:3001/?url=www.example.com to get a JSON structure containing the share counts:

{"facebook":1452,"googleplus":23}

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.