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-index

v0.2.2

Published

HTTP server/site for hosting and management of nonstop packages and bootstrappers

Downloads

11

Readme

nonstop index

Security Roles

Each of the actions provided by the index's API requires a user assigned to a specific role. The roles are:

  • admin - can perform all actions
  • agent - can upload new packages to the index
  • client - can make calls related to searching the index, downloading packages, registering hosts and updating status

Installation

Install the index globally from NPM:

npm install nonstop-index -g

Setup

You'll need to provide some information during the first run in order to create client and agent credentials. This information is stored in NeDB files by default. The users.db file will contain a list of users that displays their roles and tokens.

Running

Once you've set everything up, use the -s flag to auto-start the service and skip the menu.

nsindex -s

Configuration

The process will look in the current working directory (where nsindex was called from, not where it is installed to) for a config.json file. This file can provide keys that will override the defaults specified.

Note: when overriding a key with an array value, you must provide all desired values for the array.

defaults

{
	host: {
		cors: {
			"Access-Control-Allow-Origin": "*",
			"Access-Control-Allow-Headers": "X-Requested-With,Authorization,Content-Type",
			"Access-Control-Allow-Methods": "OPTIONS,POST,PUT,PATCH,GET,DELETE"
		},
		modules: [
			"nonstop-package-resource",
			"nonstop-registry-resource",
			"autohost-webhook"
		],
		noSession: true,
		apiPrefix: "",
		urlPrefix: "",
		port: 4444,
		logging: {
			adapters: {
				stdOut: {
					level: 3,
					topic: "#"
				}
			}
		}
	}
}

config.json

{
	"host": {
		"cors": {
			"Access-Control-Allow-Origin": "*",
			"Access-Control-Allow-Headers": "X-Requested-With,Authorization,Content-Type",
				"Access-Control-Allow-Methods": "OPTIONS,POST,PUT,PATCH,GET,DELETE"
		},
		"modules": [
			"nonstop-package-resource",
			"nonstop-registry-resource",
			"autohost-webhook"
		],
		"noSession": true,
		"apiPrefix": "",
		"urlPrefix": "",
		"port": 4444
	},
	"logging": {
		"adapters": {
			"stdOut": {
				"level": 3,
				"topic": "#"
			}
		}
	},
	"storage": {
		"s3": {
			"id": "",
			"key": "",
			"bucket": "nonstop-packages"
		},
		"rethink": {
			"host": "localhost",
			"port": 28015,
			"database": "nonstop"
		}
	}
}

Dockerization

Using the sample Dockerfile below, you can supply a config.json file that will provide the customization you need.

Sample Dockerfile

FROM nodesource/trusty:0.12.7
ENV DEBIAN_FRONTEND noninteractive
USER root

# install node via NPM and nonstop index
RUN /bin/bash -c "npm install [email protected] -g"

# Index HTTP
EXPOSE 4444

# setup directories for data and packages
RUN mkdir /usr/src/app/data && mkdir /usr/src/app/public

# expose data and packages as volumes
VOLUME [ "/usr/src/app/data", "/usr/src/app/public" ]

# add configuration file
ADD config.json /usr/src/app/config.json

CMD /bin/bash -c "nsindex -s"

Setup

The first time you run this container will need to be in interactive mode in order to create the authentication information.

Note: the image name nonstop-index is intentionally generic and would be replaced with your own Docker image.

first-time setup

sudo docker run -it \
	-v ~/nsdata:/usr/src/app/data \
	-v ~/packages:/usr/src/app/public \
	-e HOSTNAME=nonstop-index \
	-p 4444:4444 \
	--name nonstop-index \
	--restart=always \
	nonstop-index \
	bash

Updating

After that, container instances based on the original or newer versions of the image can be started directly as they will re-use the externalized NeDB files.

starting the container after setup

sudo docker run -d \
	-v ~/nsdata:/usr/src/app/data \
	-v ~/packages:/usr/src/app/public \
	-e HOSTNAME=nonstop-index \
	-p 4444:4444 \
	--name nonstop-index \
	--restart=always
	nonstop-index