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

nohost

v1.1.4

Published

A web server in your web browser

Downloads

12

Readme

nohost

A web server in your web browser.

Overview

nohost uses Filer to run a node'js style, POSIX filesystem inside a Service Worker, and handle requests for static files and directories.

The most likely use case for nohost would be an app that uses Filer to run a filesystem in the window, and then use nohost to provide a way to interact with that filesystem in the browser via URLs, like one would with Apache or another web server hosting static files.

Example

NOTE: I don't currently have a full demo up (TODO), so the default filesystem is empty. My plan is to rework this into a module people can include along with Filer to allow self-hosting of static files in the browser.

Until then, here's what nohost looks like running with a fileystem manually created:

Example running

Clicking a link does what you'd expect, serving the file to the browser via the Service Worker.

Installation

To run it:

npm install
npm run build

The nohost Service Worker will be built in dist/nohost-sw.js. NOTE: you can also use npm run dev to also start a web server.

Now register nohost's Service Worker in your app at startup:

if(!('serviceWorker' in navigator)) {
  console.warn('unable to initialize nohost service worker: not supported.');
} else {
  navigator.serviceWorker
    .register('./nohost-sw.js') // see configuration options below
    .catch(err => {
      console.error(`unable to register nohost service worker: ${err.message}`);
    });
}

Configure Web Server

Various features of the nohost web server can be configured by passing options on the query string when registering the nohost-sw.js Service Worker:

  • route (String): with the route name to use when listening for filesystem path requests. Defaults to fs, such that /fs/path/to/file would respond with /path/to/file

  • disableIndexes (Boolean, present or absent): directory indexes (i.e., listings) will not be shown. By default they will be shown. If defined, users will have to know the filename they wish to get back from the server.

  • directoryIndex (String): overrides the default directory index filename, used when a directory path is given. Defautls to index.html. For example, /fs/ would return /fs/index.html by default (if present). If another name is specified here, that filename will be used instead.

For example:

// Use /www for the server route, and disable directory listings
navigator.serviceWorker
  .register('./nohost-sw.js?route=www&disableIndexes');

Browse Filesystem

After the Service Worker is installed, you can then browse into the filesystem via the specified route (defaults to /fs/*). For example, if running the demo: http://localhost:8080/fs/*, where /* is a path into the filesystem.

To get metadata about files/directories vs. contents, add ?json to the URL. For example: http://localhost:8080/fs/dir?json

To download instead of view files in the browser, add ?download or ?dl to the URL. For example: http://localhost:8080/fs/path/to/file.png?dl