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/fooserve-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