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

auth-static

v1.0.3

Published

Super-simple node-static server with http basic auth

Downloads

14

Readme

Auth-static

A super-simple node-static server with http basic auth, perfect for serving static content on Heroku behind a username and password.

Works as a simple static server without authentication until pushed to production, whereupon basic HTTP authentication is employed.

Supports a superset of the node-static API.

Usage

var server = require('auth-static')

server(config)

Config

Auth-static uses a configuration object with the following keys:

var config = {
	options: {
		// supports node-static options
	},
	password: process.env.PASSWORD, // environment variable
	port: 1234,                     // port for localhost only
	realm: 'Private',               // label for the auth form
	root: './example',              // root directory to serve
	username: process.env.USERNAME  // environment variable
}

Heroku

The simplest way to get up and running on with auth-static on Heroku (assuming you've already installed the Heroku Toolbelt) is to:

  1. Create a Heroku app
  2. Install auth-static via NPM
  3. Create the server
  4. Tell Heroku to run the server
  5. Set up the config variables in the Heroku Dashboard
  6. Commit your changes
  7. Push your code to Heroku
  8. Test your app

In more detail

1. Create a Heroku app

heroku create your-app-name

Replace your-app-name with whatever you want your app to be called. This example would result in the app being available at https://your-app-name.herokuapp.com/.

2. Install auth-static via NPM

npm install --save auth-static

3. Create the server

// index.js

var server = require('auth-static')

server({
	options: {
	    cache: 3600,
	    gzip: true
	},
	password: process.env.PASSWORD,
	port: 1234,
	realm: 'Private',
	root: './example',
	username: process.env.USERNAME
})

4. Tell Heroku to run the server

The Procfile tells Heroku what to do once it's installed your project.

We want Heroku to run the server that lives in index.js:

// Procfile

web: node index.js

5. Set up the config variables in the Heroku Dashboard

Visit https://dashboard.herokuapp.com/, navigate to the settings page for your app and edit the config variables. We need to create pairs for NODE_ENV, USERNAME, and PASSWORD. NODE_ENV needs a value of productio for everything to work, whereas the the other two can be whatever you want.

6. Commit your changes

git commit -m "Setting up auth-static"

7. Push your code to Heroku

git push master heroku

8. Test your app

Running heroku open will open your app (e.g. https://your-app-name.herokuapp.com/) in your browser of choice. If everything has worked, you will be presented with a basic auth form; enter your username and passowrd and you'll be able to see your static content.