Lloyd Brookes
86b2b52291
|
8 years ago | |
---|---|---|
bin | 9 years ago | |
doc | 9 years ago | |
example | 9 years ago | |
jsdoc2md | 9 years ago | |
lib | 8 years ago | |
ssl | 9 years ago | |
test | 9 years ago | |
.coveralls.yml | 9 years ago | |
.gitignore | 9 years ago | |
.travis.yml | 9 years ago | |
LICENSE | 9 years ago | |
README.md | 9 years ago | |
package.json | 8 years ago |
README.md
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-16 Lloyd Brookes 75pound@gmail.com. Documented by jsdoc-to-markdown.