From 69c2def2ff20f80f707c403972e2f7d207e1a2ab Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Thu, 6 Jun 2019 10:27:14 +0100 Subject: [PATCH] deps, readme, remove API docs --- README.md | 63 ------------------------------------------------------- doc/api.md | 51 -------------------------------------------- index.js | 27 ------------------------ package-lock.json | 38 ++++++++++++++++++++------------- package.json | 15 +++++++------ 5 files changed, 32 insertions(+), 162 deletions(-) delete mode 100644 doc/api.md diff --git a/README.md b/README.md index 4dd58da..bbe6263 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![Coverage Status](https://coveralls.io/repos/github/lwsjs/local-web-server/badge.svg?branch=master)](https://coveralls.io/github/lwsjs/local-web-server?branch=master) [![Dependency Status](https://badgen.net/david/dep/lwsjs/local-web-server)](https://david-dm.org/lwsjs/local-web-server) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard) -[![Join the chat at https://gitter.im/lwsjs/local-web-server](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lwsjs/local-web-server?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) **Requires node v8 or above. Upgraders, please read the [release notes](https://github.com/lwsjs/local-web-server/releases)**. @@ -87,68 +86,6 @@ $ ws --http2 Serving at https://mbp.local:8000, https://127.0.0.1:8000, https://192.168.0.100:8000 ``` -### Mock responses - -Imagine the network is down or you're working offline, proxied requests to `https://internal-service.local/api/users/1` would fail. In this case, Mock Responses can fill the gap. Mocks are defined in a module which can be reused between projects. - -Trivial example - respond to a request for `/rivers` with some JSON. Save the following Javascript in a file named `example-mocks.js`. - -```js -module.exports = MockBase => class MockRivers extends MockBase { - mocks () { - return { - route: '/rivers', - responses: [ - { - response: { - type: 'json', - body: [ - { name: 'Volga', drainsInto: 'Caspian Sea' }, - { name: 'Danube', drainsInto: 'Black Sea' }, - { name: 'Ural', drainsInto: 'Caspian Sea' }, - { name: 'Dnieper', drainsInto: 'Black Sea' } - ] - } - } - ] - } - } -} -``` - -Launch `ws` passing in your mocks module. - -```sh -$ ws --mocks example-mocks.js -Serving at http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:8000 -``` - -GET your rivers. - -```sh -$ curl http://127.0.0.1:8000/rivers -[ - { - "name": "Volga", - "drainsInto": "Caspian Sea" - }, - { - "name": "Danube", - "drainsInto": "Black Sea" - }, - { - "name": "Ural", - "drainsInto": "Caspian Sea" - }, - { - "name": "Dnieper", - "drainsInto": "Black Sea" - } -] -``` - -See [the tutorials](https://github.com/lwsjs/local-web-server/wiki#tutorials) for more information and examples about mock responses. - ## Further Documentation [See the wiki for plenty more documentation and tutorials](https://github.com/lwsjs/local-web-server/wiki). diff --git a/doc/api.md b/doc/api.md deleted file mode 100644 index a5633cf..0000000 --- a/doc/api.md +++ /dev/null @@ -1,51 +0,0 @@ - - -## local-web-server -**Emits**: module:local-web-server#event:verbose -**Example** -```js -const LocalWebServer = require('local-web-server') -const localWebServer = new LocalWebServer() -const server = localWebServer.listen({ - 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 -``` - -* [local-web-server](#module_local-web-server) - * [LocalWebServer](#exp_module_local-web-server--LocalWebServer) ⏏ - * [.listen([options])](#module_local-web-server--LocalWebServer+listen) ⇒ Server - - - -### LocalWebServer ⏏ -**Kind**: Exported class - - -#### localWebServer.listen([options]) ⇒ Server -Returns a listening HTTP/HTTPS server. - -**Kind**: instance method of [LocalWebServer](#exp_module_local-web-server--LocalWebServer) -**Params** - -- [options] object - Server options - - [.port] number - Port - - [.hostname] string - The hostname (or IP address) to listen on. Defaults to 0.0.0.0. - - [.maxConnections] number - The maximum number of concurrent connections supported by the server. - - [.keepAliveTimeout] number - The period (in milliseconds) of inactivity a connection will remain open before being destroyed. Set to `0` to keep connections open indefinitely. - - [.configFile] string - Config file path, defaults to 'lws.config.js'. - - [.https] boolean - Enable HTTPS using a built-in key and cert registered to the domain 127.0.0.1. - - [.key] string - SSL key file path. Supply along with --cert to launch a https server. - - [.cert] string - SSL cert file path. Supply along with --key to launch a https server. - - [.pfx] string - Path to an PFX or PKCS12 encoded private key and certificate chain. An alternative to providing --key and --cert. - - [.ciphers] string - Optional cipher suite specification, replacing the default. - - [.secureProtocol] string - Optional SSL method to use, default is "SSLv23_method". - - [.stack] Array.<string> | Array.<Middlewares> - Array of feature classes, or filenames of modules exporting a feature class. - - [.server] string | ServerFactory - Custom server factory, e.g. lws-http2. - - [.websocket] string | Websocket - Path to a websocket module - - [.moduleDir] Array.<string> - One or more directories to search for modules. - diff --git a/index.js b/index.js index 15c7a32..74a13eb 100644 --- a/index.js +++ b/index.js @@ -23,25 +23,6 @@ const Lws = require('lws') * @alias module:local-web-server */ class LocalWebServer extends Lws { - /** - * 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. - * @param [options.maxConnections] {number} - The maximum number of concurrent connections supported by the server. - * @param [options.keepAliveTimeout] {number} - The period (in milliseconds) of inactivity a connection will remain open before being destroyed. Set to `0` to keep connections open indefinitely. - * @param [options.configFile] {string} - Config file path, defaults to 'lws.config.js'. - * @param [options.https] {boolean} - Enable HTTPS using a built-in key and cert registered to the domain 127.0.0.1. - * @param [options.key] {string} - SSL key file path. Supply along with --cert to launch a https server. - * @param [options.cert] {string} - SSL cert file path. Supply along with --key to launch a https server. - * @param [options.pfx] {string} - Path to an PFX or PKCS12 encoded private key and certificate chain. An alternative to providing --key and --cert. - * @param [options.ciphers] {string} - Optional cipher suite specification, replacing the default. - * @param [options.secureProtocol] {string} - Optional SSL method to use, default is "SSLv23_method". - * @param [options.stack] {string[]|Middlewares[]} - Array of feature classes, or filenames of modules exporting a feature class. - * @param [options.moduleDir] {string[]} - One or more directories to search for modules. - * @returns {Server} - */ - getDefaultConfig () { return Object.assign(super.getDefaultConfig(), { moduleDir: [ __dirname, '.' ], @@ -50,12 +31,4 @@ class LocalWebServer extends Lws { } } -/** - * Highly-verbose debug information event stream. - * - * @event module:local-web-server#verbose - * @param key {string} - An identifying string, e.g. `server.socket.data`. - * @param value {*} - The value, e.g. `{ socketId: 1, bytesRead: '3 Kb' }`. - */ - module.exports = LocalWebServer diff --git a/package-lock.json b/package-lock.json index fd18126..e69e1a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -645,9 +645,9 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "coveralls": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.3.tgz", - "integrity": "sha512-viNfeGlda2zJr8Gj1zqXpDMRjw9uM54p7wzZdvLRyOgnAfCe974Dq4veZkjJdxQXbmdppu6flEajFYseHYaUhg==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.4.tgz", + "integrity": "sha512-eyqUWA/7RT0JagiL0tThVhjbIjoiEUyWCjtUJoOPcWoeofP5WK/jb2OJYoBFrR6DvplR+AxOyuBqk4JHkk5ykA==", "dev": true, "requires": { "growl": "~> 1.10.0", @@ -1731,9 +1731,9 @@ } }, "load-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-module/-/load-module-2.0.0.tgz", - "integrity": "sha512-1cWxQTYoB77vrMj6feNV3kMb6PZtH8vUgLhSQow7RE8OgQCLjSUuScyYABbw5duPViIuEXfaVEte1LZ3t4rJAg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/load-module/-/load-module-2.0.1.tgz", + "integrity": "sha512-uPi6sDp/7rcX5hP8jRncyBa63++qOJxczYAoq58DpoAnQmLJ+e7zz8qmRS+zfkOGEhqj10SFwuZrZuen8Ep5zQ==", "requires": { "array-back": "^3.1.0" } @@ -1809,15 +1809,16 @@ } }, "lws": { - "version": "2.0.0-8", - "resolved": "https://registry.npmjs.org/lws/-/lws-2.0.0-8.tgz", - "integrity": "sha512-uG5+n+gk0j6txsxm6bkxJX0EcI3frOQdDaNjt8P0oHVLcBNIAf1H6fDm3YcHBEKwWS1A3EgZec7d4upIUfy43g==", + "version": "2.0.0-9", + "resolved": "https://registry.npmjs.org/lws/-/lws-2.0.0-9.tgz", + "integrity": "sha512-E4fBFt/uIQzoVIIzXK5FVCGfffAY+Z75pVjVWBVQjJRvd67+FfhtoKsiIkBKCq8K9QhUjUWu26hVTVsJKQk6TA==", "requires": { "ansi-escape-sequences": "^4.1.0", "array-back": "^3.1.0", "byte-size": "^5.0.1", "command-line-args": "^5.1.1", "command-line-usage": "^5.0.5", + "create-mixin": "^2.0.1", "koa": "^2.7.0", "load-module": "^2.0.0", "lodash.assignwith": "^4.2.0", @@ -1826,6 +1827,13 @@ "reduce-flatten": "^2.0.0", "typical": "^5.0.0", "walk-back": "^3.0.1" + }, + "dependencies": { + "create-mixin": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/create-mixin/-/create-mixin-2.0.1.tgz", + "integrity": "sha512-r11aTk2z5x2C9ZI85oxuZ0EzgjBH0BdGacnXeuA+9d59xV2Hsy+ZpRmU+LUjJT9KdnLgzaxZoCbqrJ5qjl0bAA==" + } } }, "lws-basic-auth": { @@ -1879,9 +1887,9 @@ } }, "lws-index": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/lws-index/-/lws-index-1.0.1.tgz", - "integrity": "sha512-j9ba7EfMtNl2Ejm3jAtK999+R7zpZlq/eWGbJi2sBww28ZNZkNHEt1Dqhf9d59RyINjVozcwRAqJ9JHzQ0jGVQ==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lws-index/-/lws-index-1.0.2.tgz", + "integrity": "sha512-cU0UohkIFnI1mHhs/fn3VuBTBWKl9soOnPXR8zUBoaYBfnNepFsVmnhpEmQIdDXXOtWZedIXFV5JH+aNWwLlmg==", "requires": { "serve-index": "^1.9.1" } @@ -1917,9 +1925,9 @@ } }, "lws-request-monitor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/lws-request-monitor/-/lws-request-monitor-1.0.1.tgz", - "integrity": "sha512-POyRl0Dbq6smsjKT0b9vb/GCYbCnfGHj91tdTga1P7qz1rpgaLEqmqPxvYUq3iGu49n16YdGBdSZ1rUUE5Eqdw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/lws-request-monitor/-/lws-request-monitor-1.0.3.tgz", + "integrity": "sha512-g0McT3GV8Gm9nCnlEXUJ5vTOgpiBgA2O0nxOQFzzpW0aDR5fxh2MoFYKxjpkOX09YaSdgpAaXdQV2ts/Ixk8Lw==", "requires": { "byte-size": "^5.0.1" } diff --git a/package.json b/package.json index 2b1b1d6..71d814e 100644 --- a/package.json +++ b/package.json @@ -20,14 +20,17 @@ "rest", "mock", "api", - "proxy" + "proxy", + "lws", + "backend", + "frontend", + "full-stack" ], "engines": { "node": ">=8" }, "scripts": { "test": "test-runner test/*.js", - "docs": "jsdoc2md -p list index.js lib/*.js > doc/api.md; echo", "cover": "nyc npm test && nyc report --reporter=text-lcov | coveralls" }, "files": [ @@ -36,26 +39,26 @@ "index.js" ], "dependencies": { - "lws": "2.0.0-8", + "lws": "2.0.0-9", "lws-basic-auth": "^1.0.2", "lws-blacklist": "^2.0.1", "lws-body-parser": "^1.0.1", "lws-compress": "^1.0.1", "lws-conditional-get": "^1.0.0", "lws-cors": "^2.0.0", - "lws-index": "^1.0.1", + "lws-index": "^1.0.2", "lws-json": "^1.0.0", "lws-log": "^1.0.0", "lws-mime": "^1.0.0", "lws-range": "^2.0.0", - "lws-request-monitor": "^1.0.1", + "lws-request-monitor": "^1.0.3", "lws-rewrite": "^2.0.0", "lws-spa": "^2.0.0", "lws-static": "^1.1.0", "node-version-matches": "^1.0.1" }, "devDependencies": { - "coveralls": "^3.0.3", + "coveralls": "^3.0.4", "jsdoc-to-markdown": "^5.0.0", "node-fetch": "^2.6.0", "nyc": "^14.1.1",