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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simpleriak

v0.1.10

Published

a very simple riak http client

Readme

SimpleRiak is a very simple riak HTTP client. It wraps request and simplifies the calls made to riak as much as possible.

Usage

Installation

npm install simpleriak

Object creation

Host, port, and bucket are all optional. Host defaults to localhost and port to 8098. If bucket is present, it sets the default bucket to be used in future calls. If you don't set the bucket here, you must specify it in each call you make. Specifying a bucket in a call always takes precedence over the default.

var riak = require('simpleriak').createClient({ host: 'localhost', port: 8098, bucket: 'test' });

Callbacks

Every function returns the same callback pattern (err, reply).

err will be an Error object if any error is present reply is an object containing the following keys

  • "statusCode" will be the HTTP status code returned from riak
  • "data" will be the body of the HTTP response from riak
  • "headers" is the complete HTTP headers returned from riak
  • "key" when a location header is present, this property will contain the key in the header

List buckets

riak.getBuckets(function (err, reply) {
    console.log(reply.data);
});

List keys

riak.getKeys({ bucket: 'test2' }, function (err, reply) {
    console.log(reply.data);
});

List keys (matching an index)

riak.getKeys({ index: 'count', start: 5, end: 10 }, function (err, reply) {
    console.log(reply.data);
});

When using an index, you may either specify a start and end to be used with riak's range finding, or a key which will search for an exact match.

Get bucket properties

riak.getBucket(function (err, reply) {
    console.log(reply.data); // gets default bucket properties
});

Set bucket properties

riak.setBucket({ allow_mult: false }, function (err, reply) {
    console.log(err); // reply.data should be empty for this call
});

You can specify any editable property for a bucket.

Get data (by key)

riak.get({ key: 'test' }, function (err, reply) {
    console.log(reply.data); // returns { example: 'object' }
});

Get data (by index)

riak.get({ index: 'creator', key: 'me' }, function (err, reply) {
    console.log(reply.data); // returns ['i put this here']
});

When fetching data by index, the reply data will always be an array. This usage is actually an interface to the MapReduce function (described later) that fetches the keys and uses the Riak.mapValuesJson map phase to return data

Store data (Riak created key)

riak.put({ data: 'wee, a string!' }, function (err, reply) {
    console.log(reply.key); // the key riak created
});

Store data (User specified key)

riak.put({ key: 'test', data: { example: 'object' } }, function (err, reply) {
    console.log(err);
});

Store data (with an index)

riak.put({ index: { creator: 'me' }, data: 'i put this here' }, function (err, reply) {
    console.log(reply.key);
});

You can specify as many indexes as you like, the property name will be the index and its value the key.

Delete a key

riak.del({ key: 'creator' }, function (err, reply) {
    console.log(err);
});

Note that this function does not work with an index, this is by design. If you need to delete all keys that match an index, use getKeys and iterate the results.

MapReduce

function map(v, keyData, arg) {
    var ret = [],
        index = v.values[0].metadata.index;

    if (index.creator_bin === arg) ret.push(JSON.parse(v.values[0].data));
    return ret;
};

riak.mapred({ map: { source: map, arg: 'me' } }, function (err, reply) {
    console.log(reply.data); // ['i put this here']
});

The MapReduce function can take map and reduce phases as either an object (shown above), a string

riak.mapred({ map: 'Riak.mapValuesJson' }, callback);

or a function directly

riak.mapred({ map: map }, callback);

You may specify a bucket, a bucket and key, or a bucket and an index using an exact match or range.

riak.mapred({ bucket: 'test2', map: 'Riak.mapValuesJson' }, callback);
riak.mapred({ key: 'test', map: 'Riak.mapValuesJson' }, callback); // default bucket is used
riak.mapred({ index: 'creator', key: 'me', map: 'Riak.mapValuesJson' }, callback);

Ping

riak.ping(function (err, reply) {
    console.log(reply.data); // 'OK'
});

Stats

riak.stats(function (err, reply) {
    console.log(reply.data); // full stats object returned from riak
});

Resources

riak.resources(function (err, reply) {
    console.log(reply.data); // full resources information from riak
});