npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jugo

v0.0.5

Published

JavaScript port of OpenFuego

Downloads

20

Readme

jugo

fuego for JavaScript

Installation

To run jugo, the following must be installed

Once both are installed, run the following to install jugo locally

npm install jugo

Usage

Collection script

To start collecting tweets from your "universe" via the twitter gardenhose, create a script containing the following...


var jugo = require('jugo');

var J = jugo({
  "twitter" : {
    "consumer_key": "<INSERT KEY>",
    "consumer_secret": "<INSERT KEY>",
    "access_token": "<INSERT KEY>",
    "access_token_secret": "<INSERT KEY>"
  },
  "accounts" : [
    ... // list of accounts you want to track
  ],
  "database" : "mongodb://localhost/test" // database location
})

// start collecting
J.collect();

And then run it as a background process. This will collect tweets as they come in, as well as metadata scraped from the urls. The collection script creates two mongo collections posts and meta which contain documents of the following schema...

// example post document
{
  url : post_url,
  date : new Date(tweet.created_at),
  account : tweet.user.screen_name,
  followers : tweet.user.followers_count,
  retweets : tweet.retweet_count,
  favorites : tweet.favorite_count
}

// example meta document
{
  url : url,
  title : ..., // open graph protocol title
  image : ...,// open graph protocol image
  author : ..., // open graph protocol author
  description : .., // open graph protocol description
  date : ..., // open graph protocol date
}

Usage in a web app

Jugo also provides a little wrapper for aggregating and accessing the tweets in the database. For example, in node express application, one might use Jugo as follows...


var jugo = require('jugo');

var J = jugo(jugo_config);

// open jugo database connection when app starts
J.open(function() {
  console.log('database open!')
});

// database query api
app.get('/get/:query', function(req, res) {
  var params = getJsonFromUrl(req.params.query);

  var max, min;

  if (params.max) {
    var date_num = parseInt(params.max);
    if (!isNaN(date_num)) {
      max = new Date(date_num);
    }
  }

  if (params.min) {
    var date_num = parseInt(params.min);
    if (!isNaN(date_num)) {
      min = new Date(date_num);
    }
  }

  //
  // Use jugo "get" method to find top 40 stories
  // (currently ranked by number of tweets)
  // returns ...
  // {
  //   url : (shared url)
  //   count : (number of shares in specified timeframe)
  //   meta : (object containing scraped OG protocol metadata)
  // }
  //
  J.get(
    {
      max_date : max,
      min_date : min,
      num : 40
    },
    function(results) {
      res.send(results);
    }
  );
})