docs
This commit is contained in:
98
README.md
98
README.md
@ -25,7 +25,7 @@ Application Shell
|
|||||||
* specify options (for command line or config)
|
* specify options (for command line or config)
|
||||||
* Accepts Koa v1 or 2 middleware
|
* Accepts Koa v1 or 2 middleware
|
||||||
* Bundle with your front-end project
|
* Bundle with your front-end project
|
||||||
* Configuration is via json file or command-line (latter taking presedence)
|
* Configuration is via json file or command-line (latter taking precedence)
|
||||||
* Outputs a dynamic statistics view to the terminal
|
* Outputs a dynamic statistics view to the terminal
|
||||||
|
|
||||||
|
|
||||||
@ -51,30 +51,32 @@ local-web-server is a command-line tool. To serve the current directory, run `ws
|
|||||||
|
|
||||||
<strong>Synopsis</strong>
|
<strong>Synopsis</strong>
|
||||||
|
|
||||||
$ ws [<server options>]
|
$ ws [--verbose] [<server options>] [<middleware options>]
|
||||||
$ ws --config
|
$ ws --config
|
||||||
$ ws --help
|
$ ws --help
|
||||||
|
|
||||||
<strong>Server</strong>
|
<strong>Server</strong>
|
||||||
|
|
||||||
-p, --port number Web server port.
|
-p, --port number Web server port.
|
||||||
-d, --directory path Root directory, defaults to the current directory.
|
--key file SSL key. Supply along with --cert to launch a https server.
|
||||||
-f, --log-format string If a format is supplied an access log is written to stdout. If
|
--cert file SSL cert. Supply along with --key to launch a https server.
|
||||||
not, a dynamic statistics view is displayed. Use a preset ('none',
|
--https Enable HTTPS using a built-in key and cert, registered to the domain
|
||||||
'dev','combined', 'short', 'tiny' or 'logstalgia') or supply a
|
127.0.0.1.
|
||||||
custom format (e.g. ':method -> :url').
|
|
||||||
-r, --rewrite expression ... A list of URL rewrite rules. For each rule, separate the 'from'
|
<strong>Middleware</strong>
|
||||||
and 'to' routes with '->'. Whitespace surrounded the routes is
|
|
||||||
ignored. E.g. '/from -> /to'.
|
-r, --rewrite expression ... A list of URL rewrite rules. For each rule, separate the 'from' and 'to'
|
||||||
-s, --spa file Path to a Single Page App, e.g. app.html.
|
routes with '->'. Whitespace surrounded the routes is ignored. E.g. '/from ->
|
||||||
-c, --compress Serve gzip-compressed resources, where applicable.
|
/to'.
|
||||||
-b, --forbid path ... A list of forbidden routes.
|
-b, --forbid path ... A list of forbidden routes.
|
||||||
-n, --no-cache Disable etag-based caching -forces loading from disk each request.
|
-n, --no-cache Disable etag-based caching -forces loading from disk each request.
|
||||||
--key file SSL key. Supply along with --cert to launch a https server.
|
-c, --compress Serve gzip-compressed resources, where applicable.
|
||||||
--cert file SSL cert. Supply along with --key to launch a https server.
|
-f, --log-format string If a format is supplied an access log is written to stdout. If not, a dynamic
|
||||||
--https Enable HTTPS using a built-in key and cert, registered to the
|
statistics view is displayed. Use a preset ('none', 'dev','combined',
|
||||||
domain 127.0.0.1.
|
'short', 'tiny' or 'logstalgia') or supply a custom format (e.g. ':method ->
|
||||||
--verbose Verbose output, useful for debugging.
|
:url').
|
||||||
|
-s, --spa file Path to a Single Page App, e.g. app.html.
|
||||||
|
-d, --directory path Root directory, defaults to the current directory.
|
||||||
|
|
||||||
<strong>Misc</strong>
|
<strong>Misc</strong>
|
||||||
|
|
||||||
@ -108,72 +110,12 @@ serving at http://localhost:8000
|
|||||||
|
|
||||||
[Example](https://github.com/75lb/local-web-server/tree/master/example/simple).
|
[Example](https://github.com/75lb/local-web-server/tree/master/example/simple).
|
||||||
|
|
||||||
### Other usage
|
|
||||||
|
|
||||||
#### Debugging
|
|
||||||
|
|
||||||
Prints information about loaded middleware, arguments, remote proxy fetches etc.
|
|
||||||
```sh
|
|
||||||
$ ws --verbose
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Compression
|
|
||||||
|
|
||||||
Serve gzip-compressed resources, where applicable
|
|
||||||
```sh
|
|
||||||
$ ws --compress
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Disable caching
|
|
||||||
|
|
||||||
Disable etag response headers, forcing resources to be served in full every time.
|
|
||||||
```sh
|
|
||||||
$ ws --no-cache
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Log Visualisation
|
|
||||||
Instructions for how to visualise log output using goaccess, logstalgia or gltail [here](https://github.com/75lb/local-web-server/blob/master/doc/visualisation.md).
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`.
|
Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ npm install -g local-web-server
|
$ npm install -g local-web-server
|
||||||
```
|
```
|
||||||
|
|
||||||
## Distribute with your project
|
|
||||||
The standard convention with client-server applications is to add an `npm start` command to launch the server component.
|
|
||||||
|
|
||||||
1\. Install the server as a dev dependency
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ npm install local-web-server --save-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
2\. Add a `start` command to your `package.json`:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"name": "example",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"local-web-server": {
|
|
||||||
"port": 8100,
|
|
||||||
"forbid": "*.json"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"start": "ws"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
3\. Document how to build and launch your site
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ npm install
|
|
||||||
$ npm start
|
|
||||||
serving at http://localhost:8100
|
|
||||||
```
|
|
||||||
|
|
||||||
* * *
|
* * *
|
||||||
|
|
||||||
© 2013-16 Lloyd Brookes <75pound@gmail.com>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
|
© 2013-16 Lloyd Brookes <75pound@gmail.com>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
|
||||||
|
32
doc/distribute.md
Normal file
32
doc/distribute.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
## Distribute with your project
|
||||||
|
The standard convention with client-server applications is to add an `npm start` command to launch the server component.
|
||||||
|
|
||||||
|
1\. Install the server as a dev dependency
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install local-web-server --save-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
2\. Add a `start` command to your `package.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "example",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"local-web-server": {
|
||||||
|
"port": 8100,
|
||||||
|
"forbid": "*.json"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "ws"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3\. Document how to build and launch your site
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install
|
||||||
|
$ npm start
|
||||||
|
serving at http://localhost:8100
|
||||||
|
```
|
Reference in New Issue
Block a user