You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Lloyd Brookes 24e8a2c0bb remove padEnd 7 years ago
bin switch to using lws.. clean up 7 years ago
doc server now created on contruction, before views intantiated.. refactor view API 8 years ago
example use lws packages 7 years ago
jsdoc2md docs 8 years ago
lib use lws packages 7 years ago
test server now created on contruction, before views intantiated.. refactor view API 8 years ago
.coveralls.yml docs.. tidy.. examples.. --rewrite 9 years ago
.gitignore mock responses.. example 9 years ago
.travis.yml switch to using lws.. clean up 7 years ago
LICENSE switch to using lws.. clean up 7 years ago
README.md switch to using lws.. clean up 7 years ago
package.json use lws packages 7 years ago

README.md

view on npm npm module downloads Build Status Dependency Status js-standard-style Join the chat at https://gitter.im/75lb/local-web-server

Requires node v4.0.0 or higher. Install the previous release for older node support.

local-web-server

At its core, local-web-server is an application shell for building a specialised command-line web server to support productive Web Platform engineers. When combined with built-in and custom features it's in intended to by a powerful tool in helping build and debug Web applications. It comes bundled with a middleware stack covering common requirements but any arbitrary stack can be specified from the command line or config.

Being an npm module, it is trivial is bundle and distribute/deploy with your web application.

Typically used for building:

  • Simple static site
  • Single Page Application
    • Works well with React, Angular or vanilla JS.

Backend scenarios covered:

  • Existing API
  • Mock API
  • Websocket server

Server options

  • HTTP or HTTPS server
    • HTTPS is strictly required by some modern techs (ServiceWorker, Media Capture and Streams etc.)
  • Configurable middleware stack
    • Use any combination of built-in and custom middleware
    • specify options (for command line or config)
    • Accepts Koa v1 or 2 middleware

Built-in Middleware stack

  • Rewrite routes to local or remote resources
  • Efficient, predictable, entity-tag-powered conditional request handling (no need to 'Disable Cache' in DevTools, slowing page-load down)
  • Configurable log output, compatible with Goaccess, Logstalgia and glTail
  • Proxy server
    • Map local routes to remote servers. Removes CORS pain when consuming remote services.
  • Back-end service mocking
    • Prototype a web service, microservice, REST API etc.
    • Mocks are defined with config (static), or code (dynamic).
  • CORS-friendly, all origins allowed by default.

Personalised stack

Synopsis

local-web-server is a command-line tool. To serve the current directory, run ws.

$ ws --help

local-web-server

  A simple web-server for productive front-end development.

Synopsis

  $ ws [--verbose] [] []
  $ ws --config
  $ ws --help

Server

  -p, --port number   Web server port.
  --key file          SSL key. Supply along with --cert to launch a https server.
  --cert file         SSL cert. Supply along with --key to launch a https server.
  --https             Enable HTTPS using a built-in key and cert, registered to the domain
                      127.0.0.1.

Middleware

  -r, --rewrite expression ...   A list of URL rewrite rules. For each rule, separate the 'from' and 'to'
                                 routes with '->'. Whitespace surrounded the routes is ignored. E.g. '/from ->
                                 /to'.
  -b, --forbid path ...          A list of forbidden routes.
  -n, --no-cache                 Disable etag-based caching -forces loading from disk each request.
  -c, --compress                 Serve gzip-compressed resources, where applicable.
  -f, --log.format string        If a format is supplied an access log is written to stdout. If not, a dynamic
                                 statistics view is displayed. Use a preset ('none', 'dev','combined',
                                 'short', 'tiny' or 'logstalgia') or supply a custom format (e.g. ':method ->
                                 :url').
  -s, --spa file                 Path to a Single Page App, e.g. app.html.
  -d, --directory path           Root directory, defaults to the current directory.

Misc

  -h, --help    Print these usage instructions.
  --config      Print the stored config.

  Project home: https://github.com/75lb/local-web-server

Install

$ npm install -g local-web-server

© 2013-17 Lloyd Brookes 75pound@gmail.com. Documented by jsdoc-to-markdown.