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

ezhs

v1.1.0

Published

Easy HTTP Server

Downloads

8

Readme

Easy HTTP Server

  • Only accepts GET/HEAD requests
  • Applies gzip encoding when appropriate (1.4KB <= file size <= 10MB, and in a text file format more-or-less)
  • Your reverse proxy should be handling SSL and caching
  • Sane defaults
  • No current option for custom HTTP error pages

Defaults

CORS headers

  • Access-Control-Allow-Methods: GET, HEAD
  • Access-Control-Allow-Headers: X-Requested-With, Content-Type, Content-Encoding
  • Access-Control-Allow-Credentials: false

Other security headers

  • X-Content-Type-Options: nosniff
  • X-XSS-Protection: 0
  • Cross-Origin-Resource-Policy: same-site
  • Cross-Origin-Embedder-Policy: require-corp
  • Referrer-Policy: strict-origin-when-cross-origin
  • Server: webserver
  • Permissions-Policy: geolocation=(), camera=(), microphone=(), display-capture=()
  • Content-Security-Policy: default-src 'self' 'unsafe-inline'; frame-ancestors 'self'; form-action 'self';

Use in node.js

.listen(port_number) - Starts the server, default: 80

.close(callback) - Closes the server, calls the callback function when when the server closes (after all connections are finished)

.path('/path/to/static/files') - Defaults to the current directory

.gzip() - Disable gzip compression

.security() - Disable non-CORS security headers

.cors('optional url') - Sets the CORS URL; sending no string defaults to "*"

.headers([ insert header arrays here ]) - Overwrites any other headers besides the CORS URL (if it's set)

Examples in js

import ezhs from 'ezhs'
const server = ezhs();
server.listen();

The simplest example, listens on the default port 80 and hosts files in "./public/"

server.path('./files').listen(8080);

Listens on port 8080 and hosts files in "./files/"

server.headers([
    ['X-Frame-Options', 'DENY'],
    ['X-XSS-Protection', '0'],
    ['X-Content-Type-Options', 'nosniff'],
    ['Referrer-Policy', 'strict-origin-when-cross-origin'],
]).listen();

Listens on port 80, includes XSS headers

Use via commandline

npm i -g ezhs

ezhs

    Options:
        -d, --dir       Sets the directory to host static files, defaults to the current directory
        -p, --port      Sets the port for the server to run on, defaults to 80
        -g, --gzip      Disables gzip
        -c, --cors      Set the CORS URL or let it default to "*"
		-s, --security	Disables default non-CORS headers
        -h, --help      Displays this help message

    Example:
        ezhs
            Runs the server with default values (no CORS)
        ezhs -p 8080 -d ./web -g -c
            Uses port 8080, serves from "./web", disables gzip, enables CORS from all domains
        ezhs -c http://www.google.com
            Enables CORS from a specific origin

Testing

npm run test

Todo

  • custom error pages
  • https maybe