From 4533b5c1d4961b6588c2e43ff45e195978e61178 Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Sat, 8 Jul 2017 16:30:57 +0100 Subject: [PATCH] docs --- README.md | 2 +- lib/cli-app.js | 3 --- lib/command/serve.js | 4 ---- lib/local-web-server.js | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a4f6165..cf7cf56 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ # local-web-server -The modular web server for productive full-stack development. +The modular web server for productive full-stack development, powered by [lws](https://github.com/lwsjs/lws). Use this tool to: diff --git a/lib/cli-app.js b/lib/cli-app.js index da2b862..33a17fd 100644 --- a/lib/cli-app.js +++ b/lib/cli-app.js @@ -1,9 +1,6 @@ 'use strict' const LwsCliApp = require('lws/lib/cli-app') -/** - * @alias module:local-web-server - */ class WsCliApp extends LwsCliApp { constructor (options) { super (options) diff --git a/lib/command/serve.js b/lib/command/serve.js index d5a0aa9..8845a62 100644 --- a/lib/command/serve.js +++ b/lib/command/serve.js @@ -1,10 +1,6 @@ const ServeCommand = require('lws/lib/command/serve') const path = require('path') -/** - * @module local-web-server - */ - class WsServe extends ServeCommand { execute (options, argv) { const usage = require('lws/lib/usage') diff --git a/lib/local-web-server.js b/lib/local-web-server.js index 5455322..e6c9e76 100644 --- a/lib/local-web-server.js +++ b/lib/local-web-server.js @@ -1,7 +1,41 @@ const Lws = require('lws') const path = require('path') +/** + * @module local-web-server + * @example + * const LocalWebServer = require('local-web-server') + * const localWebServer = new LocalWebServer() + * const server = localWebServer.create({ + * port: port, + * directory: 'src' + * }) + */ + + /** + * @alias module:local-web-server + */ class LocalWebServer extends Lws { + /** + * Create 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.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. + * @returns {Server} + */ create (options) { const usage = require('lws/lib/usage') usage.defaults