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

chain-smoker

v0.3.0

Published

Smokes a suite of tests a day (at least)

Downloads

19

Readme

Chain Smoker

It runs your tests. It checks the callbacks. Chain Smoker is an old curmudgeon that will yell at you when your stuff falls over.

It's totally not ready for use yet. Come back later.

Setup

Chain Smoker requires Redis.

  1. Install Chain Smoker
$ npm install chain-smoker --save
  1. Create your test suite.
var ChainSmoker = require('chain-smoker');

var Suite = {};

Suite.tests = [
  {
    name: 'example-get',
    address: 'http://example.com',
    assertions: {
      statusCode: 200
    }
  },
  {
    name: 'example-callback',
    address: 'http://example.com/call/me/back',
    method: 'POST',
    headers: {
      'X-Awesome-Header': 'this is really cool'
    },
    body: {
      neato: true,
      callback_url: 'http://this-hostname/callback/example-callback'
    },
    assertions: {
      statusCode: 201
    },
    callback_assertions: {
      job_success: function(req) {
        return req.body.status === 'success';
      }
    },
    callback_time_limit: 10000,
    external_id: function(req) {
      return req.body.id;
    }
  }
];

var options = {
  apiPort: 8080,
  lateCallback: function(jobs) {
    if (jobs.length === 0) {
      console.log('There are no late jobs!');
    } else {
      console.log('There are '+ jobs.length +' late jobs!');
      console.log(jobs);
    }
  }
}

ChainSmoker(Suite, options, function(err, runner) {
  if (err) return console.log(err);
  console.log('Locked and loaded.');

  // Now that everything's nice and ready, we need to
  // kick off the tests. Sit back and let the man smoke.
  runner.runAll();
});
  1. Enjoy.

Test options

Option | Details (default) ------- | --------- name | String (null) - Name of the test (really useful for callback routing) address | string (null) - Endpoint to hit for the test method | string (GET) - HTTP method to use when hitting the specified address headers | Object ({}) - Headers to deliver when making the request body | String or Object ('null') - If an object is given, it will be stringified before making the request. external_id | Function (msg.body.id) - Function that returns a unique ID from the response. If this is null, msg.body.id is blindly used, so external_id could potentially be null. assertions | Object ({}) - Object containing the assertions to run against the initial request. The values of each assertion can either be a string (or object) to compare against the key of the same name in the response, or a function that returns true or false. callback_assertions | Object (null) - Same as above, but for the callback received from the initial request callback_time_limit | Integer (0) - Amount of time (in milliseconds) before a callback is considered late. After this point, the late jobs begin to show up in the lateCallback mentioned below.

Chain Smoker Run Options

Option | Values (default) | Details ------------- | ---------------- | ------------ apiPort | Integer (3000) | The port to use for the callback server lateCallback | Fn([jobs]) (noop()) | The function to call when the check for late jobs comes back. The callback fires even if the array is empty, which can be useful to clear out any pager alerts or other things fired when the array was not empty. lateCheckFrequency | Integer (1500) | How often in milliseconds to check for late jobs disableCleaner | Boolean (false) | If true, old completed jobs will not be removed from the database cleanFailures | Boolean (false) | Whether or not to remove jobs that have completed, but were unsuccessful maxCompletedAge | Integer (3600000) | If cleanup is enabled, this is the age (in milliseconds) threshold before a job is cleaned. Default is 1 hour. cleanFrequency | Integer (5000) | How often in milliseconds to run the cleanup check