***Requires node v4.0.0 or higher. Install the [previous release](https://github.com/75lb/local-web-server/tree/prev) for older node support.***
***Requires node v4.0.0 or higher. Install the [previous release](https://github.com/75lb/local-web-server/tree/prev) for older node support.***
# local-web-server
# local-web-server
A simple, extensible web-server for productive front-end development. Typical use cases:
An application shell for building a simple, command-line web server for productive web development.
* Front-end Development
* Static or Single Page App development
* Re-route paths to local or remote resources
* Efficient, predictable, entity-tag-powered conditional request handling (no need to 'Disable Cache' in DevTools, slowing page-load down)
It is trivial is bundle and deploy with your project. Also deploys to heroku well for demo projects.
It comes with some middleware built-in, which you need not use but will get you up and running for the following use cases:
* Static or Single Page Application front-end development where you have
* No backend, an existing remote API or need to mock-up an API.
Application Shell
* HTTP or HTTPS server
* HTTPS is strictly required by some modern techs (ServiceWorker, Media Capture and Streams etc.)
* Add your middleware
* Use any combination of built-in and custom middleware
* specify options (for command line or config)
* Accepts Koa v1 or 2 middleware
* Bundle with your front-end project
* Bundle with your front-end project
* Very little configuration, just a few options
* Configuration is via json file or command-line (latter taking presedence)
* Outputs a dynamic statistics view to the terminal
* Outputs a dynamic statistics view to the terminal
Built-in Middleware (all optional)
* 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](https://github.com/75lb/local-web-server/blob/master/doc/visualisation.md)
* Configurable log output, compatible with [Goaccess, Logstalgia and glTail](https://github.com/75lb/local-web-server/blob/master/doc/visualisation.md)
* Proxy server
* Map local routes to remote servers. Removes CORS pain when consuming remote services.
* Back-end service mocking
* Back-end service mocking
* Prototype a web service, microservice, REST API etc.
* Prototype a web service, microservice, REST API etc.
* Mocks are defined with config (static), or code (dynamic).
* Mocks are defined with config (static), or code (dynamic).
* CORS-friendly, all origins allowed by default.
* CORS-friendly, all origins allowed by default.
* Proxy server
* Map local routes to remote servers. Removes CORS pain when consuming remote services.
* HTTPS server
* HTTPS is strictly required by some modern techs (ServiceWorker, Media Capture and Streams etc.)
* File sharing
## Synopsis
## Synopsis
local-web-server is a simple command-line tool. To use it, from your project directory run `ws`.
local-web-server is a command-line tool. To serve the current directory, run `ws`.
<pre><code>$ ws --help
<pre><code>$ ws --help
@ -84,7 +96,7 @@ For the examples below, we assume we're in a project directory looking like this
└── package.json
└── package.json
```
```
**All paths/routes are specified using [express syntax](http://expressjs.com/guide/routing.html#route-paths)**. To run the example projects linked below, clone the project, move into the example directory specified, run `ws`.
All paths/routes are specified using [express syntax](http://expressjs.com/guide/routing.html#route-paths). To run the example projects linked below, clone the project, move into the example directory specified, run `ws`.
### Static site
### Static site
@ -585,63 +597,7 @@ serving at http://localhost:8100
- [.forbid] <code>Array.<string></code> - A list of forbidden routes, each route being an [express route-path](http://expressjs.com/guide/routing.html#route-paths).
- [.spa] <code>string</code> - specify an SPA file to catch requests for everything but static assets.
***Requires node v4.0.0 or higher. Install the [previous release](https://github.com/75lb/local-web-server/tree/prev) for older node support.***
***Requires node v4.0.0 or higher. Install the [previous release](https://github.com/75lb/local-web-server/tree/prev) for older node support.***
# local-web-server
# local-web-server
A simple web-server for productive front-end development. Typical use cases:
An application shell for building a simple, command-line web server for productive web development.
* Front-end Development
* Static or Single Page App development
* Re-route paths to local or remote resources
* Efficient, predictable, entity-tag-powered conditional request handling (no need to 'Disable Cache' in DevTools, slowing page-load down)
It is trivial is bundle and deploy with your project. Also deploys to heroku well for demo projects.
It comes with some middleware built-in, which you need not use but will get you up and running for the following use cases:
* Static or Single Page Application front-end development where you have
* No backend, an existing remote API or need to mock-up an API.
Application Shell
* HTTP or HTTPS server
* HTTPS is strictly required by some modern techs (ServiceWorker, Media Capture and Streams etc.)
* Add your middleware
* Use any combination of built-in and custom middleware
* specify options (for command line or config)
* Accepts Koa v1 or 2 middleware
* Bundle with your front-end project
* Bundle with your front-end project
* Very little configuration, just a few options
* Configuration is via json file or command-line (latter taking presedence)
* Outputs a dynamic statistics view to the terminal
* Outputs a dynamic statistics view to the terminal
Built-in Middleware (all optional)
* 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](https://github.com/75lb/local-web-server/blob/master/doc/visualisation.md)
* Configurable log output, compatible with [Goaccess, Logstalgia and glTail](https://github.com/75lb/local-web-server/blob/master/doc/visualisation.md)
* Proxy server
* Map local routes to remote servers. Removes CORS pain when consuming remote services.
* Back-end service mocking
* Back-end service mocking
* Prototype a web service, microservice, REST API etc.
* Prototype a web service, microservice, REST API etc.
* Mocks are defined with config (static), or code (dynamic).
* Mocks are defined with config (static), or code (dynamic).
* CORS-friendly, all origins allowed by default.
* CORS-friendly, all origins allowed by default.
* Proxy server
* Map local routes to remote servers. Removes CORS pain when consuming remote services.
* HTTPS server
* HTTPS is strictly required by some modern techs (ServiceWorker, Media Capture and Streams etc.)
* File sharing
## Synopsis
## Synopsis
local-web-server is a simple command-line tool. To use it, from your project directory run `ws`.
local-web-server is a command-line tool. To serve the current directory, run `ws`.