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

handydevserver

v1.0.9

Published

A simple web server with handy hooks for setting up test environments for web development.

Downloads

12

Readme

HandyDevServer

A simple web server with handy hooks for setting up test environments for web development. ###Installation   npm version

npm install handydevserver

###Simple Usage Call the constructor with a port to run on, and an array of folders to look for files in.

var handydevserver = require("handydevserver");
// Add three folders to the common directory.
// Run on port 8080
handydevserver(8080, ['./dist', './smoketest', './gateway'])

###Simulated server delay To simulate latency, add a latency attribute with a delay value (in ms):

handydevserver(8080, ['./dist', './smoketest', './gateway'], {
    latency: 2500
})

If you want to randomize the latency, provide an array of two values and the latency will be randomized somewhere in between:

handydevserver(8080, ['./dist', './smoketest', './gateway'], {
    latency: [500, 2500]
})

###Ignore files/folders To remove certain files or folders for directory listings, add an ignore array of strings. These are wildcards, so if you specify the string "hello" it would ignore things like: "hello_world", "hello_america", etc:

handydevserver(8080, ['./dist', './smoketest', './gateway'], {
    ignore: ['node_modules', '.svn']
})

###Hooks You can intercept text files (CSS, HTML, JS, etc) before they get delivered to the browser incase you want to change them. To do this, pass a config object to your call to the constructor:

handydevserver(
    8080,
   ['./dist', './smoketest', './gateway'],
    {
      ontextfile: function (filename, contents, headers) {
        if (filename.indexOf('gateway.js') || filename.indexOf('gateway.min.js')) {
          contents = contents.replace(/foo/gi, "bar");
        }
        // Add some header
        headers.myHeader = 'some header value';
        return contents;
      },
      onhtmlfile: function(filename, contents, headers) {
        // an HTML file is being served
        // Do whatever changes you want
        return contents;
      },
      onjsfile: function(filename, contents, headers) {
        // a JavaScript file is being served
        // Do whatever changes you want
        return contents;
      }
    });

###Custom Headers You can add your own custom headers to responses by adding a headers object to your configuration:

handydevserver(
    8080,
   ['./dist', './smoketest', './gateway'],
    {
      headers: {'mycustomheader':'somevalue'}
    });

###SSL You can also run an HTTPS server by using the self-signed cert feature. Note: you will need to add an exception to any certificate errors that occur in your browser.

handydevserver(443, [/*dirs*/], { ssl: true });