Skip to content

Instantly share code, notes, and snippets.

@tkissing
Last active August 29, 2015 14:07
Show Gist options
  • Save tkissing/dacc9e3e9dbbede84296 to your computer and use it in GitHub Desktop.
Save tkissing/dacc9e3e9dbbede84296 to your computer and use it in GitHub Desktop.
serve-it - an easy-to-use local http(s) server

A global npm command serve-it that takes a "virtual url path" with an optional port and an optional path (defaulting to cwd). The command starts up an http server (optionally: https) and adds the required configuration to serve the files in that folder (recursively). If the server is already running, it just reconfigures the server at runtime.

Examples:

  • serve-it foo:8081 // serves current working directory at http://localhost:8081/foo
  • serve-it --save bar ./bar/src // serves ./bar/src at http://localhost:$PORT/bar with $PORT being default port from ~/.serve-it/config.json or 8080 if not configured; persists to ~/.serve-it/config.json

An optional --save adds the configuration to ~/.serve-it/config.json Anytime the runtime configuration changes, it is also written to ~/.serve-it/.runtime.json - allowing to restore the last configuration after a crash using a command like serve-it --restore

Every configuration entry in ~/.serve-it/config.json can have an optional tags property, an array of strings. Using a command like serve-it --tags=foo,bar the server will start up/reconfigure such that only matching entries from the configuration are active

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment