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

dcap

v0.1.0

Published

A NodeJS implementation of [dCap](https://github.com/genealogysystems/dcap).

Downloads

2

Readme

dCap

A NodeJS implementation of dCap.

Download

You can install cDap by cloning this repository or by using npm

npm install dcap

Tests

There is a fairly comprehensive test suite.

cd /path/to/cloned/repo
mocha

// TODO notes for REST api tests

http://thewayofcode.wordpress.com/2013/04/21/how-to-build-and-test-rest-api-with-nodejs-express-mocha/

https://brianstoner.com/blog/testing-in-nodejs-with-mocha/

https://www.npmjs.org/package/supertest

To see code coverage run

cd /path/to/cloned/repo
./coverage/generate.sh

Open ./coverage/coverage.html in your browser to view the coverage report.

Note: make sure you install jscoverage first.

Usage

var dcap = require('dcap');

var store = dcap.createMemStore(opts);
//var store = dcap.createElasticSearchStore(opts);

var client = dcap.createClient(store, options);

var server = dcap.createServer(store, options);

server.listen(port, callback);

Store

Implementations of a dCap store.

There are a few Store implementations, the only difference in syntax being the options they take in instantiation.

MemStore - An in-memory implementation

var store = dcap.createMemStore({});

ElasticSearchStore - A store backed with ElasticSearch (coming soon) // TODO move out to dcap-elasticsearch?

var opts = {};
var store = dcap.createElasticSearchStore(opts);

store.get(repo, id, callback)

store.get('repo-id', 'commit-id', function(error, commit) {
  // error will either be Error or null
  // commit will be a JSON object
})

store.put(repo, id, commit, callback)

store.put('repo-id', 'commit-id', commitObj, function(error) {
  // error will either be Error or null
})

store.query(criteria, callback)

//TODO Change type of return to object with more info about matches?

For a full list of criteria see here.

var criteria = {
  repo: '1234',
  from: 1398441136000
}

store.query(criteria, function(error, commits) {
  // error will either be Error or null
  // commits will be an array of matching commits
})

Client

Implementation of a dCap client.

var options = {
  send: {
    "repo1": [
      "_local"
    ],
    "repo2": [
      "_local",
      "http://host.com:1234"
    ],
    "*": [
      "http://host.com:1234"
    ]
  },
  receive: {
    "repo1": "_local",
    "repo2": "http://host.com:1234"
    "*": "http://host.com:1234" // * is required
  }
}

var client = dcap.createClient(store, options);

Conventions

dcap client follows the standard Node callback conventions.

client.someFunction(param1, param2, callback);

function callback(error, optionalReturnValue) {
  // error will either be a standard Error or null

  // optionalReturnValue is the return value of the function.
  // Note: some functions have no return value, like graph.save(repo, commit, callback)
}

client.save(repo, commit, callback)

client.save('repo-id', commitObj, function(error) {
  // error will either be Error or null
})

client.get(repo, commit)

client.get('repo-id', 'commit-id', function(error, commit) {
  // error will either be Error or null
  // commit will be a JSON object
})

client.query(criteria, commit)

For a full list of criteria see here.

var criteria = {
  repo: '1234',
  from: 1398441136000
}

client.query(criteria, function(error, commits) {
  // error will either be Error or null
  // commits will be an array of matching commits
})

Server

Implementation of a dCap server.

var server = dcap.createServer(store, {});
server.listen(8081, callback);