docs
This commit is contained in:
41
README.md
41
README.md
@ -9,27 +9,28 @@
|
|||||||
|
|
||||||
# local-web-server
|
# local-web-server
|
||||||
|
|
||||||
The modular web server for productive full-stack development.
|
A modular HTTP, HTTPS and HTTP2 command-line web server for productive full-stack development. Local-web-server is a distribution of [lws](https://github.com/lwsjs/lws) bundled with a "starter pack" of useful middleware.
|
||||||
|
|
||||||
Use this tool to:
|
Use this tool to:
|
||||||
|
|
||||||
* Build any flavour of web application (static site, dynamic site with client or server-rendered content, Single Page App, Progessive Web App, Angular or React app etc.)
|
* Help build any flavour of front-end web application
|
||||||
* Prototype any CORS-enabled back-end service (e.g. RESTful HTTP API or Microservice using websockets, Server Sent Events etc.)
|
* *Static site, dynamic site with client or server-rendered content, Single Page App, Progessive Web App, Angular or React app etc.*
|
||||||
* Monitor activity, analyse performance, experiment with caching strategies etc.
|
* Prototype a CORS-enabled back-end service
|
||||||
* Build your own, personalised CLI web server tool
|
* *RESTful HTTP API, microservice, websocket server, Server Sent Events service etc.*
|
||||||
|
* Monitor activity, analyse performance, fine-tune caching strategy etc.
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
* Modular, extensible and easy to personalise. Create, share and consume only plugins which match your requirements.
|
* Full control over the middleware stack
|
||||||
* Powerful, extensible command-line interface (add your own commands and options)
|
* Single Page Application (SPA) support
|
||||||
* HTTP, HTTPS and HTTP2 support (HTTP2 requires node v8.4.0 or above)
|
* URL Rewriting
|
||||||
* URL Rewriting to local or remote destinations
|
* Proxy requests to remote resources
|
||||||
* Single Page Application support
|
* HTTP Conditional Request support
|
||||||
* Response mocking
|
* Range request support
|
||||||
|
* Gzip response compression
|
||||||
|
* HTTP Basic Authentication
|
||||||
* Configurable access log
|
* Configurable access log
|
||||||
* Route blacklisting
|
* Route blacklisting and more
|
||||||
* HTTP Conditional and Range request support
|
|
||||||
* Gzip response compression, HTTP Basic Authentication and much more
|
|
||||||
|
|
||||||
## Synopsis
|
## Synopsis
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ This package installs the `ws` command-line tool (take a look at the [usage guid
|
|||||||
|
|
||||||
### Static web site
|
### Static web site
|
||||||
|
|
||||||
The most simple use case is to run `ws` without any arguments - this will **host the current directory as a static web site**. Navigating to the server will render a directory listing or your `index.html`, if that file exists.
|
Running `ws` without any arguments will host the current directory as a static web site. Navigating to the server will render a directory listing or your `index.html`, if that file exists.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ws
|
$ ws
|
||||||
@ -53,15 +54,15 @@ $ ws --spa index.html
|
|||||||
Serving at http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:8000
|
Serving at http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:8000
|
||||||
```
|
```
|
||||||
|
|
||||||
By default, requests for typical SPA paths (e.g. `/user/1`, `/login`) return `404 Not Found` as a file at that location does not exist. By marking `index.html` as the SPA you create this rule:
|
With a static site, requests for typical SPA paths (e.g. `/user/1`, `/login`) would return `404 Not Found` as a file at that location does not exist. However, by marking `index.html` as the SPA you create this rule:
|
||||||
|
|
||||||
*If a static file is requested (e.g. `/css/style.css`) then serve it, if not (e.g. `/login`) then serve the specified SPA and handle the route client-side.*
|
*If a static file is requested (e.g. `/css/style.css`) then serve it, if not (e.g. `/login`) then serve the specified SPA and handle the route client-side.*
|
||||||
|
|
||||||
[Read more](https://github.com/lwsjs/local-web-server/wiki/How-to-serve-a-Single-Page-Application-(SPA)).
|
[SPA tutorial](https://github.com/lwsjs/local-web-server/wiki/How-to-serve-a-Single-Page-Application-(SPA)).
|
||||||
|
|
||||||
### URL rewriting and proxied requests
|
### URL rewriting and proxied requests
|
||||||
|
|
||||||
Another common use case is to **re-route certain requests to a remote server** if, for example, you'd like to use data from a different environment. The following command would proxy requests with a URL beginning with `http://127.0.0.1:8000/api/` to `https://internal-service.local/api/`:
|
Another common use case is to forward certain requests to a remote server. The following command would proxy requests from any URL beginning with `/api/` to `https://internal-service.local/api/`. For example, a request to `/api/posts/1` would be proxied to `https://internal-service.local/api/posts/1`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ws --rewrite '/api/* -> https://internal-service.local/api/$1'
|
$ ws --rewrite '/api/* -> https://internal-service.local/api/$1'
|
||||||
@ -70,7 +71,7 @@ Serving at http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:80
|
|||||||
|
|
||||||
### HTTPS
|
### HTTPS
|
||||||
|
|
||||||
Launching a secure server is as simple as setting the `--https` flag. [See the wiki](https://github.com/lwsjs/local-web-server/wiki) for further configuration options and a guide on how to get the "green padlock" in your browser.
|
Launch a secure server by setting the `--https` flag. [See the wiki](https://github.com/lwsjs/local-web-server/wiki) for further configuration options and a guide on how to get the "green padlock" in your browser.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ws --https
|
$ ws --https
|
||||||
@ -79,7 +80,7 @@ Serving at https://mbp.local:8000, https://127.0.0.1:8000, https://192.168.0.100
|
|||||||
|
|
||||||
### HTTP2
|
### HTTP2
|
||||||
|
|
||||||
Uses node's built-in HTTP2 support. HTTP2 servers are always secure using local-web-server's built-in SSL certificates (by default) or those supplied by `--cert`, `--key` or `--pfx`. [See the wiki](https://github.com/lwsjs/local-web-server/wiki) for further info about HTTPS options and a guide on how to get the "green padlock" in your browser.
|
Uses node's built-in HTTP2 support. [See the wiki](https://github.com/lwsjs/local-web-server/wiki) for further info about HTTPS options and a guide on how to get the "green padlock" in your browser.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ws --http2
|
$ ws --http2
|
||||||
|
66
package-lock.json
generated
66
package-lock.json
generated
@ -1809,9 +1809,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lws": {
|
"lws": {
|
||||||
"version": "2.0.0-9",
|
"version": "2.0.0-10",
|
||||||
"resolved": "https://registry.npmjs.org/lws/-/lws-2.0.0-9.tgz",
|
"resolved": "https://registry.npmjs.org/lws/-/lws-2.0.0-10.tgz",
|
||||||
"integrity": "sha512-E4fBFt/uIQzoVIIzXK5FVCGfffAY+Z75pVjVWBVQjJRvd67+FfhtoKsiIkBKCq8K9QhUjUWu26hVTVsJKQk6TA==",
|
"integrity": "sha512-M6CSIQEMjxq7/hCOtpNDNLx4eDfZCWML6OHi0iUdup6D13TAySXWVZmnvPQTls5lkRV2OannfGMxLwKUdz2Heg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-escape-sequences": "^4.1.0",
|
"ansi-escape-sequences": "^4.1.0",
|
||||||
"array-back": "^3.1.0",
|
"array-back": "^3.1.0",
|
||||||
@ -1903,12 +1903,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lws-log": {
|
"lws-log": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/lws-log/-/lws-log-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/lws-log/-/lws-log-1.0.1.tgz",
|
||||||
"integrity": "sha512-bwH4PM5umVNU0V5TP6Ps/tSyjQ+YAILmQv/Fc/6cuG3LIAXnyjeIMfn8dT1Hw8434kHSkivdqArtnilNsMrqrw==",
|
"integrity": "sha512-dN50IuP7ro23rg06t0fp7PTZHiv2AI2F3Kj6Qj3uPgkTVVvR2T4UEnvhc9g7+6BLwAg429WfXo9STOWbE05vDA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"koa-morgan": "^1.0.1",
|
"koa-morgan": "^1.0.1",
|
||||||
"stream-log-stats": "^2.0.2"
|
"stream-log-stats": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lws-mime": {
|
"lws-mime": {
|
||||||
@ -1933,9 +1933,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lws-rewrite": {
|
"lws-rewrite": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/lws-rewrite/-/lws-rewrite-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/lws-rewrite/-/lws-rewrite-2.0.1.tgz",
|
||||||
"integrity": "sha512-R/r5o15Evlcqk+nop9tj+aLPl/2r5wztPb9EB/6XT7khZHDTeLRoj3nsc0MXk14KhvL4X/Hv+IR0URkQ3fFkAQ==",
|
"integrity": "sha512-IBIPnDKCwdvfkQWQFT2IHNwa4hjJqIXNspdPX3MBj2S9JhVE+EvvO0awzE3AHNwlBa+HJPYmVbtiSFwF4hNhAg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"array-back": "^3.1.0",
|
"array-back": "^3.1.0",
|
||||||
"koa-rewrite-75lb": "^3.0.1",
|
"koa-rewrite-75lb": "^3.0.1",
|
||||||
@ -2965,45 +2965,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stream-log-stats": {
|
"stream-log-stats": {
|
||||||
"version": "2.0.2",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/stream-log-stats/-/stream-log-stats-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/stream-log-stats/-/stream-log-stats-3.0.0.tgz",
|
||||||
"integrity": "sha512-b1LccxXhMlOQQrzSqapQHyZ3UI00QTAv+8VecFgsJz//sGB5LFl/+mkFeWBVVI2/E4DlCT4sGgvLExB/VTVFfA==",
|
"integrity": "sha512-rv7anqmc2fYKfCkLeISQbtw1ebyiapl34AltF04cknL/l1IGbffAB0DN2NvH3ec57kXwzJBOK6ZsjxP41Ai5IA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"JSONStream": "^1.3.1",
|
"JSONStream": "^1.3.5",
|
||||||
"ansi-escape-sequences": "^3.0.0",
|
"ansi-escape-sequences": "^4.1.0",
|
||||||
"byte-size": "^3.0.0",
|
"byte-size": "^5.0.1",
|
||||||
"common-log-format": "~0.1.3",
|
"common-log-format": "~0.1.4",
|
||||||
"lodash.throttle": "^4.1.1",
|
"lodash.throttle": "^4.1.1",
|
||||||
"stream-via": "^1.0.3",
|
"stream-via": "^1.0.4",
|
||||||
"table-layout": "~0.4.0"
|
"table-layout": "~0.4.4"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-escape-sequences": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-escape-sequences/-/ansi-escape-sequences-3.0.0.tgz",
|
|
||||||
"integrity": "sha1-HBg5S2r5t2/5pjUJ+kl2af0s5T4=",
|
|
||||||
"requires": {
|
|
||||||
"array-back": "^1.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"array-back": {
|
|
||||||
"version": "1.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz",
|
|
||||||
"integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=",
|
|
||||||
"requires": {
|
|
||||||
"typical": "^2.6.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"byte-size": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/byte-size/-/byte-size-3.0.0.tgz",
|
|
||||||
"integrity": "sha1-QG+eI2aqXav2NnLrKR17sJSV2nU="
|
|
||||||
},
|
|
||||||
"typical": {
|
|
||||||
"version": "2.6.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz",
|
|
||||||
"integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0="
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stream-read-all": {
|
"stream-read-all": {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
"index.js"
|
"index.js"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lws": "2.0.0-9",
|
"lws": "2.0.0-10",
|
||||||
"lws-basic-auth": "^1.0.2",
|
"lws-basic-auth": "^1.0.2",
|
||||||
"lws-blacklist": "^2.0.1",
|
"lws-blacklist": "^2.0.1",
|
||||||
"lws-body-parser": "^1.0.1",
|
"lws-body-parser": "^1.0.1",
|
||||||
@ -48,11 +48,11 @@
|
|||||||
"lws-cors": "^2.0.0",
|
"lws-cors": "^2.0.0",
|
||||||
"lws-index": "^1.0.2",
|
"lws-index": "^1.0.2",
|
||||||
"lws-json": "^1.0.0",
|
"lws-json": "^1.0.0",
|
||||||
"lws-log": "^1.0.0",
|
"lws-log": "^1.0.1",
|
||||||
"lws-mime": "^1.0.0",
|
"lws-mime": "^1.0.0",
|
||||||
"lws-range": "^2.0.0",
|
"lws-range": "^2.0.0",
|
||||||
"lws-request-monitor": "^1.0.3",
|
"lws-request-monitor": "^1.0.3",
|
||||||
"lws-rewrite": "^2.0.0",
|
"lws-rewrite": "^2.0.1",
|
||||||
"lws-spa": "^2.0.0",
|
"lws-spa": "^2.0.0",
|
||||||
"lws-static": "^1.1.0",
|
"lws-static": "^1.1.0",
|
||||||
"node-version-matches": "^1.0.1"
|
"node-version-matches": "^1.0.1"
|
||||||
|
Reference in New Issue
Block a user