HandyDevServer
A simple web server with handy hooks for setting up test environments for web development.
Installation
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 = ;// Add three folders to the common directory.// Run on port 8080
Simulated server delay
To simulate latency, add a latency
attribute with a delay value (in ms):
If you want to randomize the latency, provide an array of two values and the latency will be randomized somewhere in between:
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:
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:
;
Custom Headers
You can add your own custom headers to responses by adding a headers
object to your configuration:
;
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.
;