From 68cc2864dc5a36a7ea511d98009d243ff3bbdf89 Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Mon, 16 Nov 2015 10:30:04 +0000 Subject: [PATCH] docs, examples --- README.md | 49 ++++++++++++++++++++++++++++--------- example/simple/package.json | 7 ++++++ jsdoc2md/README.hbs | 49 ++++++++++++++++++++++++++++--------- test/fixture/.local-web-server.json | 2 +- 4 files changed, 82 insertions(+), 25 deletions(-) create mode 100644 example/simple/package.json diff --git a/README.md b/README.md index 47d9b59..501dc0e 100644 --- a/README.md +++ b/README.md @@ -10,52 +10,77 @@ A simple web-server for productive front-end development. **Requires node v4.0.0 or higher**. ## Synopsis -Some typical use cases.. +Some typical use cases. For these examples, assume we're in our site directory, which looks like: -### Static site -Fire up your site on the default port: ```sh $ tree . ├── css │   └── style.css -└── index.html +├── index.html +└── package.json +``` +### Static site + +Fire up your static site on the default port: +```sh $ ws serving at http://localhost:8000 ``` ### Single Page Application -Mark `index.html` as an SPA with client-side routing. +You're building a web app with client-side routing, so mark `index.html` as the SPA. ```sh $ ws --spa index.html ``` With this option, routes with existing files (e.g. `/css/style.css`) will be served normally as static assets. Routes without an existing file (e.g. `/user/1`, `/login` etc.) are passed directly to your SPA. Without this option they would 404. +### Access Control -Blacklist certain paths, for example config files: +Access to all files is allowed, beside those you forbid (e.g. config files): ```sh $ ws --forbid .json .yml serving at http://localhost:8000 ``` -Reduce bandwidth with gzip compression: -```sh -$ ws --compress -``` +### URL rewriting When urls don't map to your directory structure, rewrite: ```sh $ ws --rewrite /css=>/build/css ``` -Rewrite to remote servers: +Rewrite to remote servers (proxy): ```sh -$ ws --rewrite /api=>http://api.example.com/api /npm=>http://registry.npmjs.com +$ ws --rewrite "/api => http://api.example.com/api" \ + "/npm => http://registry.npmjs.com" \ + "/user/:project/repo -> https://api.github.com/repos/:project" ``` +### Mock Responses + +### Stored config + +Always use this port and blacklist? Persist it to the config: +```json +{ + "name": "example", + "version": "1.0.0", + etc, + etc, + "local-web-server": { + "port": 8100, + "forbid": "\\.json$" + } +} +``` + +### Other features + +Compression, caching, simple statistics view, log, override mime types. ## Install Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`. diff --git a/example/simple/package.json b/example/simple/package.json new file mode 100644 index 0000000..03e697a --- /dev/null +++ b/example/simple/package.json @@ -0,0 +1,7 @@ +{ + "name": "example", + "version": "1.0.0", + "local-web-server": { + "port": 8100 + } +} diff --git a/jsdoc2md/README.hbs b/jsdoc2md/README.hbs index 3d7ca17..feb5158 100644 --- a/jsdoc2md/README.hbs +++ b/jsdoc2md/README.hbs @@ -10,52 +10,77 @@ A simple web-server for productive front-end development. **Requires node v4.0.0 or higher**. ## Synopsis -Some typical use cases.. +Some typical use cases. For these examples, assume we're in our site directory, which looks like: -### Static site -Fire up your site on the default port: ```sh $ tree . ├── css │   └── style.css -└── index.html +├── index.html +└── package.json +``` +### Static site + +Fire up your static site on the default port: +```sh $ ws serving at http://localhost:8000 ``` ### Single Page Application -Mark `index.html` as an SPA with client-side routing. +You're building a web app with client-side routing, so mark `index.html` as the SPA. ```sh $ ws --spa index.html ``` With this option, routes with existing files (e.g. `/css/style.css`) will be served normally as static assets. Routes without an existing file (e.g. `/user/1`, `/login` etc.) are passed directly to your SPA. Without this option they would 404. +### Access Control -Blacklist certain paths, for example config files: +Access to all files is allowed, beside those you forbid (e.g. config files): ```sh $ ws --forbid .json .yml serving at http://localhost:8000 ``` -Reduce bandwidth with gzip compression: -```sh -$ ws --compress -``` +### URL rewriting When urls don't map to your directory structure, rewrite: ```sh $ ws --rewrite /css=>/build/css ``` -Rewrite to remote servers: +Rewrite to remote servers (proxy): ```sh -$ ws --rewrite /api=>http://api.example.com/api /npm=>http://registry.npmjs.com +$ ws --rewrite "/api => http://api.example.com/api" \ + "/npm => http://registry.npmjs.com" \ + "/user/:project/repo -> https://api.github.com/repos/:project" ``` +### Mock Responses + +### Stored config + +Always use this port and blacklist? Persist it to the config: +```json +{ + "name": "example", + "version": "1.0.0", + etc, + etc, + "local-web-server": { + "port": 8100, + "forbid": "\\.json$" + } +} +``` + +### Other features + +Compression, caching, simple statistics view, log, override mime types. ## Install Ensure [node.js](http://nodejs.org) is installed first. Linux/Mac users may need to run the following commands with `sudo`. diff --git a/test/fixture/.local-web-server.json b/test/fixture/.local-web-server.json index 99cbae7..8858020 100644 --- a/test/fixture/.local-web-server.json +++ b/test/fixture/.local-web-server.json @@ -2,7 +2,7 @@ "mime": { "text/plain": [ "php" ] }, - "blacklist": [ + "forbid": [ "php$" ] }