readme, docs, deps

This commit is contained in:
Lloyd Brookes
2017-07-09 09:10:51 +01:00
parent 5da7ee12c6
commit 34373217ec
3 changed files with 20 additions and 14 deletions

View File

@ -56,7 +56,9 @@ Serving at http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:80
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:
*If a static file at the requested path exists (e.g. `/css/style.css`) then serve it, if it does 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)).
### URL rewriting and proxied requests

View File

@ -7,9 +7,13 @@ const path = require('path')
* const LocalWebServer = require('local-web-server')
* const localWebServer = new LocalWebServer()
* const server = localWebServer.listen({
* port: port,
* directory: 'src'
* port: 8050,
* https: true,
* directory: 'src',
* spa: 'index.html',
* websocket: 'src/websocket-server.js'
* })
* // secure, SPA server with listening websocket now ready on port 8050
*/
/**
@ -17,7 +21,7 @@ const path = require('path')
*/
class LocalWebServer extends Lws {
/**
* Create a listening HTTP/HTTPS server.
* Returns a listening HTTP/HTTPS server.
* @param [options] {object} - Server options
* @param [options.port] {number} - Port
* @param [options.hostname] {string} -The hostname (or IP address) to listen on. Defaults to 0.0.0.0.
@ -33,7 +37,7 @@ class LocalWebServer extends Lws {
* @param [options.stack] {string[]|Middlewares[]} - Array of feature classes, or filenames of modules exporting a feature class.
* @param [options.server] {string|ServerFactory} - Custom server factory, e.g. lws-http2.
* @param [options.websocket] {string|Websocket} - Path to a websocket module
* @param [options.moduleDir] {string[]} - One or more directories to search for feature modules.
* @param [options.moduleDir] {string[]} - One or more directories to search for modules.
* @returns {Server}
*/
listen (options) {

View File

@ -33,19 +33,19 @@
"author": "Lloyd Brookes <75pound@gmail.com>",
"dependencies": {
"lws": "^1.0.0-pre4.0",
"lws-blacklist": "^0.2.1",
"lws-blacklist": "^0.2.3",
"lws-body-parser": "^0.2.4",
"lws-compress": "^0.2.1",
"lws-conditional-get": "^0.3.3",
"lws-cors": "^0.3.2",
"lws-index": "^0.3.2",
"lws-cors": "^0.3.4",
"lws-index": "^0.3.3",
"lws-json": "^0.3.2",
"lws-log": "^0.3.1",
"lws-mime": "^0.2.1",
"lws-mock-response": "^0.4.0",
"lws-request-monitor": "^0.1.3",
"lws-rewrite": "^0.3.5",
"lws-spa": "^0.2.2",
"lws-log": "^0.3.2",
"lws-mime": "^0.2.2",
"lws-mock-response": "^0.4.2",
"lws-request-monitor": "^0.1.4",
"lws-rewrite": "^0.3.6",
"lws-spa": "^0.2.3",
"lws-static": "^0.4.1"
},
"devDependencies": {