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

node-static-plus

v1.0.0

Published

A super-simple static web server with optional HTTP Basic Auth and local HTTPS via self-signed certificates.

Downloads

4

Readme

node-static-plus

A super-simple static web server with optional HTTP Basic Auth and local HTTPS via self-signed certificates.

node-static-plus makes it super-simple to add a static server to a client-side project for working with secure services and privileged JavaScript APIs. Once you're ready to deploy it to Dokku, Heroku, now, or whatever, add any platform-specific files (e.g. echo 'web: node .' > Procfile for Dokku/Heroku) and you're good to go.

node-static-plus is built on top of the tried and tested foundation of node-static.

Usage

$ npm i -s node-static-plus to add the module as a dependency, then create an index.js as follows:

// index.js

const nodeStaticPlus = require('node-static-plus')
const config = {
  // see next section for config options
}

nodeStaticPlus(config)

Configuration

node-static-plus can be configured as follows:

const config = {
  auth: { // Optional
    username: 'user', // Required if `auth` is specified
    password: 'pass', // Required if `auth` is specified
    realm: 'Demo', // Optional. Displayed in authentication prompt is some browsers. Default is `'Private'`
    always: true, // Optional. Enforces authentication even when `process.env.NODE_ENV !== 'production'`. Default is `false`
  },
  errors: { // Optional
    404: '404.html' // If you don't specify a 404, a blank page will be shown instead
  },
  port: 12345, // Optional. Default is `process.env.PORT` or `54321`
  root: 'public', // Optional. Default is `'.'`
  static: {}, // Optional. Provides configuration for `node-static`. See `node-static` documentation for valid options
  tls: { // Optional. Swaps the server to HTTPS (unless `process.env.NODE_ENV === 'production'`)
    cert: 'path/to/cert.pem',
    key: 'path/to/cert-key.pem'
  }
}

Of course you can also set any property to use environment variables, etc.

TLS support

node-static-plus turns into an HTTPS server if you feed it a valid SSL certificate and key.

If you need to create locally-trusted development certificates, check out mkcert.

TLS in production

TLS support is intended for local dev use only, and the configuration is automatically ignored in production, where you should be using something more robust. Many platforms will provide SSL out-of-the-box. If you're using dokku, then dokku-letsencrypt is your friend.

Demo

$ npm run demo and open http://localhost:12345 in your browser. Username is user and password is pass.

Unresolved URLs such as http://localhost:12345/unicorns get a 404 page as per the config in demo/index.js.