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

pingback

v0.0.3

Published

pingbacks for node.js

Readme

node-pingback

Pingbacks have come to node.js. If you're writing a blog, you may be interested in this. It conforms to the pingback specification, as well as the XML-RPC spec, however, it may need more testing.

It protects against spam, has no dependencies, and can be used right out of the box. Connect/Express middleware is included.

Usage

Receiving Pingbacks (contrived example for clarity)

app.use('/pingback', Pingback.middleware(function(source, target, next) {
  var self = this;
  Posts.get(target.pathname, function(err, post) {
    if (err) {
      return next(Pingback.TARGET_DOES_NOT_EXIST); 
    }
    if (post.pingbacks[source.href]) { 
      return next(Pingback.ALREADY_REGISTERED);
    }
    if (post.pingbacksDisabled) {
      return next(Pingback.TARGET_CANNOT_BE_USED); 
    }
    // or pass zero above for a generic error
    post.pingbacks.push({
      from: source.href, // e.g. "http://domain.tld/hey_check_out_this_guys_post"
      title: self.title, // e.g. "Joe's blog"
      text: self.excerpt // e.g. "hey, check this out: <a href="your_site">...</a>"
    });
    post.save();
    next(); // send a success response
  });
}));

What you see above is merely the abstracted interface of the bundled middleware. See example.js/test.js for more in-depth and lower-level examples.

Sending Pingbacks

// ping a target - err will be a fault code if present
Pingback.send('[target]', '[source]', function(err, pingback) {
  if (!err) console.log('Pinged ' + pingback.href + ' successfully.');
});

// scan an html string for links to ping
var text = 'a link here: <a href="http://localhost:9000/article">a post</a>';
Pingback.scan(text, '[source]', function(err, pingback) {
  // optional callback - will get called for every pingback sent
  if (!err) console.log('Pinged ' + pingback.href + ' successfully.');
});

Again, see example.js/test.js for more examples and explanation.

Reference

Fault Code Constants

Pingback.METHOD_NOT_FOUND = -32601;
Pingback.GENERAL_ERROR = 0;
Pingback.SOURCE_DOES_NOT_EXIST = 16;
Pingback.NO_LINK_TO_TARGET = 17;
Pingback.TARGET_DOES_NOT_EXIST = 32;
Pingback.TARGET_CANNOT_BE_USED = 33;
Pingback.ALREADY_REGISTERED = 48;
Pingback.ACCESS_DENIED = 49;

Pingback properties

  • source: a parsed url object of the source
  • target: a parsed url object of the target
  • excerpt: an excerpt from the source's page
  • title: the title of the source page

Events for receiving pingbacks

  • ping: An optional event to validate and handle errors/faults. If bound, this will be triggered as the first event and passed a next callback, which can be passed a fault code to trigger a fault response, otherwise it will continue handling the pingback. Arguments: source, target, next.
  • fault: Emitted when a fault occurs. Passed the fault code and string. Arguments: code, msg.
  • error: Emitted for non-fault related errors. Calls the next middleware layer in the bundled connect/express middleware function. Arguments: err.
  • end: Emitted if no ping listeners have been bound, and after a pingback has been received and verified. Arguments: source, target, next. next has the same effect as the callback passed for ping.
  • success: Emitted if a ping listener was bound, and after the pingback has been received and handled. Arguments: source, target.

License

(c) Copyright 2011, Christopher Jeffrey (MIT License). See LICENSE for more info.