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 🙏

© 2025 – Pkg Stats / Ryan Hefner

http-fs

v0.0.11

Published

HTTP server for file serving

Downloads

41

Readme

Simple static HTTP file server

Serves files from a given path. Uses Node streams for low memory usage and no dependencies on third party modules.

Clone

git clone https://github.com/varadero/http-fs.git cd http-fs

Install

npm install

Build

The source code is written in TypeScript so it must be build before use:

npm run build

Application files can be found in dist folder

Usage

After the application is build, execute this from any folder:

node path/to/http-fs/dist/index.js --path path/to/folder/to/serve

This will serve files in specified directory in the --path parameter.

Command line parameters:

  • --path - Root path to be served. Can be either relative or absolute. Defaults to . (if not provided, current directory will be served). Can contain only Windows-style (%NAME%) environment variables.
  • --host - Host or IP at which to listen. Defaults to 127.0.0.1.
  • --port - Port at which to listen. Defaults to 80 if --use-ssl is not provided and 443 if --use-ssl is provided.
  • --default-file-name - The default file name to serve if the URL is a folder. Defaults to index.html. To switch off default file serving, set it to empty string inside quotes - --default-file-name ""
  • --not-found-file - The file which must be served in case the requested file cannot be found. Can contain environment variables.
  • --use-ssl - If provided, files will be served over HTTPS.
  • --ssl-cert-file - Points to a file containing the certificate. Defaults to cert.pem. Can contain environment variables.
  • --ssl-key-file - Points to a file containing the certificate key. Defaults to key.pem. Can contain environment variables.
  • --mime-map-file - Points to a JSON file containing MIME map. Can contain only Windows-style (%NAME%) environment variables.
  • --mime-map - JSON (special characters like double quotes must be escaped - \") representing MIME map of file extensions (without the dot in front of the extension) and HTTP Content-Type header value. The entries in the default MIME map with the same key as these provided in --mime-map will be overwritten. Defaults to empty JSON. Default MIME map contains the following entries:
{
    "css": "text/css",
    "html": "text/html",
    "ico": "image/x-icon",
    "jpeg": "image/jpeg",
    "jpg": "image/jpeg",
    "js": "application/javascript",
    "json": "application/json",
    "otf": "font/otf",
    "png": "image/png",
    "ttf": "font/ttf",
    "txt": "text/plain",
    "woff": "font/woff",
    "woff2": "font/woff2",
    ".": "application/octet-stream",
    "*": "application/octet-stream"
}
  • --log-events - Logs some of the request and response events

MIME map specifics

  • Files without extensions are referenced with . map
  • File extensions not specified are referenced with * map
  • All file extensions that map to empty content type will not be served (404 Not Found will be returned). The logic for finding content type is the following: If the file extension exists in the mapping - use its content type, if it doesn't exists - use content type specified in * map
  • If all not specified file extesions must be disabled, set * map to empty string. This will constrain http-fs to serve only file extensions specified in the MIME map (which does not map to empty strings)

Samples

  • Serve path ./dist at http://localhost with default file index.html with sample log output:

node path/to/http-fs/dist/index.js --path ./dist --log-events

  • Serve absolutely specified directory

node path/to/http-fs/dist/index.js --path "c:/some/path/to/web files"

  • Serve relatively specified directory

node path/to/http-fs/dist/index.js --path ./dist

node path/to/http-fs/dist/index.js --path ../../webapp

  • Serve with Windows-style envionment variable in the path

node path/to/http-fs/dist/index.js --path %WEBAPP_FOLDER%

node path/to/http-fs/dist/index.js --path ../../webapps/%WEBAPP_NAME%/dist

  • Serve without default file so trying to access a folder will result in HTTP 404 Not Found:

node path/to/http-fs/dist/index.js --default-file-name ""

  • Serve specified file if requested is not found. Can be used for SPA applications so when the browser is refreshed while at some route URL, the application will be loaded from specified HTML file keeping the URL in the browser

node path/to/http-fs/dist/index.js --not-found-file ./index.html

  • Serve at specific IP and port

node path/to/http-fs/dist/index.js --host 192.168.0.1 --port 12345

  • Serve with HTTPS using the default files cert.pem and key.pem in current folder (you can create .pem files using openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem)

node path/to/http-fs/dist/index.js --use-ssl

  • Serve with HTTPS specifying certificate .pem files

node path/to/http-fs/dist/index.js --use-ssl --ssl-cert-file "C:\some path\to\certificate files\cert.pem" --ssl-key-file "C:\some path\to\certificate files\key.pem"

  • Serve with MIME map overwrites provided as JSON file

node path/to/http-fs/dist/index.js --mime-map-file path/to/mime-map.json

  • Serve with MIME map overwrites provided as argument (js:text/plain overwriting exiting js:application/javascript and added htm:text/html)

node path/to/http-fs/dist/index.js --mime-map "{\"js\":\"text/plain\",\"htm\":\"text/html\"}"

  • Serve with MIME map disabling ttf files ("ttf":"")

node path/to/http-fs/dist/index.js --mime-map "{\"ttf\":\"\"}"

  • Serve with MIME map disabling all non-specified files ("*":"")

node path/to/http-fs/dist/index.js --mime-map "{\"*\":\"\"}"