Browse Source

docs

master
Lloyd Brookes 9 years ago
parent
commit
e08dca08f7
  1. 28
      README.md
  2. 28
      jsdoc2md/README.hbs
  3. 2
      package.json

28
README.md

@ -10,10 +10,9 @@ A simple web-server for productive front-end development.
**Requires node v4.0.0 or higher**. **Requires node v4.0.0 or higher**.
## Synopsis ## Synopsis
Some typical use cases. For these examples, assume we're in our site directory, which looks like:
Some typical use cases. For these examples, assume we're in a site directory looking like this:
```sh ```sh
$ tree
. .
├── css ├── css
│   └── style.css │   └── style.css
@ -36,7 +35,7 @@ You're building a web app with client-side routing, so mark `index.html` as the
$ ws --spa index.html $ 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.
By default, typical SPA urls (e.g. `/user/1`, `/login`) would return `404 Not Found`. By marking `index.html` as the SPA you create this rule: *if a file with that url exists (e.g. `/css/style.css`) then serve it, if it does not (e.g. `/login`) then pass it to the SPA*.
### Access Control ### Access Control
@ -69,8 +68,6 @@ Always use this port and blacklist? Persist it to the config:
{ {
"name": "example", "name": "example",
"version": "1.0.0", "version": "1.0.0",
etc,
etc,
"local-web-server": { "local-web-server": {
"port": 8100, "port": 8100,
"forbid": "\\.json$" "forbid": "\\.json$"
@ -90,29 +87,32 @@ $ npm install -g local-web-server
``` ```
## Distribute with your project ## 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 ```sh
$ npm install local-web-server --save-dev $ npm install local-web-server --save-dev
``` ```
Then add an `start` script to your `package.json` (the standard npm approach):
2. Add a `start` command to your `package.json`:
```json ```json
{ {
"name": "my-web-app",
"name": "example",
"version": "1.0.0", "version": "1.0.0",
"local-web-server": {
"port": 8100,
"forbid": "\\.json$"
},
"scripts": { "scripts": {
"start": "ws" "start": "ws"
} }
} }
``` ```
This simplifies a rather specific-looking instruction set like:
```sh
$ npm install
$ npm install -g local-web-server
$ ws
```
3. Document how to build and launch your site
to the following, server implementation and launch details abstracted away:
```sh ```sh
$ npm install $ npm install
$ npm start $ npm start

28
jsdoc2md/README.hbs

@ -10,10 +10,9 @@ A simple web-server for productive front-end development.
**Requires node v4.0.0 or higher**. **Requires node v4.0.0 or higher**.
## Synopsis ## Synopsis
Some typical use cases. For these examples, assume we're in our site directory, which looks like:
Some typical use cases. For these examples, assume we're in a site directory looking like this:
```sh ```sh
$ tree
. .
├── css ├── css
│   └── style.css │   └── style.css
@ -36,7 +35,7 @@ You're building a web app with client-side routing, so mark `index.html` as the
$ ws --spa index.html $ 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.
By default, typical SPA urls (e.g. `/user/1`, `/login`) would return `404 Not Found`. By marking `index.html` as the SPA you create this rule: *if a file with that url exists (e.g. `/css/style.css`) then serve it, if it does not (e.g. `/login`) then pass it to the SPA*.
### Access Control ### Access Control
@ -69,8 +68,6 @@ Always use this port and blacklist? Persist it to the config:
{ {
"name": "example", "name": "example",
"version": "1.0.0", "version": "1.0.0",
etc,
etc,
"local-web-server": { "local-web-server": {
"port": 8100, "port": 8100,
"forbid": "\\.json$" "forbid": "\\.json$"
@ -90,29 +87,32 @@ $ npm install -g local-web-server
``` ```
## Distribute with your project ## 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 ```sh
$ npm install local-web-server --save-dev $ npm install local-web-server --save-dev
``` ```
Then add an `start` script to your `package.json` (the standard npm approach):
2. Add a `start` command to your `package.json`:
```json ```json
{ {
"name": "my-web-app",
"name": "example",
"version": "1.0.0", "version": "1.0.0",
"local-web-server": {
"port": 8100,
"forbid": "\\.json$"
},
"scripts": { "scripts": {
"start": "ws" "start": "ws"
} }
} }
``` ```
This simplifies a rather specific-looking instruction set like:
```sh
$ npm install
$ npm install -g local-web-server
$ ws
```
3. Document how to build and launch your site
to the following, server implementation and launch details abstracted away:
```sh ```sh
$ npm install $ npm install
$ npm start $ npm start

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "local-web-server", "name": "local-web-server",
"version": "0.5.23", "version": "0.5.23",
"description": "Lightweight static web server, zero configuration. Perfect for front-end devs.",
"description": "A simple web-server for productive front-end development",
"bin": { "bin": {
"ws": "./bin/cli.js" "ws": "./bin/cli.js"
}, },

Loading…
Cancel
Save