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

nonstop-package-resource

v0.2.1

Published

Package index HTTP API as a resuable resource lib for Autohost

Downloads

13

Readme

nonstop package resource

This module can be used to provide the nonstop package hypermedia API to any autohost server that's using hyped.

Why?

If you have a client application that you'd like to have installed that auto-updates itself whenever new versions are available - this makes adding the server side support very simple.

Using with Autohost

NPM install this module to your project

npm install nonstop-package-resource hyped -S

Add the module to the modules property in your autohost init:

var hyped = require( 'hyped' );
var host = require( 'autohost' );

host.init( {
		port: 8888,
		noOptions: true,
		urlStrategy: hyped.urlStrategy,
		modules: [ 'nonstop-package-resource' ]
	} )
	.then( hyped.addResources );
hyped.setupMiddleware( host );

Consuming

To consume this API from Node, please look at nonstop-index-client. It uses halon to discover the API this makes available via hyped.

API

The API this adds is relatively straight-forward. It allows for

Download By Filter

If you know the criteria for uniquely identifying a file (project, owner, branch, version or slug), you can provide the criteria via query parameters to get the matching file.

GET /package?project=test&owner=me&branch=master&version=0.1.0-1

GET /package?slug=1da43f9

Download By File Name

If you know the filename, it can be provided in the URL path for the get.

GET /package/test~my~develop~53688240~0.1.0~1~linux~any~any~x64.tar.gz

List Packages

This allows you to find packages that match the criteria provided via query parameters. It sorts the results by the semantic version of the packages from the newest to oldest.

GET /package?project=test&owner=your&branch=feature-branch&version=0.1.0-1

List Projects

Provides a unique set of projects that match the criteria. Useful for finding all a particular owner's projects or seeing the builds for a particular slug.

GET /project?owner=teamMember

List Terms

A way to see all possible values for specific package filters. Warning can be time consuming since some storage mechanisms will have to scan all packages to determine the term list. You can limit the terms by providing a filter to only see values across a subset of packages.

GET /terms?owner=myOrg

Upload

Allows build agents to upload a new package.

POST /package

Promote

Promotes a package to release. Nonstop builds will not produce a release version, there will always be a build number appended so that packages look like pre-releases to the service hosts. Promoting a package removes the build number and creates a non-pre-release semantic version of that package. Use with caution.

Configuration

By default this module uses the file system and memory to manage packages and the related information. The major trade-off being that everything is done in-memory which means some performance degredation over time.

No additional configuration is required to get default behavior.

Alternate Storage Providers

This module supports optional S3 package storage and optional RethinkDB package information storage. They can be used together or separately. If only Rethink is configured, the local file system is still used to store packages.

S3 storage

To have packages stored in S3, you'll need to provide configuration. Configuration for this module is provided via fount:

var fount = require( 'fount' );
var hyped = require( 'hyped' );
var host = require( 'autohost' );

var storage = {
	s3: {
		id: '',
		key: '',
		bucket: ''
	}
};

fount.register( 'storageConfig', storage );

host.init( {
		port: 8888,
		noOptions: true,
		urlStrategy: hyped.urlStrategy,
		modules: [ 'nonstop-package-resource' ]
	} )
	.then( hyped.addResources );
hyped.setupMiddleware( host );

RethinkDB Info

To have packages information stored in RethinkDB, you'll need to provide configuration. Configuration for this module is provided via fount:

var fount = require( 'fount' );
var hyped = require( 'hyped' );
var host = require( 'autohost' );

var storage = {
	rethink: {
		host: 'localhost',
		port: 28015,
		database: 'nonstop'
	}
};

fount.register( 'storageConfig', storage );

host.init( {
		port: 8888,
		noOptions: true,
		urlStrategy: hyped.urlStrategy,
		modules: [ 'nonstop-package-resource' ]
	} )
	.then( hyped.addResources );
hyped.setupMiddleware( host );