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

nestor-share

v0.0.1

Published

Resource sharing plugin for nestor

Downloads

3

Readme

Resource sharing plugin for nestor

This plugin enables other plugins to share resources, ie make them available for download to users without authorized access to nestor, with a random and short URL. Shares can be manually revoked or suspended at any time.

Shared resources can also have limits, for example:

  • A maximum number of downloads
  • An expiration date
  • A list of allowed client IP addresses

Sharing resources

To share a resource, a plugin must :

  • define a share provider function with the share:provider intent
  • add a document to the Share model collection, with the provider name and a resource ID

It's then up to the share provider to resolve the resource ID to what is actually intended to be shared, and build the actual download file. The Share model does not allow storing the actual contents of the download, instead it must be determined dynamically by the share provider function.

Internals

Models

Share: a model to store shared resources, along with their limits. Each share has a provider name and a provider-specific resource ID.

REST resources

/shares/:id: access to shared resource definitions.

HTTP resources

/downloads/:id: download shared resource

Intents

share:provider: used by plugins to declare a "share provider", that is, a handler that is able, given a resource ID, build a downloadable file. This intent must be dispatched with the following arguments:

  • the provider name
  • the share provider function

The provider function is called when a shared resource is requested by a client, and receives the resource ID, a DownloadStreamBuilder object and a callback as arguments. It should build the download using the DownloadStreamBuilder, and then call the callback (with an optional error argument).

DownloadStreamBuilder usage

A DownloadStreamBuilder provides methods to add contents to a download. If multiple files have been added to the builder, a ZIP archive will be sent to the client.

  • DownloadStreamBuilder#addContent(name, content) creates a new file named name with content content. When building downloads with multiple files, name can be a relative path in the archive; parent directories are created automatically.
  • DownloadStreamBuilder#addFile(name, path) adds an existing file path with name name. When building downloads with multiple files, name can be a relative path in the archive; parent directories are created automatically.
  • DownloadStreamBuilder#addDirectory(name, path) adds an existing directory path, including its contents, under relative path name in the archive.
  • DownloadStreamBuilder#setDownloadFilename(name) sets the name of the file to be sent to the client.

The name of the file sent to the client is determined as follows:

  • if setDownloadFilename has been called, the name it received
  • otherwise, if the download contains a single file, the basename of this file
  • otherwise, if the download contains a single directory, the basename of this directory with a ".zip" extension
  • otherwise, "download.zip"