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

httpdir

v2.1.0

Published

Simple, zero dependency command-line HTTP server for static local files

Downloads

38

Readme

Version Downloads Last commit Test Codecov Install Size

Icon

Simple, zero dependency command-line HTTP server for static local files


Installation

This module needs Node >=14.

Install with npm:

$ npm install httpdir --global

Usage

CLI

httpdir <path> <port>

Example:

# This will start a local server on port `8090`,
# with `~/Desktop` as root directory
httpdir ~/Desktop 8090

Default path is ., default port is 8080.

Node module

Import httpdir and create a server:

const httpdir = require('httpdir')
const server = httpdir.createServer({
  basePath: '/some/path', // Optional, default is "."
  httpPort: 9898,         // Optional, default is 8080
})

Main events can be listened to:

server.onStart((settings) => {
  console.log('Server started')
  console.log('Base path is:', settings.basePath)
  console.log('Port is:', settings.httpPort)
  console.log('Available URLs:', settings.urls.join(', '))
})
server.onStop(() => {
  console.log('Server stopped')
})
server.onResponse((response) => {
  console.log('Requested path was:', response.requestedPath)
  console.log('Requested method was:', response.requestedMethod)
  console.log('Response code is:', response.httpCode)
})
server.onError((error) => {
  console.log('Server error', error)
})

After event listeners have been attached if needed, start the server:

server.start()

And stop:

server.stop()

Changelog

This project uses semver.

| Version | Date | Notes | | --- | --- | --- | | 2.1.0 | 2023-1-07 | Support Range request header | | 2.0.1 | 2023-02-12 | Fix onResponse event for favicons | | 2.0.0 | 2023-02-04 | Expose node moduleDrop Node 12 support | | 1.4.0 | 2023-01-29 | Improve startup info | | 1.3.0 | 2023-01-28 | Support more mime types | | 1.2.0 | 2022-01-10 | Update UI (#1) | | 1.1.0 | 2021-09-25 | Stop relying on deprecated url.parse() | | 1.0.1 | 2021-07-04 | Fix execution issue on Unix | | 1.0.0 | 2021-07-04 | Initial version |

License

This project is released under the MIT License.