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

smart-private-npm

v2.3.0

Published

An intelligent routing proxy for npm with support for: private, whitelisted, and blacklisted packaged

Downloads

71

Readme

smart-private-npm

build
status

An intelligent routing proxy for npm with support for: private, whitelisted, and blacklisted packages.

Sample Usage

n.b. Default CouchDB rewrites automatically loaded from config/rewrites.js.

  var smartPrivateNpm = require('smart-private-npm'),
      url = require('url');

  //
  // Configure your private npm. You could load this in from a file
  // somewhere
  //
  var config = {
    //
    // Private npm options.
    //
    rewrites: require('./config/rewrites'),
    proxy: {
      //
      // This can optionally just be a single url.parsed URL or an array to
      // cycle through. Optionally you can also have an array of url.parsed urls
      // as well
      //
      npm: {
        read: url.parse('http://user:[email protected]'),
        write: url.parse('https://registry.npmjs.org')
      },
      policy: {
        npm: url.parse('http://user:[email protected]'),
        private: {
          //
          // This is the list of "known private modules"
          // that will always be proxied to the private npm.
          // It is built over time by remembering "publish" requests.
          //
        },
        blacklist: {
          //
          // This is the list of modules that will ALWAYS be proxies
          // to the private npm, no matter what.
          //
        },
        whitelist: {
          //
          // If enabled: only requests for these modules will be served
          // by the proxy (unless they are "known private modules").
          //
        },
        //
        // In "transparent mode" the proxy will always forward to
        // the public registry.
        //
        transparent: false
      }
    },
    //
    // Server options (from "create-servers")
    //
    http: 80,
    https: {
      port: 443,
      root: '/path/to/your/ssl/files',
      key: 'your-ssl.key',  // or .pem
      cert: 'your-ssl.cert' // or .pem
    }
  };

  smartPrivateNpm.createServer(config, function (err, servers) {
    if (err) {
      console.log('Error starting private npm: %j', servers);
      return process.exit(1);
    }

    console.log('Private npm running on %j servers.', Object.keys(servers));
  });

Understanding a Policy

In order to get your smart-private-npm setup you'll need to decide on a policy for your users, which are assumed to be authenticated by the CouchDB and the npm CouchApp. A policy is composed of:

  • Private: This is the set of "known private packages" which are always proxied to your private CouchDB server. All new publish requests are also proxied to your private CouchDB server.
  • Blacklist: These packages are explicitly forbidden to be retrieved from the public npm. It is possible for a package to be both private and blacklisted. This is how you can take ownership over a given module.
  • Whitelist: If set, only these packages (and all private npm packages) will be permitted from the public npm registry.

Both the sets of whitelisted and blacklisted packages are read from on start time and require updating from the caller.

License: Apache2
Author: Nodejitsu Inc.
Contributors: Charlie Robbins, Jarrett Cruger