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

heroku-addonpool

v1.0.2

Published

Manages Addon Pool of an App in Heroku.

Readme

Manages Addon Pool of an App in Heroku.

# NOTE:
# The app with addons (pool app) must be different from the app
# that uses the addons because heroku resets the pool app each
# time a configuration variable is changed.
# set heroku cli login in environment variables
[email protected]
HEROKU_CLI_PASSWORD=yourpassword

# also as of now you also need to purge cache before build
heroku repo:purge_cache -a yourpoolapp
var Pool = require('heroku-addonpool');
// Pool(<id>, <app>, <opt>)

/* Assume "ci-herokuaddonpool" has 2 postgresql addons provisioned.
 * There are 3 consumers which need access to a postgresql database,
 * for a limited amount of time. Since we have only 2 available, we
 * create a pool to enable consumers to acquire (remove) and release
 * (add) database from the pool. If no database is available in the
 * pool, a consumer will have to wait (Promise) until the resource
 * is released by some other consumer.
 */

var pg = Pool('heroku-postgresql', 'ci-herokuaddonpool', {
  'config': /(HEROKU_POSTGRESQL|DATABASE)\S*URL/g,
  'log': true
});

pg.setup().then((ans) => {
  var cona = 'consumer-a';
  var conb = 'consumer-b';
  var conc = 'consumer-c';
  console.log(ans);      // available addons (Map)
  console.log(ans.size); // number of addons
  pg.remove(cona).then((ans) => {
    console.log(ans.name);        // name of the addon
    console.log(ans.attachments); // app to addon attachments
    console.log(ans.installedAt); // provision date
    console.log(ans.owningApp);   // owner app of this addon
    console.log(ans.plan);        // addon service:plan
    console.log(ans.price);       // addon price
    console.log(ans.state);       // addon state
    console.log(ans.value);       // addon access url
    console.log(`${cona} has acquired ${ans.name}`);
    console.log(`-> connection string: ${ans.value}`);
    // consumer-a uses database for 20s
    setTimeout(() => {
      console.log(`${cona} is releasing ${ans.name}`);
      pg.add(cona);
    }, 20000);
  }).then(() => {
    return pg.remove(conb);
  }).then((ans) => {
    console.log(`${conb} has acquired ${ans.name}`);
    console.log(`-> connection string: ${ans.value}`);
    // consumer-b uses database for 10s
    setTimeout(() => {
      console.log(`${conb} is releasing ${ans.name}`);
      pg.add(conb);
    }, 10000);
  }).then(() => {
    return pg.remove(conc);
  }).then((ans) => {
    // consumer-c waits for 10s until consumer-b releases
    console.log(`${conc} has acquired ${ans.name}`);
    console.log(`-> connection string: ${ans.value}`);
    // consumer-c uses database for 10s
    setTimeout(() => {
      console.log(`${conc} is releasing ${ans.name}`);
      pg.add(conc);
    }, 10000);
  });
});