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

requireable-registry-couchapp

v1.0.5

Published

When writing code that needs to do some of the same things that the npm registry does, it can be useful to use the couchapp code for the registy itself, which is in the package [`npm-registry-couchapp`](https://www.npmjs.com/package/npm-registry-couchapp)

Downloads

8

Readme

requireable-registry-couchapp

When writing code that needs to do some of the same things that the npm registry does, it can be useful to use the couchapp code for the registy itself, which is in the package npm-registry-couchapp. Unfortunately, this code is not designed to run in node, but in CouchDB, so in order to require it correctly, require need to be defined in a way that works correctly.

In order to make this easier, requireable-registry-couchapp does all the work of requiring the the code, and making it available to you.

For example, to use the couchapp code for showing a package (which does things like isolating versions as well), you can do this:

var ddoc = require('requireable-registry-couchapp')();

var shownPackage = ddoc.shows.package(/* ... */);

The functions that are provided by npm-registry-couchapp, such as the one in the example above, can sometimes be confusing to use (as they have specific argument requirements), so for convenience, a few extra functions have been added:

ddoc.showPackage(doc, name, [version])

This calls the ddoc.shows.package function as above, putting in ther correct arguments. doc should be JS object that is the entire package metadata.

Returns a JS object.

ddoc.showPackageString(doc, name, [version])

Since ddoc.shows.package returns a string instead of an object, and sometimes that's exactly what you want, this method bypasses the JSON.parse done in ddoc.showPackage, but is otherwise identical to it.

ddoc.updatePackage(params, updatedDoc, originalDoc, username, isAdmin)

This calls ddoc.updates.package with the correct arguments. params indicates which kind of update is being done, and is typically gotten from an HTTP request (see source for more details). updatedDoc is the new state of the document and originalDoc is the state it was in before. username is the username of the user performing the operation and isAdmin is used to override permissions if the user doesn't own the package.

Returns an array. The first element is the modified document. The second element is a stringified status message, which can be sent to clients to confirm the update.

This function also calls ddoc.validate_doc_update, which can throw, and the objects that it throws are not Error objects, unfortunately.

License

Code licensed under the MIT license. See LICENSE.txt file for terms.