From 34373217ec51c884bb7487f465279eb38d6585fd Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Sun, 9 Jul 2017 09:10:51 +0100 Subject: [PATCH] readme, docs, deps --- README.md | 4 +++- lib/local-web-server.js | 12 ++++++++---- package.json | 18 +++++++++--------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index cf7cf56..dd38e05 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/local-web-server.js b/lib/local-web-server.js index dfd92f1..e549291 100644 --- a/lib/local-web-server.js +++ b/lib/local-web-server.js @@ -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) { diff --git a/package.json b/package.json index f55f117..59658cf 100644 --- a/package.json +++ b/package.json @@ -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": {